Oracle 程序(失败日期格式)
Oracle procedure (failure od date format)
我有这个程序:
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
看看这个例子;阅读代码中的注释。
我已经创建了示例表,只是为了确保程序代码可以编译。
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>
我有这个程序:
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
看看这个例子;阅读代码中的注释。
我已经创建了示例表,只是为了确保程序代码可以编译。
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>