原贴描述:
===========================================
客户程序如下:我oracle10只有一个数据库是orcl
 oracleclient.c
#include <stdio.h>
#include <atmi.h>
#include <string.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
      char *sendbuf,*recvbuf;
      long sendlen,recvlen;
      int ret;
      if(argc!=2){
            printf("please call the format as : oracleclient %s \n",argv[0]);
            (void) fprintf(stderr, "Usage: oracleclient string\n");
            exit(1);
      }
      if(tpinit((TPINIT *)NULL)==-1){
            (void)fprintf(stderr,"failed to init!\n");
            exit(1);
      }
      sendlen=strlen(argv[1]);
      if((sendbuf=(char *)tpalloc("STRING",NULL,sendlen+1))==-1){
            (void)fprintf(stderr,"failed to allocate memory to sendbuf!\n");
            tpterm();
            exit(1);
      }
      if((recvbuf=(char *)tpalloc("STRING",NULL,5*sendlen+1))==-1){
            (void)fprintf(stderr,"failed to allocate memory for recvbuf!\n");
            tpterm();
            exit(1);
      }
      strcpy(sendbuf,argv[1]);
      ret = tpcall("ORACLES", (char *)sendbuf, 0, (char **)&recvbuf, &recvlen, (long)0);
      if(ret==-1){
            (void) fprintf(stderr, "Can't send request to service oracleserver\n");
            (void) fprintf(stderr, "Tperrno = %d, %s\n, ", tperrno, tpstrerror(tperrno));
            tpfree(sendbuf);
            tpfree(recvbuf);
            tpterm();
            exit(1);
      }
      (void)fprintf(stdout,"the return result is :%s \n",recvbuf);
      tpfree(sendbuf);
      tpfree(recvbuf);
      tpterm();
      return 0;
}
服务器server程序如下:
oracleserv.pc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include <userlog.h>
exec sql include sqlca;
tpsvrinit(int argc,char *argv[])
{
      if(tpopen()==-1){
            printf("error to connect to oracle!\n");
      }
      printf("the oracleserv successfully to connect to db2 in linux!\n");
      return 0;
}
ORACLES(TPSVCINFO *rqst)
{
      exec sql begin declare section;
      char db_string[50];
      exec sql end declare section;
      int i=0;
      for(i=0;i<rqst->len-1;i++){
            db_string=rqst->data;
      }
      exec sql delete from system.hmptest where username=:db_string;
      if(sqlca.sqlcode!=0){
            printf("delete error!\n");
            tpreturn(TPFAIL,0,NULL,0,0);
      }
      tpreturn(TPSUCCESS,0,rqst->data,0L,0);
}
tpsvrdone()
{
if(tpclose()==-1){
      printf("oracleserv close error!\n");
      return;
}
printf("oracleserv disconnected!\n");
return;
}
编译完全通过:
proc oracleserv.c parse=full include=/home/oracle/oracle/product/10.2.0/db_1/precomp/public include=/home/tuxedo/bea/tuxedo9.1/include
buildserver -o oracleserv -f "oracleserv.c -I/home/oracle/oracle/product/10.2.0/db_1/precomp/public" -r Oracle_XA -s ORACLES
没有错误。。正常运行
buildclient -o oracleclient -f oracleclient.c
但是那个exec sql delete from system.hmptest where username=:db_string;,..为什么不能执行
 我的RM文件里用户密码是system/oracle
在sqlplus 里system/oracle能完全操作hmptest数据表。。。
===========================================
  --转自
