当前位置: 代码迷 >> DB2 >> db2 存储过程
  详细解决方案

db2 存储过程

热度:996   发布时间:2013-02-26 00:00:00.0
db2 存储过程求助
这样的存储过程有错吗?
怎么不能创建,要怎么才能创建这样的存储过程
create procedure bb 
(
in i integer,
in j integer
)
dynamic result sets 2
language sql
begin 
declare sc1 cursor with return to caller for select * from bas_dpt;
open sc1;
end;

------解决方案--------------------------------------------------------
CREATE PROCEDURE SP2 ( IN whichQuery INTEGER )
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- SQL Stored Procedure 
-- whichQuery
------------------------------------------------------------------------
P1: BEGIN
-- Declare cursors
DECLARE cursor1 CURSOR WITH RETURN FOR
SELECT PROCSCHEMA, PROCNAME FROM SYSCAT.PROCEDURES;

CASE whichQuery
WHEN 0 THEN
-- Cursor left open for client application
OPEN cursor1;
WHEN 1 THEN
Insert a statement or click Create SQL.;
END CASE;
END P1

------解决方案--------------------------------------------------------
楼上正解。

存储过程语法:http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.sql.ref.doc/doc/r0008329
  相关解决方案