如何在另一个存储过程中调用存储过程并如何像在DB2中的变量中那样设置值 [英] How to call stored procedure inside another stored procedure and set the values as in variable in DB2

查看:124
本文介绍了如何在另一个存储过程中调用存储过程并如何像在DB2中的变量中那样设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将存储过程调用到另一个存储过程中,并返回存储在db2中的变量中的值。

I need to call stored procedure into another stored procedure and return value stored in variable in db2.

谢谢

推荐答案

一个例子可能就是这个例子:

One examples could be this one:

 DECLARE STMT STATEMENT;
 PREPARE STMT FROM 'CALL MODIFY_DESCENDANTS (?, ?)';
 EXECUTE STMT USING LOG_ID, LEVEL;

来自log4db2- https://github.com/angoca/log4db2/blob/master/src/main/sql-pl /03-UtilityBody.sql#L729

Taken from log4db2 - https://github.com/angoca/log4db2/blob/master/src/main/sql-pl/03-UtilityBody.sql#L729

如果存储过程返回一个结果集,并且您要从中获取值,则需要调用存储过程,并使用关联和分配语句。例如,您可以访问 https:/ /www.toadworld.com/platforms/ibmdb2/w/wiki/7460.call-allocate-and-associate

If the stored procedure returns a result set, and you want to take values from that, then you need to call the stored procedure and use the associate and allocate statements. For an example, you can visit https://www.toadworld.com/platforms/ibmdb2/w/wiki/7460.call-allocate-and-associate

CALL EMPR;
ASSOCIATE RESULT SET LOCATOR (LOC1) WITH PROCEDURE EMPR;
ALLOCATE C1 CURSOR FOR RESULT SET LOC1;

这篇关于如何在另一个存储过程中调用存储过程并如何像在DB2中的变量中那样设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆