免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 7461 | 回复: 13
打印 上一主题 下一主题

[Tuxedo] 在tuxedo里不能访问oracle表 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-21 13:31 |只看该作者 |倒序浏览
我已经把oralce10和tuxedo9。1完全配置好料,,一切都好了,系统是suse linux 10.1 x86 32bit

oracle和tuxedo都能正常启动运行。。。但是在写测试的程序的时候,在server端 的程序里调用exec sql delete from tables where username=:db_code..

结果无法运行。。。清问高如何解决。。。

非常感谢!
客户程序如下:我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数据表。。。

哪位大侠能告诉我为什么。。。非常感谢!

论坛徽章:
0
2 [报告]
发表于 2009-06-22 20:58 |只看该作者

回复 #1 xinxinhao 的帖子

哦,这个是2007年的帖子,不知道你当时问题解决了吗?怎么解决的?

论坛徽章:
0
3 [报告]
发表于 2009-06-22 21:02 |只看该作者

回复 #1 xinxinhao 的帖子

但是那个exec sql delete from system.hmptest where username=:db_string;,..为什么不能执行
我的RM文件里用户密码是system/oracle
===========================
oracleserv.pc
这个是pro*c程序吗?怎么没有main()?
===========================
exec sql begin declare section;
                char db_string[50];
        exec sql end declare section;
这个不是应该在程序开头吗?

论坛徽章:
0
4 [报告]
发表于 2009-06-22 21:14 |只看该作者
但是那个exec sql delete from system.hmptest where username=:db_string;,..为什么不能执行
=================
能说说怎么个不能执行法吗?
报什么错?还是没有响应?

论坛徽章:
0
5 [报告]
发表于 2009-06-22 21:18 |只看该作者
我知道pro*c/c++,经过预编译后都是.cc了,可是我还是想知道Tuxedo的client端和server端可以用不同的语言写吗?
============
我看你前面是.c后面是.pc,这样可以吗?

论坛徽章:
15
射手座
日期:2014-11-29 19:22:4915-16赛季CBA联赛之青岛
日期:2017-11-17 13:20:09黑曼巴
日期:2017-07-13 19:13:4715-16赛季CBA联赛之四川
日期:2017-02-07 21:08:572015年亚冠纪念徽章
日期:2015-11-06 12:31:58每日论坛发贴之星
日期:2015-08-04 06:20:00程序设计版块每日发帖之星
日期:2015-08-04 06:20:00程序设计版块每日发帖之星
日期:2015-07-12 22:20:002015亚冠之浦和红钻
日期:2015-07-08 10:10:132015亚冠之大阪钢巴
日期:2015-06-29 11:21:122015亚冠之广州恒大
日期:2015-05-22 21:55:412015年亚洲杯之伊朗
日期:2015-04-10 16:28:25
6 [报告]
发表于 2009-06-26 22:28 |只看该作者
原帖由 xinxinhao 于 2007-11-21 13:31 发表
我已经把oralce10和tuxedo9。1完全配置好料,,一切都好了,系统是suse linux 10.1 x86 32bit

oracle和tuxedo都能正常启动运行。。。但是在写测试的程序的时候,在server端 的程序里调用exec sql delete fro ...

在tpsvrinit()中打开数据库!

论坛徽章:
0
7 [报告]
发表于 2009-06-27 05:44 |只看该作者
原帖由 yulihua49 于 2009-6-26 22:28 发表

在tpsvrinit()中打开数据库!

--------------------------------------
怎么"在tpsvrinit()中打开数据库!"?
我是这么做的:
tpsvrinit(int argc,char *argv[])
{

      EXEC SQL BEGIN DECLARE SECTION;
                char  *uid="pw/pw@wilson";
                float salary;
        EXEC SQL END DECLARE SECTION;   
        EXEC SQL CONNECT :uid;

        if(tpopen()==-1){
                printf("error to connect to oracle!\n");
        }
        printf("the oracleserv successfully to connect to db2 in linux!\n");
        return 0;
}
这样可以吗?

[ 本帖最后由 simhare 于 2009-6-27 05:46 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2009-06-27 05:48 |只看该作者

回复 #1 xinxinhao 的帖子

谁知道
=======
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;
}
=======
这里需不需要打开数据库连接?怎么打开?

论坛徽章:
0
9 [报告]
发表于 2009-06-27 05:49 |只看该作者

回复 #1 xinxinhao 的帖子

---------------
这个板块人好少啊!?
有没有早起的,早期做过Tuxedo的朋友们?

论坛徽章:
0
10 [报告]
发表于 2009-06-27 05:53 |只看该作者

回复 #1 xinxinhao 的帖子

这一节,我想做的是返回一个字符串(有兄弟说C里面应该只有字符数组)给调用我的这里的ORACLE这个Service的程序,应该怎么做
==============
服务器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;
}

==============
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP