#include <stdio.h>
#include <ctype.h>
#include "friend.h"
#include <sqlcode.h>
#include <atmi.h> /* tuxedo Header File */
#include <userlog.h> /* TUXEDO Header File */
/* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
*/
EXEC SQL INCLUDE sqlca;
EXEC SQL begin declare section;
static long friend_id;
static char fname[10];
static char fmobile[14];
static char conn[20];
EXEC SQL end declare section;
#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) || defined(__cplusplus)
ADD_FRIEND(TPSVCINFO *transb)
#else
ADD_FRIEND(transb)
TPSVCINFO *transb;
#endif
{
struct friendv *transv;
transv = (struct friendv*)transb->data;
friend_id=transv->friend_id;
strcpy(fname,transv->fname);
strcpy(fmobile,transv->fmobile);
strcpy(conn,"admin/keke@denver");
EXEC SQL CONNECT :conn;
EXEC SQL insert into FRIEND(FRIEND_ID,NAME,MOBILE)
value(:friend_id,:fname,:fmoblie);
if(SQLCODE != SQL_OK){
userlog("Cannot insert into FRIEND");
tpreturn(TPFAIL,0,transb->data,0L,0);
}
EXEC SQL ROLLBACK WORK RELEASE;
tpreturn(TPSUCCESS, 0, transb->data, 0L, 0);
}
这个代码编译就报错
[oracle@Oracle9iDemo simpapp]$ buildserver -f viewserv.c -o viewserv
CMDTUX_CAT:4188: WARN: server built without the -s option cannot advertise services.
viewserv.c:17:21: sqlcode.h: No such file or directory
viewserv.c:26: syntax error before "SQL"
viewserv.c:26: warning: data definition has no type or storage class
viewserv.c:27: syntax error before "SQL"
viewserv.c:27: warning: data definition has no type or storage class
viewserv.c:32: syntax error before "SQL"
viewserv.c:32: warning: data definition has no type or storage class
viewserv.c: In function `ADD_FRIEND':
viewserv.c:91: dereferencing pointer to incomplete type
viewserv.c:92: dereferencing pointer to incomplete type
viewserv.c:93: dereferencing pointer to incomplete type
viewserv.c:95: `EXEC' undeclared (first use in this function)
viewserv.c:95: (Each undeclared identifier is reported only once
viewserv.c:95: for each function it appears in.)
viewserv.c:95: syntax error before "SQL"
viewserv.c:99: `SQLCODE' undeclared (first use in this function)
viewserv.c:99: `SQL_OK' undeclared (first use in this function)
viewserv.c:103: syntax error before "SQL"
CMDTUX_CAT:1832: ERROR: can't execute cc -m32 -I$TUXDIR/include -o viewserv BS-79c9.c -L${TUXDIR}/lib viewserv.c -ltux -lbuft -lfml -lfml32 -lengine -ldl -lpthread
--友情转载