oracle PLS-00103:在预期以下情况之一时遇到符号“)”:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9826829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:04:11  来源:igfitidea点击:

PLS-00103: Encountered the symbol ")" when expecting one of the following:

oraclestored-proceduressyntax-error

提问by Adrian

I have this stored procedure for Oracle:

我有这个 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;

I get the following error when I try to compile it:

当我尝试编译它时出现以下错误:

Error(2,31): PLS-00103: Encountered the symbol ")" when expecting one of the following:     <an identifier> <a double-quoted delimited-identifier>    current 
Error(2,31): PLS-00103: Encountered the symbol ")" when expecting one of the following:     <an identifier> <a double-quoted delimited-identifier>    current 

Question:
How do I make a stored procedure where I don't need to pass any arguments to it?

问题:
如何创建一个不需要传递任何参数的存储过程?

回答by Rob Kennedy

Simply omit the parentheses entirely:

只需完全省略括号:

create or replace
procedure bns_saa_message_get
AS

The railroad diagram in the documentationshows that if you include the opening parenthesis, then at least one argument is required.

文档中的铁路图显示,如果包含左括号,则至少需要一个参数。

回答by Ollie

Remove the brackets:

去掉括号:

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;

EDIT:

编辑:

To answer your second question...

回答你的第二个问题...

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;

This assumes you only get one row returned from your query.... If you get more than one row then you'll have to bulk collectinto a collection.

这假设您只从查询中返回一行......如果您得到不止一行,那么您将不得不批量收集到一个集合中。

回答by MarkSchoonover

Remove the () when you don't have any parameters.

当您没有任何参数时删除 ()。

Example: procedure bns_saa_message_get() -> procedure bns_saa_message_get AS

示例:过程 bns_saa_message_get() -> 过程 bns_saa_message_get AS