Professional Web Applications Themes

Help me - IBM DB2

Hi to all NG I have a problem with my c program. I try to manage a cursor, but I can't able to do. my problem is this : suppose to have a table t1, describe with a columns c1, c2 .. cn Now: ..... ..... EXEC SQL DECLARE c11 CURSOR WITH HOLD FOR select c1, c2 , c3 from t1 where c4 = 1 ; EXEC SQL OPEN c11 ; while ( TRUE ) { EXEC SQL FETCH c11 INTO var1:ivar1 , var2:ivar2, var3:ivar3; if no data found the exit ; ..... } DESIDERATA: I 'ld like to write ...

  1. #1

    Default Help me

    Hi to all NG

    I have a problem with my c program. I try to manage a cursor, but I can't
    able to do.
    my problem is this :
    suppose to have a table t1, describe with a columns c1, c2 .. cn Now:
    .....
    .....
    EXEC SQL DECLARE c11 CURSOR WITH HOLD FOR
    select c1, c2 , c3
    from t1
    where c4 = 1 ;

    EXEC SQL OPEN c11 ;

    while ( TRUE ) {
    EXEC SQL FETCH c11 INTO var1:ivar1 , var2:ivar2, var3:ivar3;
    if no data found the exit ;
    .....
    }

    DESIDERATA:
    I 'ld like to write these piece of code in this way

    fun_declare_open()
    int main(argv, argc)
    {
    ....
    fun_declare_open() ;
    ....
    while ( TRUE ) {
    EXEC SQL FETCH c11 INTO var1:ivar1 , var2:ivar2, var3:ivar3;
    if no data found the exit ;
    ....
    }
    }
    fun_declare_open()
    {
    EXEC SQL DECLARE c11 CURSOR WITH HOLD FOR
    select c1, c2 , c3
    from t1
    where c4 = 1 ;

    EXEC SQL OPEN c11 ;
    }

    In the DESIDEARATA case during the precompilation the system told me that
    the cursor c11 was undefined!!??!?!

    Why ?

    someone can help me ?
    I hope yes

    Best thanks and best regards
    sergio


    EAP90210 Guest

  2. #2

    Default Re: Help me

    "EAP90210" <it> wrote in message
    news:bn0a3u$jf0$inet.it... 
    The Declare Cursor is not actually a separate piece of executable SQL code.
    It is actually part of the Open Cursor statement and must occur before the
    Open Cursor (actually anywhere in the program before the Open Cursor
    statement). Also, make sure that you don't check the SQL return code of the
    Declare Cursor statement, because since it is not an executable SQL
    statement, you are really checking the return code of the previous SQL
    statement that was executed in your program.

    Most people place the Declare Cursor towards the front of the program where
    variables are defined.


    Mark Guest

  3. #3

    Default Re: Help me

    Best thanks for your answer!

    Can you show me an address that is possible to see a "c" program that call
    an sql for db2 ?

    thanks again
    Sergio
    p.s. : I 'm a junior and I have not a sufficient experience !
    [cut] 
    > The Declare Cursor is not actually a separate piece of executable SQL[/ref]
    code. 
    the 
    where 


    EAP90210 Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139