Re: Basic PRO*C problem

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Fri, 13 Aug 1999 21:43:44 GMT
Message-ID: <37bc90f7.38194600_at_newshost.us.oracle.com>


A copy of this was sent to Patrick Drouin <patrick.drouin_at_remove_this.nortel.com> (if that email address didn't require changing) On Fri, 13 Aug 1999 10:55:54 -0400, you wrote:

>Hello everyone,
>
> PRO*C is driving me crasy. I am trying to compile a VERY SIMPLE program
>that uses a cursor. I've done it in the past and ran into problem but
>moving some code around fixed it (don't ask why!). Now, it just won't
>budge.
>
> PRO*C compiles the C file without any problems but gcc or the Sun
>compiler will not accept the generated code (I would do the same...).
>Here's the snippet of my code. Anything wrong with this?
>

you don't mention the error but is it something like:

gcc -I. -g -c t.c

t.pc: In function `process':
t.pc:87: break statement not within loop or switch
make: *** [t.o] Error 1


if so, add to your code:

>/* We query the USER_PROFILES_CHANGES table */
>/* and grab all the entries. The ACTION column */
>/* tells us what to do and the status tells us */
>/* which rows we need to process. */
> EXEC SQL DECLARE user_list CURSOR FOR
> SELECT user_id, password, action
> FROM USER_PROFILES_CHANGES
> WHERE status=0;
>
>/* Open the cursor we have prepared */
>EXEC SQL OPEN user_list;
>
>/* Loop on the cursor and break if empty */
>EXEC SQL WHENEVER NOT FOUND DO break;
>for(;;)
>{
> /* Fetch values into our HOST variables */
> EXEC SQL FETCH user_list INTO :new_user, :new_user_password,
>:action;
> printf("%s\t%s\t%s\n",new_user,new_user_password,action);
>}

EXEC SQL WHENEVER NOT FOUND CONTINUE; It is happening because the directive just puts code like "if sqlca.sqlcode==-1403 break;" into your code. thats only valid in a LOOP and errors out outside of a loop.

If it is not the error, that would be helpful to know (what is the error)

>
>/* Close the cursor */
>EXEC SQL CLOSE user_list;
>
>Regards,
>Patrick

-- 
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
 
Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Fri Aug 13 1999 - 23:43:44 CEST

Original text of this message