makefile
CPP = xlC_r7 -q64 -bh:5 -g.cpp中包含#include <sqlca.h>
CPPFLAGS = -c -o
LFLAGS = $(PLATFORM_DEF) -D_REENTRANT -D_THREAD_SAFE -g -w -o
LIB = -L$(PATH_LIB)
PATH_TEST =/ngbss/mddms/interface/other/SRBI/test
PROC_INCLUDE = -I${ORACLE_HOME}/precomp/public
PROC_LIB =-L${ORACLE_HOME}/lib -L${ORACLE_HOME}/precomp/lib -lclntsh
OCI_INCLUDE = -O -I${ORACLE_HOME}/rdbms/include -I${ORACLE_HOME}/rdbms/demo -I${ORACLE_HOME}/rdbms/public -I${ORACLE_HOME}/plsql/public -I${ORACLE_HOME}/network/public
OCI_LIBPATH = -L. -L.. -L${ORACLE_HOME}/lib
INCLUDE = $(OCI_INCLUDE)
OBJ_TEST =\
$(PATH_TEST)/a.o\
$(PATH_TEST)/b.o\
exec_test:
@$(CPP) $(CPPFLAGS) $(OBJ_TEST)
$(PATH_TEST)/a.o:
@$(CPP) $(PROC_INCLUDE) $(CPPFLAGS) $@ $(PATH_TEST)/a.cpp $(PROC_LIB)
$(PATH_TEST)/b.o:
@$(CPP) $(PROC_INCLUDE) $(CPPFLAGS) $@ $(PATH_TEST)/b.cpp $(PROC_LIB)
test:$(OBJ_TEST) exec_test
@$(CPP) a.o -o a
@$(CPP) b.o -o b
@a
@b
void ConnectDB(char userpass[200])
{
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR UserPasswd[200];
EXEC SQL END DECLARE SECTION;
bzero(&UserPasswd,sizeof(UserPasswd));
strcpy (UserPasswd.arr,userpass);
UserPasswd.len=strlen(UserPasswd.arr);
EXEC SQL connect :UserPasswd;
if (sqlca.sqlcode!=0)
{
PRINTF("连接数据库失败,错误代码:%ld\n",sqlca.sqlcode);
exit(-1);
}
}
错误:
"/ngbss/mddms/interface/other/SRBI/test/a.cpp", line 160.14: 1540-0040 (S) The text "SQL" is unexpected. "EXEC" may be undeclared or ambiguous.
------解决方案--------------------------------------------------------
哈哈,proc,有那么短么
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname ;