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

发布于 2024-08-11 07:23:23 字数 489 浏览 8 评论 0原文

我有一个如下所示的 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;

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

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

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

I have an Oracle script that looks like the following:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

谁与争疯 2024-08-18 07:23:23

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

根据这个网站(第二awnser) 这表明您正在尝试执行缺少参数的查询。

例如:

exec SomeStoredProcedureThatReturnsASite( :L_kSite );

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

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

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

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

For instance :

exec SomeStoredProcedureThatReturnsASite( :L_kSite );

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

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

命硬 2024-08-18 07:23:23

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

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.

吃素的狼 2024-08-18 07:23:23

我认为它与jdbc有关。

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

a = :namedparameter and b = :namedparameter

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

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

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

I think its related with jdbc.

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

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.

神仙妹妹 2024-08-18 07:23:23

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

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

对你的占有欲 2024-08-18 07:23:23

我遇到此错误是因为包含问号的列的别名中出现了一些拼写错误(例如,contract.reference 作为contract?ref)

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)

别在捏我脸啦 2024-08-18 07:23:23

我在 SQL Developer 中遇到问题,因为我错误地使用了绑定。正在使用这个,从日志中复制:

变量=?

应该是

变量=:变量

现在 SQL Developer 提示我输入值。

I had issue in SQL Developer because I was using binds incorrectly. Was using this, copied from log:

variable = ?

should be

variable = :variable

Now SQL Developer prompts me for values.

七月上 2024-08-18 07:23:23

我在某些用户设置中偶尔出现相同的错误,而其他人则对相同的报告感到满意。我用改变大小写的北欧字母编写了参数,例如:Henkilö。我将它们改为 HENKILO,仅使用大写字母,不使用北欧字母,结果成功了。

该驱动程序是 Oracle 的某些未知或不同的 JDBC 版本。

我的错误描述源自某些第 3 方 bin:
Excel 插件错误:执行语句失败(索引:: 4 处缺少 IN 或 OUT 参数)
SQL 语句失败。请核实并更正!

I got the same error sporadically appearing on some user setup, while others were content with the same report. I had my parameters written in altered case and with nordic letters, for example: Henkilö. I changed them to HENKILO, using only upper case and no nordics, and it did the trick.

The driver is some unknown or varying JDBC version to Oracle.

My error desc was originated from some 3rd party bin:
Excel Plugin Error: Failed executing statement (Missing IN or OUT parameter at index:: 4)
SQL Statement failed. Please verify and correct it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文