这是错误消息: PLS-00428: an INTO clause is expected in this SELECT statement. 同时,这是测试显示系统日期的过程:
CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" AS BEGIN SELECT SYSDATE FROM DUAL; END;首先,我不需要使用INTO Oracle坚持让我这样做。 还有其他方法使用光标(我在这里看到它https://stackoverflow.com/a/6029963/1983024 )? 我认为它不应该是这样,它确实正常运行,就像在MS SQL中不使用INTO或游标一样。
This is the error message: PLS-00428: an INTO clause is expected in this SELECT statement. Meanwhile, this is the procedure for testing displaying the system date:
CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" AS BEGIN SELECT SYSDATE FROM DUAL; END;In the first place I don't need to use that INTO Oracle is insisting for me to do. Is there other way around beside using a cursor (I've seen it here https://stackoverflow.com/a/6029963/1983024)? I think it should not be like that, this does run normally just like in MS SQL without using INTO or cursor.
最满意答案
首先,我不需要使用INTO Oracle坚持让我这样做。
事实是,Oracle是正确的:您确实需要使用INTO来获取返回值。
毕竟,如果要显示查询结果,您将需要一个变量将其放在第一位。
Finally found a solution to the output I want (based on your responses) :D
CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" RET_DATE CHAR(10); BEGIN SELECT TO_CHAR(SYSDATE, 'MM/DD/YYYY') INTO RET_DATE FROM DUAL; DBMS_OUTPUT.PUT_LINE(RET_DATE); END;This displays the SYSDATE with format of MM/DD/YYYY. Still, thanks for the replies and ideas (mostly @Jeffrey Kemp). Oracle just lengthens what MS SQL can normally do in one line :D
更多推荐
发布评论