Home » Developer & Programmer » Precompilers, OCI & OCCI » C+ and Oracle
C+ and Oracle [message #94338] Tue, 10 August 2004 03:08
RR
Messages: 19
Registered: October 2001
Junior Member
I am trying to use the following code base to just connect with oracle. Looks like I am missing steps in the precompilation/inclusion of libraries in Makefile.

Platform - Solaris 8
=====================
Oracle 9i
==========

MakeFile
=========
include $(ORACLE_HOME)/rdbms/lib/env_rdbms.mk

INCLUDE_DIR=-I.
#LIBDIR=$(ORACLE_HOME)/lib
#LIBS=-lclntsh -locci
#LIB= -L$(LIBDIR) $(LIBS)

two: two.cpp
.cpp $(SHARED_LDCLIENTLIBS) $(LLIBTHREAD)

clean:
rm -f two *.o *.out

# end of Makefile

Actual Code
============
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "./sqlda.h"
#include "./sqlcpr.h"
/* host variable*/

EXEC SQL begin declare section;

char user[[20]];

char pass[[20]];

EXEC SQL end declare section;

#include "./sqlca.h"

int main()

{

strcpy(user,"cemsmaster");

strcpy(pass,"cemsmaster");

EXEC SQL connect :user identified by :pass;

printf ("byen");

return 0;

}

Error
========
bash-2.03$ make two
gcc -o two -I. two.cpp -lclntsh `cat /opt/oracle/u01/app/oracle/product/9.2.0/lib/ldflags` `cat /opt/oracle/u01/app/oracle/product/9.2.0/lib/sysliblist` -
R/opt/oracle/u01/app/oracle/product/9.2.0/lib -laio -lposix4 -lkstat -lm -lthread
two.cpp:8: error: `EXEC' does not name a type
two.cpp:14: error: `EXEC' does not name a type
two.cpp: In function `int main()':
two.cpp:32: error: `EXEC' undeclared (first use this function)
two.cpp:32: error: (Each undeclared identifier is reported only once for each function it appears in.)
two.cpp:32: error: expected `;' before "SQL"
*** Error code 1
make: Fatal error: Command failed for target `two'

Comments??
Previous Topic: ORA-00000 in Precompiler
Next Topic: SQLCode = -904
Goto Forum:
  


Current Time: Sat Aug 15 15:39:27 CDT 2020