Home » Developer & Programmer » Precompilers, OCI & OCCI » Need help on Pro*C compilation (Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production, OS- Unix AIX 5.1)
Need help on Pro*C compilation [message #429572] Wed, 04 November 2009 10:26
Learning.Oracle
Messages: 1
Registered: November 2009
Junior Member
Hi All,
I am a beginner in Pro*C. I have written below Pro*C program
/*--------------------------------------------------------------------
 * Very simple example Pro*C program to select records from a database
 *
  *--------------------------------------------------------------------
 */

#include <stdio.h>
#include <sqlca.h>

void sqlerror();

EXEC SQL BEGIN DECLARE SECTION;
char *connstr = "user/password@dbname";
char db_racf_id[30];
int  db_orgztn_key;
EXEC SQL END DECLARE SECTION;

void main() {
        EXEC SQL WHENEVER SQLERROR DO sqlerror();
        EXEC SQL WHENEVER SQLWARNING CONTINUE;
        EXEC SQL CONNECT :connstr;

        EXEC SQL WHENEVER NOTFOUND GOTO notfound;
        EXEC SQL SELECT RACF_ID, ORGZTN_KEY
                 INTO   db_racf_id, db_orgztn_key
                 FROM   IDENTITY
                 WHERE  RACF_ID = CI466;

found:
        printf("%s has Organisation %i\n", db_racf_id, db_orgztn_key);
        return;

notfound:
        printf("Identity record not found in database.\n");
        return;
}

void sqlerror() {
        printf("Stop Error:\t%25i\n", sqlca.sqlcode);
        return;
}

After above program is written, I did following steps to compile it
$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Nov 03 06:09 first.pc
$->proc first.pc

Pro*C/C++: Release 8.1.7.0.0 - Production on Wed Nov 4 10:19:21 2009

(c) Copyright 2000 Oracle Corporation.  All rights reserved.

System default option values taken from: /oracle/app/oracle/product/8.1.7/precomp/admin/pcscfg.cfg

$->ls -lrt first*
-rwxrwxrwx    1 sqloper4 staff          1069 Nov 03 06:09 first.pc
-rw-r--r--    1 sqloper4 staff             0 Nov 04 10:19 first.lis
-rw-r--r--    1 sqloper4 staff          6648 Nov 04 10:19 first.c
$->
$->cc first.c
first.c:142:19: error: sqlca.h: A file or directory in the path name does not exist.
first.c: In function 'main':
first.c:170: error: 'sqlca' undeclared (first use in this function)
first.c:170: error: (Each undeclared identifier is reported only once
first.c:170: error: for each function it appears in.)
first.c:154: warning: return type of 'main' is not 'int'
first.c: In function 'sqlerror':
first.c:260: error: 'sqlca' undeclared (first use in this function)
$->

Could you please help me solve above issue?

Thanks in advance!


Previous Topic: to retrieve the metadata of prepared statement using OCI calls.
Next Topic: Strange "SELECT" sql got somehow repeatly executed
Goto Forum:
  


Current Time: Thu Mar 28 05:50:47 CDT 2024