【问题标题】:Oracle procedure (failure od date format)Oracle 过程(失败 od 日期格式)
【发布时间】:2018-12-05 16:56:14
【问题描述】:

我有这个程序:

SQL> create or replace procedure KORELACJA (START IN DATE, END IN DATE) AS
  2  BEGIN
  3  SELECT T.City, Corr(T.Value, H.Value)
  4  FROM TEMP T 
  5  INNER JOIN HUMIDITY H 
  6  on T.City = H.City 
  7  and T.mDate = H.mDate 
  8  WHERE T.mDate between to_date(START,'YYYY-MM-DD') and to_date(END,'YYYY-MM-DD') 
  9  GROUP BY T.City
 10  END;
 11  /

出现错误:ORA-06550:第 1 行,第 7 列:

有人知道如何解决这个问题吗?

[编辑]

SQL> show error procedure KORELACJA;
Errors for PROCEDURE KORELACJA:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/1      PLS-00428: an INTO clause is expected in this SELECT statement

【问题讨论】:

  • 你能粘贴show error procedure KORELACJA;的输出吗?
  • 我编辑了描述。
  • DECLARE 两个变量说t_cityt_h_corr,然后将SELECT T.City, Corr(T.Value, H.Value) 替换为SELECT T.City, Corr(T.Value, H.Value) INTO t_city, t_h_corr
  • 我试过了,但还是不行。我应该将每个 T.City 更改为 t_city 吗?
  • 在 PL/SQL 查询中必须选择 INTO 变量。 Find out more

标签: oracle date plsql procedure


【解决方案1】:

看看这个例子;在代码中读取 cmets。

我创建了示例表,只是为了确保过程代码能够编译。

SQL> create table temp (city varchar2(10), value number, mdate date);

Table created.

SQL> create table humidity (city varchar2(10), value number, mdate date);

Table created.

程序本身:

SQL> create or replace procedure korelacja
  2    (p_start in date, p_end in date)           --> renamed parameters
  3  is
  4    l_city temp.city%type;                     --> declared local variables for SELECT
  5    l_corr number;                             --  statement's results
  6  begin
  7    select t.city, corr(t.value, h.value)
  8      into l_city, l_corr                      --> missing INTO clause
  9      from temp t join humidity h on t.city = h.city
 10                                 and t.mdate = h.mdate
 11      where t.mdate between p_start and p_end  --> parameters already are DATEs; you don't
 12      group by t.city;                         --  need TO_DATE against them
 13  end;
 14  /

Procedure created.

SQL>

【讨论】:

  • 非常感谢您的帮助。我真的很感激。
猜你喜欢
  • 2022-12-07
  • 1970-01-01
  • 1970-01-01
  • 2018-01-28
  • 2020-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多