Duplicate cursor names

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shorti

    #1

    Duplicate cursor names

    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_f unction(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?

  • Mark A

    #2
    Re: Duplicate cursor names

    "shorti" <lbryan21@juno. comwrote in message
    news:1192210199 .823188.7770@y2 7g2000pre.googl egroups.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_f unction(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.


    Comment

    Working...