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

Home -> Community -> Usenet -> c.d.o.server -> Re: New to Pro*C -- Help Please -- Unexpected results

Re: New to Pro*C -- Help Please -- Unexpected results

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Tue, 26 Jan 1999 13:50:09 GMT
Message-ID: <36b3c7da.2691430@192.86.155.100>


A copy of this was sent to "Jun" <jmarcos_at_skyinet.net> (if that email address didn't require changing) On Mon, 25 Jan 1999 13:22:18 +0800, you wrote:

>Hello,
>
>I need help about --
>
>My program had been compiled successfully but the result is
>different from expected.
>
>In the main module i'd connected to Oracle successfully (First Module that
>has a Pro*C).
>Then I'd try to execute the next module ( with Pro*C Source code) -
>unexpected result occurs.
>
>My source codes is like this:
>
>...
>
> /* Copy all contents of CDR_REJECT for recycle */
> EXEC SQL WHENEVER SQLERROR DO sql_error("Oracle error:");
> EXEC SQL INSERT INTO ISRS.CDR_FOR_RECYCLE
> SELECT * FROM ISRS.CDR_REJECT
> WHERE Recycle_Flag=1;
>
> nRowsRecycle = sqlca.sqlerrd[2]; /* Im expecting here the no. of rows
>inserted */
>
>...
>....
>
> if(nRowsRecycle!=0L) {
> /* process the table here */
>...
> }
>
>
>The variable 'sqlca' here is a global variable declared & initialized
>somehere.
>The Table 'ISRS.CDR_FOR_RECYCLE' initialyhas no content -- so I'm expecting
>the variable 'nRowsRecycle' to be equal to zero but it is not. What happens?
>
>I'd tried to print the value of 'sqlca.sqlerrd[2]' in ladebug but it can't,
>it gives an error
>similar to "can't parse C statement" (i.e 'print (sqlca.sqlerrd[2])' ). Why?
>

print is not a C function (although printf is) hence the cause of that error. Here is an example of what you are attempting that works:

static void process( void )
{
long rowCount;

    EXEC SQL WHENEVER SQLERROR CONTINUE;     EXEC SQL DROP TABLE T;     EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();     EXEC SQL CREATE TABLE T AS SELECT * FROM ALL_USERS WHERE 1=0;     EXEC SQL INSERT INTO T SELECT * FROM ALL_USERS;     rowCount = sqlca.sqlerrd[2];

    if ( rowCount != 0 )
    {

        printf( "A non-zero number of rows (%ld) was processed\n", rowCount);     }
    else
    {

        printf( "Zero of rows processed\n" );     }
    EXEC SQL COMMIT;
}

what does your ENTIRE example look like?

>
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Tue Jan 26 1999 - 07:50:09 CST

Original text of this message

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