多个返回值的 ODBC 调用语法

发布于 2024-12-07 08:41:52 字数 1308 浏览 0 评论 0原文

首先,对于问题的长度感到抱歉...基本上,

我在从 Informix 数据库调用存储过程时遇到问题,其中存储过程有多个返回值,同时在 .NET 中使用 ODBC(又名 ODBCCommand),我还没有在互联网上看到有人做过这样的事情……那么这有可能吗?

因此,首先使用 ODBCCommand(或一般的 ODBC)调用 SP,您应该使用 ODBC 调用语法

粗略的存储过程:

create procedure informix.proc_ins (
  n_company char(10),
  n_message_body lvarchar(4096),
  n_time int,
  n_time_dt datetime year to second,
  n_processed smallint)

returning
  int,
  int;

begin
  define row_count int;
  define new_serial int;

INSERT into my_table ( company, message_body, time, time_dt, processed, create_user, create_dt, recmod_user, recmod_dt) 
VALUES ( n_company, n_message_body, n_time, n_time_dt, n_processed, USER, CURRENT YEAR TO SECOND, USER, CURRENT YEAR TO SECOND);

let new_serial = DBINFO('sqlca.sqlerrd1');
let row_count = DBINFO('sqlca.sqlerrd2');

return
  new_serial,
  row_count;     

end
end procedure;

因此,给定此 SP,ODBC 调用语法将类似于:

{XXXX = call informix.proc_ins(?,?,?,?,?)}

其中“XXXX”以某种方式有 2 个“?”...?

对此的任何帮助将不胜感激。

另外,在有人说“使用 IBM.Data.Informix 驱动程序”(其中任何一个)之前,在这种情况下这是不可能的,因为“旧”驱动程序无法与 VS2010 配合使用,并且新驱动程序无法安装在 VS2010 上。同时使用与旧电脑相同的电脑,但那是另一天的完全不同的咆哮。

So first off, sorry for the length of the question...

So basically I'm having issues calling a stored proc from an Informix database where the stored proc has multiple return value, while using ODBC in .NET (aka an ODBCCommand), and I haven't seen anything on the internet where someone has done this before... so is it even possible?

So to begin with using an ODBCCommand (or ODBC in general) to call an SP your supposed to use the ODBC Call Syntax.

Rough Stored Procedure:

create procedure informix.proc_ins (
  n_company char(10),
  n_message_body lvarchar(4096),
  n_time int,
  n_time_dt datetime year to second,
  n_processed smallint)

returning
  int,
  int;

begin
  define row_count int;
  define new_serial int;

INSERT into my_table ( company, message_body, time, time_dt, processed, create_user, create_dt, recmod_user, recmod_dt) 
VALUES ( n_company, n_message_body, n_time, n_time_dt, n_processed, USER, CURRENT YEAR TO SECOND, USER, CURRENT YEAR TO SECOND);

let new_serial = DBINFO('sqlca.sqlerrd1');
let row_count = DBINFO('sqlca.sqlerrd2');

return
  new_serial,
  row_count;     

end
end procedure;

So given this SP the ODBC Call Syntax would look something like:

{XXXX = call informix.proc_ins(?,?,?,?,?)}

where 'XXXX' somehow has 2 '?'s... ?

Any help with this would be really appreciated.

Also before someone says "use the IBM.Data.Informix drivers" (either of them), it's not possible in this case because the 'old' one doesn't work with VS2010, and the new one can't be installed on the same PCs as the old one at the same time, but that's a totally different rant for another day.

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

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

发布评论

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

评论(2

木槿暧夏七纪年 2024-12-14 08:41:52

我在 ESQL/C 中执行此操作的方法是将 EXECUTE PROCEDURE informix.proc_ins(...) 语句视为 SELECT 语句 - 也就是说,声明一个游标(可能在准备语句),然后使用OPEN(有机会传入参数)和FETCH和CLOSE来获取数据。

我希望在 ODBC 中使用相同的技术 - 可能会绕过一般的 ODBC 调用语法。

如果您需要使用官方 ODBC 符号/方法的官方答案,则必须让其他人提供答案。

The way I'd do it in ESQL/C is to treat the EXECUTE PROCEDURE informix.proc_ins(...) statement as if it was a SELECT statement - that is, declare a cursor (possibly after preparing the statement), and then using OPEN (chance to pass in parameters) and FETCH and CLOSE to get the data.

I'd expect to use the same technique in ODBC - probably bypassing the general ODBC Call Syntax.

If you need the official answer using the official ODBC notation/method, you'll have to get someone else to provide the answer.

呢古 2024-12-14 08:41:52

我不相信有“官方”ODBC 答案。这取决于司机。没有什么可以阻止您使用 SQL_PARAM_RETURN 作为多个参数的类型,但至于如何调用它,ODBC 没有说明。

I don't believe there is a "official" ODBC answer. Its down to the driver. There is nothing stopping you from using SQL_PARAM_RETURN as the type for more than one parameter, but as to how you would call that, ODBC doesn't say.

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