使用 ADODB 的旧 VB6 应用程序在调用 Oracle 存储过程时抛出错误
这必须以某种方式与提供商相关,因为它在我的开发盒上运行良好,但在另一个开发盒上不起作用。
以下是我在非工作开发盒上遇到的错误:
ORA-00604: 递归 SQL 级别 1 发生错误
ORA-06502: PL/SQL: 数字或值错误: 字符串缓冲区太小
ORA-06512: at第 26 行
ORA-06550:第 1 行,第 7 列:
PLS-00306:调用“LISTAVAILSUBMISSIONS”时参数数量或类型错误
ORA-06550:第 1 行,第 7 列:
PL/SQL:忽略语句
这是 Oracle 过程:
Procedure ListAvailSubmissions (avail_submission in out rc_avail_submission)
is
Begin
open avail_submission for
select submission_id from nais_submissions
where condition = 'ONLINE'
and status in ('ACTIVE','LOGGED')
order by submission_id desc;
Exception
When no_data_found then
v_output := utl_file.fopen (v_errdir, v_errLog, 'a');
utl_file.put_line(v_output, to_char(sysdate,'HH24:MI:SS')||'-'||'ListAvailSubmission:Sub_id: No Data Found');
utl_file.fclose(v_output);
When others then
v_error_code := sqlcode;
v_error_message := substr (sqlerrm, 1, 300);
v_output := utl_file.fopen (v_errdir, v_errLog, 'a');
utl_file.put_line(v_output, to_char(sysdate,'HH24:MI:SS')||'-'||'ListAvailSubmission:Sub_id:'|| v_error_code ||':'|| v_error_message);
utl_file.fclose(v_output);
End ListAvailSubmissions;
正如您所看到的,唯一的参数是返回参数,它是结果记录集。VB
的调用非常简单。
Public Function GetTestRequests() As ADODB.Recordset
Dim rsADO As New ADODB.Recordset
Dim cmdCommand As New ADODB.Command
Set cmdCommand.ActiveConnection = cnnADO //Ive already verified the connection is good
cmdCommand.CommandText = "ListAvailSubmissions"
Set rsADO = cmdCommand.Execute(, , adCmdStoredProc)
Set GetTestRequests = rsADO
End Function
令人沮丧的是它可以在一台机器上运行,而不能在另一台机器上运行。我使用 msdaora.1 作为提供程序,并使用 MS CompChecker 工具验证了两台计算机具有相同的 MDAC 版本。我确实发现的一件事是,如果我将工作机器切换为使用 OraOLEDB 而不是 msdaora.1,它将抛出相同的错误。基于此,我开始认为非工作机器表现出正确的行为,并且我需要修复代码。
我已经做了相当多的研究,我认为这与 in out 参数有关,并尝试将 ADODB.Recordset 设置为等于该参数。我尝试将参数更改为仅 out 但没有帮助,仍然出现相同的错误。
感谢任何帮助,这个错误让我发疯。
This has to be provider related in some way because it works fine on my dev box but doesn't work on another dev box.
Here is the error I'm getting on the non-working dev box:
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 26
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'LISTAVAILSUBMISSIONS'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Here is the Oracle Procedure:
Procedure ListAvailSubmissions (avail_submission in out rc_avail_submission)
is
Begin
open avail_submission for
select submission_id from nais_submissions
where condition = 'ONLINE'
and status in ('ACTIVE','LOGGED')
order by submission_id desc;
Exception
When no_data_found then
v_output := utl_file.fopen (v_errdir, v_errLog, 'a');
utl_file.put_line(v_output, to_char(sysdate,'HH24:MI:SS')||'-'||'ListAvailSubmission:Sub_id: No Data Found');
utl_file.fclose(v_output);
When others then
v_error_code := sqlcode;
v_error_message := substr (sqlerrm, 1, 300);
v_output := utl_file.fopen (v_errdir, v_errLog, 'a');
utl_file.put_line(v_output, to_char(sysdate,'HH24:MI:SS')||'-'||'ListAvailSubmission:Sub_id:'|| v_error_code ||':'|| v_error_message);
utl_file.fclose(v_output);
End ListAvailSubmissions;
As you can see, the only parameter is the return parameter which is the resulting recordset
The call from VB is pretty simple.
Public Function GetTestRequests() As ADODB.Recordset
Dim rsADO As New ADODB.Recordset
Dim cmdCommand As New ADODB.Command
Set cmdCommand.ActiveConnection = cnnADO //Ive already verified the connection is good
cmdCommand.CommandText = "ListAvailSubmissions"
Set rsADO = cmdCommand.Execute(, , adCmdStoredProc)
Set GetTestRequests = rsADO
End Function
The frustrating part is the it works on one machine and not another. I'm using msdaora.1 as the provider and I've verified both machines have the same MDAC version using MS CompChecker tool. One thing I did discover is that if I switch the working machine to using OraOLEDB instead of msdaora.1, it will then throw the same error. Based on that I'm starting to think that the non-working machine is exhibiting the correct behavior and that I need to fix the code.
I have done quite a bit of research and I'm thinking it has to do with the in out parameter and trying to set an ADODB.Recordset equal to the parameter. I tried changing the parameter to out only but that didn't help, still got the same error.
Any help is appreciated, this error is driving me nuts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为表中的字符串之一超出了 OLEDB 字符串限制。对于不同的驱动程序,此限制的定义不同 - 因此您会看到一个驱动程序出错,而另一个驱动程序正常工作。我相信,这个限制也可以在逐台机器的基础上进行配置,这样你就可以让一台机器工作而另一台机器不工作。
检查结果集中的任何字符串是否超过 256 个字符或非常长的长度。然后从结果集中省略该记录以查看它是否有效。
I think one of the strings in your table exceeds the OLEDB string limit. This limit is defined differently for different drivers -- so you see one driver giving error and another works. This limit, I believe, can also be configured on a machine-by-machine basis, thus you have one machine working and one doesn't.
Check if any string in your result set is longer than, say, 256 characters or something really long. Then omit that record from your result set to see if it works.