Example of using dynamic cursors for DB2 stored procedures (1)

Source: Internet
Author: User

This article will introduce you to an example of using dynamic cursors in a DB2 stored procedure. If you are interested in using dynamic cursors, it may be helpful for you to learn how to use DB2.

Create procedure data_wtptest (IN in_taskid_timestamp varchar (30 ),

OUT o_err_no int,
OUT o_err_msg varchar (1024 ))
LANGUAGE SQL

P1: BEGIN ATOMIC
-- Declaration start
-- Temporary Variable Error variable
Declare sqlcode integer default 0;
DECLARE SQLStmt varchar (1024) default '';
DECLARE r_code integer default 0;
DECLARE state varchar (1024) default 'aaa'; -- Record the current work of the program
DECLARE at_end int DEFAULT 0;
DECLARE t_destnetid int default 0;
DECLARE t_recvid varchar (30) default '';
DECLARE SP_Name varchar (50) default 'data _ wtptest ';


-- Declare the value of the cursor
-- Declare the Dynamic Cursor storage variable
DECLARE stmt1 STATEMENT;
DECLARE c1 cursor for stmt1;

-- Declaring error handling
DECLARE EXIT HANDLER FOR SQLEXCEPTION


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.