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

Duplicate cursor names

P: n/a
Hello all,

I asked this question a slightly different way earlier and didnt get a
response so I thought I would rephrase it. I contacted db2 support on
it also but never got a definite answer..I got a lot of "should be"
and "maybe".

DB2 Info Center states this:

Description
cursor-name
Specifies the name of the cursor created when the source program is
run. The name must not be the same as the name of another cursor
declared in the source program. The cursor must be opened before use.

So in saying that, if I am running in a multi-threaded environment and
I have an API that does record updates using dynamic SQL, does this
mean my one cursor could because corrupt in some way even if I do not
see any cursor open errors?

for instance, the api works like this:

update_record_function(query)
{
s1 = SELECT * FROM sometable WHERE somecolumn = somevalue FOR UPDATE
OF somecolumns
EXEC SQL PREPARE stmt FROM :s1;
EXEC SQL DESCRIBE stmt INTO :*p_sqlda;
EXEC SQL DECLARE c1 CURSOR WITH HOLD FOR stmt;
EXEC SQL OPEN c1;
s1 = UPDATE sometable SET (columns) = (values) WHERE CURRENT of C1;
EXEC SQL FETCH c1 USING DESCRIPTOR :*p_sqlda;
......
EXEC SQL CLOSE;

}

Since this is called by multiple process and threads is there an issue
with the cursor name being C1 in all calls?

Oct 12 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"shorti" <lb******@juno.comwrote in message
news:11********************@y27g2000pre.googlegrou ps.com...
Hello all,

I asked this question a slightly different way earlier and didnt get a
response so I thought I would rephrase it. I contacted db2 support on
it also but never got a definite answer..I got a lot of "should be"
and "maybe".

DB2 Info Center states this:

Description
cursor-name
Specifies the name of the cursor created when the source program is
run. The name must not be the same as the name of another cursor
declared in the source program. The cursor must be opened before use.

So in saying that, if I am running in a multi-threaded environment and
I have an API that does record updates using dynamic SQL, does this
mean my one cursor could because corrupt in some way even if I do not
see any cursor open errors?

for instance, the api works like this:

update_record_function(query)
{
s1 = SELECT * FROM sometable WHERE somecolumn = somevalue FOR UPDATE
OF somecolumns
EXEC SQL PREPARE stmt FROM :s1;
EXEC SQL DESCRIBE stmt INTO :*p_sqlda;
EXEC SQL DECLARE c1 CURSOR WITH HOLD FOR stmt;
EXEC SQL OPEN c1;
s1 = UPDATE sometable SET (columns) = (values) WHERE CURRENT of C1;
EXEC SQL FETCH c1 USING DESCRIPTOR :*p_sqlda;
......
EXEC SQL CLOSE;

}

Since this is called by multiple process and threads is there an issue
with the cursor name being C1 in all calls?
I am not quite sure about your application threading environment, but
generally the cursor name only has to be unique within the program, even if
the program is simultaneously called multiple times.

If there were a problem, you would get an error message that the cursor is
already open when you try to open it.
Oct 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.