Home » Developer & Programmer » Precompilers, OCI & OCCI » How to use "OCITypeByName"
How to use "OCITypeByName" [message #116471] Wed, 20 April 2005 04:59 Go to next message
wxuf
Messages: 9
Registered: April 2005
Junior Member
First What I want to do is access data(such as print in the terminal) row by row with an iterator.

The following is my code:
...................
typedef struct stu
{
int id ;
char name[255] ;
int age ;
char time[255] ;
}stu;
...................

ora_init() // connect to db ;
ora_prepare("select * from stu") // parepare a SQL statement ;

lRet = OCIDefineByPos(hStmt, &hDefine,
hError, 1, (dvoid *) 0, 0,
SQLT_NTY, (dvoid *) 0, (ub2 *) 0,
(ub2 *) 0, OCI_DEFAULT) ;

lRet = OCITypeByName( hEnvironment,hError, hService,
(text *)0 ,
(ub4)0,
(text *) "STU",
(ub4) strlen((char *)"STU"),
(CONST text *) 0,(ub4) 0,
OCI_DURATION_SESSION,
OCI_TYPEGET_ALL, &DateType ) ;
here I get the return value -1 always, and the
error msg : Error - OCI-22303: type ""."STU" not found


................

So what is the reason ? How can I slove it ?
Thank you very much !

wxuf
Re: How to use "OCITypeByName" [message #116476 is a reply to message #116471] Wed, 20 April 2005 05:32 Go to previous messageGo to next message
wxuf
Messages: 9
Registered: April 2005
Junior Member
Got a little confused. How to access the data row by row ?
Where should we save the data(output) from db ?

It seems we have to define a handle to a specific data.

Who can explain this to me?

wxuf
Re: How to use "OCITypeByName" [message #117085 is a reply to message #116476] Sun, 24 April 2005 16:54 Go to previous message
Michael Hartley
Messages: 110
Registered: December 2004
Location: West Yorkshire, United Ki...
Senior Member

Hi,

Seems you've already realised enough on your own to be able to follow the documentation.

However, after the OCIexecute operation has completed a set of intrinsically allocated define handles will be availabe as parameters of the OCIstatement handle.

See the examples provided by the Oracle client in $ORACLE_HOME/oci/sammples or $ORACLE_HOME/demo (i think).

Kind regards,
Michael Hartley, http://www.openfieldsolutions.co.uk
Previous Topic: How to execute the "select * from tablename" ;
Next Topic: how to get MAX(value)?/
Goto Forum:
  


Current Time: Mon Aug 10 15:29:18 CDT 2020