Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Austin, TX

    Unanswered: pro*c bind variables

    i'm required to optimize some previously written pro*c code. i'm new to pro*c, but very fluent in c. this segment kinda confuses me:

    int my_int = 0;
    EXEC SQL DECLARE my_cursor FOR
    SELECT *
    FROM my_table
    WHERE my_col = :my_int;
    if (blah)
    	my_int = 1;
    EXEC SQL OPEN my_cursor;
    EXEC SQL FETCH my_cursor into :blahblah;
    notice that my_int is conditionally assigned <after> it is used in the my_cursor declaration. if blah is true, will it affect results of the fetch?

    thanks for the help.

  2. #2
    Join Date
    Mar 2004


    No, you can put any value into the variables and every time you use the FETCH statement it will be changed to the database field value, ie:

    int i;

    i = 10; /* i value is 10 */

    cursor declaration...
    cursor open...

    for (;
    if (SQLCODE)

    fetch cursor into :i; /* it changes i to the field dabase value */
    printf("%d", i); /* print the value of the database field */

    i = 11; /* now i = 11 */
    printf("%d", i); /* print 11 */

    close cursor...
    free cursor...

    I hope this help you.

  3. #3
    Join Date
    Apr 2004
    Austin, TX
    i am afriad you completely misunderstood my question.

    please review the code i posted. notice at the time of the "declare cursor" statement, my_int is 0. but at the time of the "open" and "fetch" statements, my_int could be 1. will this affect the results of the fetch?

Posting Permissions

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