Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Doubt with WHERE clause on OCIStmtPrepare statement with OCI

Doubt with WHERE clause on OCIStmtPrepare statement with OCI

From: <albert.medela_at_gmail.com>
Date: 6 Nov 2006 02:07:49 -0800
Message-ID: <1162807669.685118.247550@h54g2000cwb.googlegroups.com>


Hello,
I'm trying to run under OCI for C/C++ something like:

>select offc_ipbase
>from nexqoffice, connection_type
>where offc_type = coty_type and offc_lastsincro > to_date('2006/11/3:00:00:00', '>yyyy/mm/dd:hh24:mi:ss')
>order by offc_id

where 'to_date...' is a variable. How Can I do this. I've been testing several (wrong) ways but all of them sends me an error. The code of my last test is:

>string sSQL = "select offc_ipbase from nexqoffice, connection_type where offc_type = >coty_type and offc_lastsincro >:dSQLDate order by offc_id";

>//Prepare statement
>checkerr(p_err, OCIStmtPrepare(sqlStatement,p_err,(unsigned char *)
>const_cast<const char *>(sSQL.c_str()),
>strlen(sSQL.c_str()),OCI_NTV_SYNTAX,OCI_DEFAULT));

>//Define Output Variables

>OCIDefine * defnp = (OCIDefine *) 0;
>short name_length=15;
>char name[15];
>checkerr(p_err, OCIDefineByPos(sqlStatement, &defnp, p_err, 1, (dvoid *) name,
>name_length+1, SQLT_STR, (dvoid *) 0, (ub2 *) 0, (ub2 *) 0,
>OCI_DEFAULT));

>// dSQLDate
>char dSQLDate[80]; //to_date('2006/11/3:00:00:00', 'yyyy/mm/dd:hh24:mi:ss')
>OCIBind *p_dSQLDate = NULL; // client and server Ips
>checkerr(p_err,OCIBindByPos(sqlStatement, &p_dSQLDate , p_err, 1, dSQLDate, 80,
>SQLT_CHR, 0, 0, 0, 0, 0, OCI_DEFAULT));
Then I make the execute statement. I guess the problem is in the dSQLDate variable, but I do not know which is it.

The error that OCI returns me is:ORA-01858: a non-numeric character was found where a numeric was expected.

Thank you very much. Received on Mon Nov 06 2006 - 04:07:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US