Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: problem about date type in OCI program

    how can I deal with a date type data in OCI program.

    I try to use c data type char[7] to get the data.i can get some data but can't use them and insert them into other tables.

    for example

    OCIEnv *envhp;
    OCIError *errhp;
    OCISvcCtx *svchp;
    OCIStmt *stmthp;
    OCIParam *colhp;
    OCIDefine *defhp;
    OCIBind *bndhp[2];
    sb2 ind;
    char rcvdate[7];
    int i;

    /*i can do this*/

    sprintf(sqltext,"SELECT sourcenum,targetnum,content,receivetime,gateway FROM receivedsm WHERE id=%d",rcvid);

    checkerr(errhp,OCIStmtPrepare(stmthp,errhp,sqltext ,(ub4)strlen((char *)sqltext),OCI_NTV_SYNTAX,OCI_DEFAULT));
    checkerr(errhp,OCIDefineByPos(stmthp,&defhp,errhp, 4,rcvdate,8,SQLT_DAT,&ind,(dvoid *)0,(ub2 *)0,OCI_DEFAULT));
    checkerr(errhp,OCIStmtExecute(svchp,stmthp,errhp,0 ,0,NULL,NULL,OCI_DEFAULT));
    checkerr(errhp,OCIStmtFetch(stmthp,errhp,1,OCI_FET CH_NEXT,OCI_DEFAULT));

    /*but i can't do this*/

    sprintf(sqltext,"insert into receivedsm(id,rcvdate) values(:id,:rcvdate)");
    i=222;
    checkerr(errhp,OCIStmtPrepare(stmthp,errhp,sqltext ,strlen(sqltext),OCI_NTV_SYNTAX,OCI_DEFAULT));
    checkerr(errhp,OCIBindByName(stmthp,&bndhp[0],errhp,":id",-1,&i,sizeof(i),SQLT_INT,0,0,0,0,0,OCI_DEFAULT));
    checkerr(errhp,OCIBindByName(stmthp,&bndhp[1],errhp,":rcvdate",-1,rcvdate,strlen(rcvdate)+1,SQLT_DAT,0,0,0,0,0,OCI _DEFAULT));
    checkerr(errhp,OCIStmtExecute(svchp,stmthp,errhp,1 ,0,NULL,NULL,OCI_DEFAULT));


    who can help me?thanks.........

  2. #2
    Join Date
    Mar 2004
    Posts
    2

    and

    and when i

    printf("rcvdate=%s",rcvdate);

    i can just see something like 'rcvdate=xhB'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •