Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PRO*C bug?

Re: PRO*C bug?

From: Brett Robson <Xbrett_r_at_yahoo.com>
Date: 1998/11/21
Message-ID: <365684F0.67B5D30@yahoo.com>#1/1

Nortel wrote:

>
>
> (*1) EXEC SQL WHENEVER NOT FOUND DO break;
> for (;;)
> {
> EXEC SQL FETCH C_TM_EXTRACT INTO :blablabla
> }
>
> EXEC SQL CLOSE C_TM_EXTRACT;
>
> (*2) EXEC SQL EXECUTE
> BEGIN
> tm_utils.create_initial_list(1, 18289, 496182);
> END;
> END-EXEC;
You should never use an infinite loop such as for(;;), lots of experienced C programmers do and then use break to get out of it. Logically a break is exactly the same as a goto and is bad for the same reasons. One of the problems with your code is the C loop may still continue if you get other oracle errors but would need to check the rest of your code. Also if the pro C compiler puts an extra loop in that you weren't counting on your break will be breaking the wrong loop.

Also you should not use WHENEVER for the same reason, but also because if you don't keep changing it you may end up in an unanticipated part of your programme.

Moral: keep your SQL and C as separate as possible.

You should write more a structured program, psuedo code follows, sql code in upper, C in lower

WHENEVER ERROR CONTINUE
OPEN CURSOR if sqlerror !=0

     proces_sql_error()
else

     while sql_error = 0
          FETCH

     if sql_error = 1403 (not found)
         CLOSE CURSOR
         ok continue
     else
         prob got a serious error

I don't guarrantee the above is prefect or exactly what you want but you should get the idea.

Brett



remove X in address to email Received on Sat Nov 21 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US