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: Pro*C++: Problem with Pointer to Array of Struct

Re: Pro*C++: Problem with Pointer to Array of Struct

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/04/20
Message-ID: <8dmves$bm3$1@nnrp1.deja.com>#1/1

In article <38FE1CEB.7952E3F1_at_t-online.de>,   Ullrich Bartels <ullrich.bartels_at_t-online.de> wrote:
> Hi,
>
> I tried out the example shown in the "Pro*C/C++ Precompiler
 Programmer=B4=
> s =
>
> Guide, Chapter 12: Using Host Array, Example6: Using a Pointer to an =
>
> Array of Structs" (pages 12-26/27):
>
> typedef struct dept
> {
> int deptno;
> char dname[15];
> char loc[14];
> }
>
> void insert_data(d, n)
> dept *d;
> int n;
> {
> exec sql for :n insert into dept values ( :d );
> }
>
> The PreCompiler gave the following err message:
>
> Semantic error at line 12, column 17, file test.pc:
> exec sql for :n insert into dept values ( :d );
> =2E...............1
> PCC-S-02322, found undefined indentifier
> Semantic error at line 12, column 17, file test.pc:
> exec sql for :n insert into dept values ( :d );
> =2E...............1
> PCC-S-02330, expecting an expression of integer type
> Semantic error at line 12, column 46, file test.pc:
> exec sql for :n insert into dept values ( :d );
> =2E............................................1
> PCC-S-02322, found undefined indentifier
>
> =
>
> So, has anyone got an idea?
>
> Thx
> Ullrich
>

on some systems, PARSE defaults to NONE meaning all identifiers by default must be in EXEC SQL BEGIN/END DECLARE SECTION; tags. Add PARSE=FULL to the proc command line to make it so that this is not the case. that'll get rid of the identifier not found issue.

I just precompiled and compiled:

typedef struct dept {
 int deptno;
 char dname[15];
 char loc[14];
} dept;

void process( dept * d, int n )
{

    exec sql for :n insert into dept values ( :d ); }

main( int argc, char * argv[] )
{

char     result[255];
dept     d[5];
int      i;

    for( i = 0; i < 4; i++ )
    {

        d[i].deptno = i;
        sprintf( d[i].dname, "Dept-%d", i );
        sprintf( d[i].loc, "Loc-%d", i );
    }

    EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();     EXEC SQL CONNECT :USERID;
    printf("\nConnected to ORACLE as user: %s\n\n", USERID);

    process( d, 4 );

    exec sql commit work release;
}

and it worked OK (as long as PARSE=FULL is true)

--
Thomas Kyte                              tkyte_at_us.oracle.com
Oracle Service Industries
http://osi.oracle.com/~tkyte/index.html
--
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Apr 20 2000 - 00:00:00 CDT

Original text of this message

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