Oracle“SQL 错误:索引处缺少 IN 或 OUT 参数:: 1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1752719/
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 02:15:27  来源:igfitidea点击:

Oracle "SQL Error: Missing IN or OUT parameter at index:: 1"

oracleoracle-sqldeveloper

提问by Otis

I have an Oracle script that looks like the following:

我有一个如下所示的 Oracle 脚本:

variable L_kSite number;
variable L_kPage number;
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
exec SomeStoredProcedureThatAddsAPageToTheSite( :L_kSite, :L_kPage );
update SiteToPageLinkingTable 
set HomePage = 1 
where kSite = :L_kSite and kPage = :L_kPage;

Supposedly the last statement is a valid use of a bind variable but when I try to run the script I get this on the last line:

据说最后一条语句是对绑定变量的有效使用,但是当我尝试运行脚本时,我在最后一行得到了这个:

SQL Error: Missing IN or OUT parameter at index:: 1

I'm not sure how to proceed here as I'm not especially proficient in Oracle.

我不知道如何在这里继续,因为我不是特别精通 Oracle。

采纳答案by Otis

Based on the comments left above I ran this under sqlplus instead of SQL Developer and the UPDATE statement ran perfectly, leaving me to believe this is an issue in SQL Developer particularly as there was no ORA error number being returned. Thank you for leading me in the right direction.

根据上面留下的评论,我在 sqlplus 而不是 SQL Developer 下运行了这个,并且 UPDATE 语句运行得很好,让我相信这是 SQL Developer 中的一个问题,特别是因为没有返回 ORA 错误号。谢谢你带领我走向正确的方向。

回答by ForceMagic

I had a similar error on my side when I was using JDBC in Java code.

当我在 Java 代码中使用 JDBC 时,我也遇到了类似的错误。

According to this website(the second awnser) it suggest that you are trying to execute the query with a missing parameter.

根据此网站(第二个 awnser),它建议您尝试使用缺少的参数执行查询。

For instance :

例如 :

exec SomeStoredProcedureThatReturnsASite( :L_kSite );

You are trying to execute the query without the last parameter.

您试图在没有最后一个参数的情况下执行查询。

Maybe in SQLPlusit doesn't have the same requirements, so it might have been a luck that it worked there.

也许SQLPlus它没有相同的要求,所以它在那里工作可能是一种运气。

回答by sanyag

I think its related with jdbc.

我认为它与jdbc有关。

I have a similar problem (missing param) when I have a where condition like this:

当我有这样的 where 条件时,我有一个类似的问题(缺少参数):

a = :namedparameter and b = :namedparameter

It's ok, When I have like this:

没关系,当我有这样的时候:

a = :namedparameter and b = :namedparameter2  (the two param has the same value)

So it's a problem with named parameters. I think there is a bug around named parameter handling, it looks like if only the first parameter get the right value, the second is not set by driver classes. Maybe its not a bug, only I don't know something, but anyway I guess that's the reason for the difference between the SQL dev and the sqlplus running for you, because as far as I know SQL developer uses jdbc driver.

所以这是命名参数的问题。我认为命名参数处理存在一个错误,看起来如果只有第一个参数获得正确的值,第二个参数不是由驱动程序类设置的。也许它不是一个错误,只是我不知道什么,但无论如何我想这就是为您运行的 SQL dev 和 sqlplus 之间存在差异的原因,因为据我所知 SQL developer 使用 jdbc 驱动程序。

回答by Tomek

I got the same error and found the cause to be a wrong or missing foreign key. (Using JDBC)

我遇到了同样的错误,发现原因是外键错误或丢失。(使用 JDBC)

回答by user7095343

I had this error because of some typo in an alias of a column that contained a questionmark (e.g. contract.reference as contract?ref)

由于包含问号的列的别名中有一些拼写错误(例如 contract.reference as contract?ref),我遇到了这个错误