我有以下针对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;

尝试编译时收到以下错误:



问题:
如何在不需要向其传递任何参数的地方创建存储过程?

最佳答案

卸下支架:

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放入集合中。

关于oracle - PLS-00103 : Encountered the symbol “)” when expecting one of the following:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9826829/

10-10 01:47