免费注册 查看新帖 |

Chinaunix

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

scounix7 下oci 连接数据库 olog 出错!!急急急!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-18 11:30 |只看该作者 |倒序浏览
运行环境:
oracle server:  hpux12 oracle 920
client :sco unixware 7.1  oracle 8.1.5



在调用OCI函数olog时出错,错误:

ORA-01009: missing mandatory parameter

多谢!

makefile
SHELL=/bin/sh
CC= cc
PC= proc

OUTPUT = $(HOME)/bin

CFLAGS= -I$(HOME)/include -I$(ORACLE_HOME)/precomp/public  

ORALIBS= -Ae -y -w -Wl,+s -DDEBUG \
        -I$(ORACLE_HOME)/rdbms/public \
        -I$(ORACLE_HOME)/precomp/public \
        -I$(ORACLE_HOME)/rdbms/demo \
        -I$(ORACLE_HOME)/plsql/public \
        -I$(ORACLE_HOME)/network/public \
        -L$(ORACLE_HOME)/lib
       
TFLAGS= \
        -lclntsh \
        -lthread \
        -lm

all: \
        oci22.o

.c.o:
        $(CC) $(ORALIBS) -c $<
        $(CC) $(ORALIBS) -o $(OUTPUT)/$* $*.o ${TFLAGS}
clean:
        rm -f *.o


程序-只测试链接数据库


#include <stdio.h>;
#include <stdlib.h>;
#include <ctype.h>;
#include <string.h>;

#include <oratypes.h>;
/* LDA and CDA struct declarations */
#include <ocidfn.h>;
#ifdef __STDC__
#include <ociapr.h>;
#else
#include <ocikpr.h>;
#endif
/* demo constants and structs */
#include <ocidem.h>;


/* oparse flags */
#define  DEFER_PARSE        1
#define  NATIVE             1
#define  VERSION_7          2

/* exit flags */
#define OCI_EXIT_FAILURE 1
#define OCI_EXIT_SUCCESS 0

#define BLOCKED -3123
#define SUCCESS 0

Lda_Def lda;                                                   /* login area */
ub4     hda[HDA_SIZE/sizeof(ub4)];                              /* host area */
Cda_Def cda;                                                  /* cursor area */

/* Function prototypes */
void logon ();
void logoff ();
void setup();
void err_report();
void do_exit();

/* SQL statement used in this program */


main(argc, argv)
eword argc;
text **argv;
{

  logon();                                       /* logon to Oracle database */

  setup();                                          /* prepare sql statement */

  logoff();                                        /* logoff Oracle database */

  do_exit(OCI_EXIT_SUCCESS);

}

/*
* Function: setup
*
* Description: This routine does the necessary setup to execute the SQL
*              statement. Specifically, it does the open, parse, bind and
*              define phases as needed.
*
*/
void setup()
{

  if (oopen(&cda, &lda, (text *) 0, -1, -1, (text *) 0, -1))         /* open */
  {
    err_report(&cda);
    do_exit(OCI_EXIT_FAILURE);
  }

  if (oparse(&cda, sqlstmt, (sb4) -1, DEFER_PARSE,                  /* parse */
               (ub4) VERSION_7))
  {
    err_report(&cda);
    do_exit(OCI_EXIT_FAILURE);
  }

  if (onbtst(&lda))
  {
    printf("connection is still blocking!!!\n";
    do_exit(OCI_EXIT_FAILURE);
  }

}



/*
* Function: err_report
*
* Description: This routine prints out the most recent OCI error
*
*/
void err_report(cursor)
Cda_Def *cursor;
{
    sword n;
    text msg[512];                      /* message buffer to hold error text */

    if (cursor->;fc >; 0)
      printf("\n-- ORACLE error when processing OCI function %s \n\n",
            oci_func_tab[cursor->;fc]);
    else
      printf("\n-- ORACLE error\n";

    n = (sword)oerhms(&lda, cursor->;rc, msg, (sword) sizeof msg);
    fprintf(stderr, "%s\n", msg);

}

/*
* Function: do_exit
*
* Description: This routine exits with a status
*
*/
void do_exit(status)
eword status;
{

  if (status == OCI_EXIT_FAILURE)
     printf("\n Exiting with FAILURE status %d\n", status);
  else
     printf("\n Exiting with SUCCESS status %d\n", status);
     
  exit(status);
}

/*
* Function: login
*
* Description: This routine logs on onto the database as OCITEST/OCITEST
*
*/
void logon()
{

  ub1 done = 0;
  static ub1 logprint = FALSE;            /* just print blocked logon once */
  char uid[256], passwd[256];

  strcpy(uid, "new97test@CF97";
  strcpy(passwd, "new97test";

  while (!done)
  {
     switch (olog(&lda, (ub1 *)hda, (text *)"OCITEST", -1,
                 (text *)"OCITEST", -1,
           (text *)"inst1_nonblock", -1, (ub4)OCI_LM_NBL))
     {

       case BLOCKED:/* will come through here multiple times, print msg once */
printf("block\n";
/*
            if (!logprint)
            printf("blocked - keep trying to log on\n";
            logprint = TRUE;
*/
            break;
       case SUCCESS:
            printf("logged on\n";
            done = 1;
            break;
       default:
printf("error\n";
            err_report((Cda_Def *)&lda);
            do_exit(OCI_EXIT_FAILURE);
     }

  }

  printf("\n Connected to ORACLE as ocitest\n";

}

/*
* Function: logoff
*
* Description: This routine closes out any cursors and logs off the database
*
*/
void logoff()
{

  if (oclose(&cda))                                          /* close cursor */
  {
    fprintf(stderr, "Error closing cursor 1.\n";
    do_exit(OCI_EXIT_FAILURE);
  }

  if (ologof(&lda))                                  /* log off the database */
  {
    fprintf(stderr, "Error on disconnect.\n");
    do_exit(OCI_EXIT_FAILURE);
  }

}

论坛徽章:
0
2 [报告]
发表于 2005-03-18 14:34 |只看该作者

scounix7 下oci 连接数据库 olog 出错!!急急急!!!

顶一下

论坛徽章:
0
3 [报告]
发表于 2005-03-18 15:52 |只看该作者

scounix7 下oci 连接数据库 olog 出错!!急急急!!!

各位老大赶快出手啊!
谢谢!!!!!

论坛徽章:
0
4 [报告]
发表于 2005-03-18 17:01 |只看该作者

scounix7 下oci 连接数据库 olog 出错!!急急急!!!

论坛徽章:
0
5 [报告]
发表于 2005-03-19 22:39 |只看该作者

scounix7 下oci 连接数据库 olog 出错!!急急急!!!

问题已经解决,是oracle 8.1.5的bug

换成oracle 8.1.7 就好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP