使用 InfoSphere Data Architect 对 DB2 存储过程进行开发、调试与部署
2010-05-13 00:00:00 来源:WEB开发网查看原图(大图)
16. 确认所有设置正确后点击“完成”以创建存储过程
新创建的存储过程被保存在“TestSPProject”项目的“存储过程”文件夹中,同时内容在一个编辑器中显示,存储过程内容如下:
清单 3. 新创建的存储过程代码
CREATE PROCEDURE TESTEMPLOYEESP ( IN IN_EMPLOYEE_NAME VARCHAR(30),
OUT SQLSTATE_OUT CHAR(5),
OUT SQLCODE_OUT INTEGER )
DYNAMIC RESULT SETS 1
---------------------------------------------------------------------
-- SQL Stored Procedure
-- IN_EMPLOYEE_NAME
-- SQLSTATE_OUT
-- SQLCODE_OUT
---------------------------------------------------------------------
P1: BEGIN
-- Declare variables
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
DECLARE SQLCODE INT DEFAULT 0;
-- Declare cursor
DECLARE cursor1 CURSOR WITH RETURN FOR
SELECT ID, NAME
FROM EMPLOYEE
WHERE NAME = IN_EMPLOYEE_NAME;
-- Declare handler
DECLARE EXIT HANDLER FOR SQLEXCEPTION
SELECT SQLSTATE, SQLCODE INTO SQLSTATE_OUT, SQLCODE_OUT
FROM SYSIBM.SYSDUMMY1;
-- Cursor left open for client application
OPEN cursor1;
SET SQLSTATE_OUT = SQLSTATE;
SET SQLCODE_OUT = SQLCODE;
END P1
Tags:使用 InfoSphere Data
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接