Informix: procedure with output parameters?

独自空忆成欢 提交于 2019-12-24 10:16:09

问题


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..


回答1:


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.



来源:https://stackoverflow.com/questions/3880517/informix-procedure-with-output-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!