Home > Database > Mysql Tutorial > body text

DB2游标使用注意事项

WBOY
Release: 2016-06-07 17:13:21
Original
1390 people have browsed it

1、游标的一般使用步骤 (1)定义游标 EXEC SQL DECLARE MY_CURSOR CURSOR FOR........ (2)打开游标 EXEC SQL OPEN MY_CURSOR

1、游标的一般使用步骤

(1)定义游标

EXEC SQL DECLARE MY_CURSOR CURSOR FOR........

(2)打开游标

EXEC SQL OPEN MY_CURSOR ;

(3)读取游标

EXEC SQL FETCH MY_CURSOR  INTO :MY_Stru;

(4)关闭游标

EXEC SQL CLOSE MY_CURSOR;

2、注意事项

(1)每步操作有都应该加上对SQLCODE的判断

(2)读取游标后若有COMMIT或ROLL BACK操作,则定义游标时必须加上WITH HOLD选项,保证提交后游标不被关闭。

(3)读取游标后,一般会有逻辑操作,逻辑操作若报错退出,必须关闭游标。

(4)对于只读操作,定义游标时加上 FOR READ ONLY

(5)对于更新操作,定义游标时加上 FOR UPDATE,,也可以指定更新的字段。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template