我有这个Oracle存储过程:
create or replace
procedure bns_saa_message_get() <--- PROBLEM IS HERE BC I HAVE NO PARAMS TO PASS
AS
begin
select HostNumber, SAAMessage from BNS_SAA_MESSAGES where HostNumber=(select max(HostNumber) from BNS_SAA_MESSAGES);
end;
当我尝试编译它时出现以下错误:
Error(2,31): PLS-00103: Encountered the symbol ")" when expecting one of the following: <an identifier> <a double-quoted delimited-identifier> current
问题:
如何在不需要传递任何参数的情况下创建存储过程?
答案 0 :(得分:4)
完全省略括号:
create or replace
procedure bns_saa_message_get
AS
railroad diagram in the documentation表示如果包括左括号,则至少需要一个参数。
答案 1 :(得分:4)
删除括号:
CREATE OR REPLACE PROCEDURE bns_saa_message_get
AS
BEGIN
SELECT hostnumber, saamessage
FROM bns_saa_messages
WHERE hostnumber = (SELECT MAX (hostnumber) FROM bns_saa_messages);
END;
编辑:
回答你的第二个问题......
CREATE OR REPLACE PROCEDURE bns_saa_message_get
AS
v_hostnumber bns_saa_messages.hostnumber%TYPE;
v_saamessage bns_saa_messages.saamessage%TYPE;
BEGIN
SELECT hostnumber, saamessage
INTO v_hostnumber, v_saamessage
FROM bns_saa_messages
WHERE hostnumber = (SELECT MAX (hostnumber) FROM bns_saa_messages);
END;
这假设您只从查询中返回一行.... 如果您获得多行,则必须bulk collect进入集合。
答案 2 :(得分:1)
如果没有任何参数,请删除()。
示例:procedure bns_saa_message_get() - &gt;程序bns_saa_message_get AS