By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,558 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,558 IT Pros & Developers. It's quick & easy.

Cursors

P: 1
I have created sql that I tested out using microsoft sql server (since I'm more familiar with it) and it works. When I try to run it in db2, I'm running into problems with a cursor definition. I'm not sure if I need this in a stored procedure, or there's some other problem with what I'm trying to do. I'm using advanced query tool to run my sql statement. Here's part of my code:

DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_org
(
agmt_id decimal(15),
rol_plyr_anchr_id decimal(15),
depth_fm_parnt smallint,
full_nm varchar(100)
);

--load temp_org


DECLARE policy_cursor CURSOR
FOR SELECT rol_plyr_anchr_id FROM SESSION.TEMP_pol;

OPEN policy_cursor;

The declare temp table is okay, but it doesn't seem to like my declare of my policy_cursor. I'm receiving the following error message:

42601(-104)[IBM][CLI Driver][DB2/AIX64] SQL0104N An unexpected token "DECLARE POLICY_CURSOR CURSOR FOR SELECT" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<space>". SQLSTATE=42601
Any suggestions would be much appreciated. I am a novice at DB2.

Thanks, Yolanda
Sep 6 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.