Informix:带有输出参数的程序?

发布于 2024-09-26 19:28:35 字数 458 浏览 10 评论 0原文

我搜索了很多,但找不到任何东西..我只是想问是否有任何方法可以创建和调用不带参数的过程(Informix)。我知道如何返回一个或多个值(对于过程和函数),但这不是我想要的。如果 Informix 不允许输出参数,那就真的很奇怪了。

提前感谢!

编辑:是的,我看到这是可能的,但我仍然无法执行这样的过程。例如:

  CREATE PROCEDURE mytest(batch INT,OUT p_out INT)  
  DEFINE inc INTEGER;  
  LET inc = 1;  
  LET p_out = 5;  
  END PROCEDURE;  

我收到的是:

例程 mytest 无法解析

,这种情况仅在执行带有输出参数的函数时发生。

I searched a lot, but couldn't find anything.. I just want to ask if there's any way to create and call a procedure (Informix) with out parameters. I know how to return one or more values (for procedures and for functions), but this is not what I want. It would be really strange, if Informix does not allow output parameters..

Thanks in advance!

EDIT: Yes, I saw it's possible, but I still can't execute such procedure. For example:

  CREATE PROCEDURE mytest(batch INT,OUT p_out INT)  
  DEFINE inc INTEGER;  
  LET inc = 1;  
  LET p_out = 5;  
  END PROCEDURE;  

and what I receive is:

The routine mytest can not be resolved

and this happens only on executing functions with output parameters..

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

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

发布评论

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

评论(1

Smile简单爱 2024-10-03 19:28:36

为什么需要“out”参数? Informix 过程可以从单个调用返回多个值(或者,在本例中,返回单个值):

  CREATE PROCEDURE mytest(batch INT) RETURNING INT AS p_out;
      DEFINE inc INTEGER;
      DEFINE p_out INTEGER;
      LET inc = 1;
      LET p_out = batch + inc;
      RETURN p_out;
  END PROCEDURE;

可以使用 OUT 参数的位置有限。一种是在查询中 - 有一个名称 SLV(语句局部变量)出现在一些错误消息中。我相信也有一种方法可以通过 Java (JDBC) 获取 OUT 参数。 AFAIK,其他 API 不允许这样做。

为 Informix 编写的代码假定它不需要输出参数。从其他(贫乏的?)系统迁移到 Informix 的代码(这些系统不从单个过程提供多个输出值)需要重新考虑,以便与 Informix 合理地配合使用。

Why do you need 'out' parameters? Informix procedures can return multiple values from a single call (or, in this case, a single value):

  CREATE PROCEDURE mytest(batch INT) RETURNING INT AS p_out;
      DEFINE inc INTEGER;
      DEFINE p_out INTEGER;
      LET inc = 1;
      LET p_out = batch + inc;
      RETURN p_out;
  END PROCEDURE;

There are only a limited number of places where you can use an OUT parameter. One is in a query - there is a name SLV (statement local variable) that turns up in some error messages. I believe there's a way to get to OUT parameters via Java (JDBC) too. AFAIK, other APIs do not allow it.

Code written for Informix assumes that it won't need output parameters. Code migrated to Informix from other (impoverished?) systems that do not provide multiple output values from a single procedure need to be rethought to work sensibly with Informix.

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