Home » Developer & Programmer » Precompilers, OCI & OCCI » OCI Error while Executing
OCI Error while Executing [message #110885] |
Thu, 10 March 2005 16:58 |
SriniIyer
Messages: 1 Registered: March 2005
|
Junior Member |
|
|
Hi All,
I'm pretty new to OCI programming. I have been getting the following error, and a core is dumped, when I run the program:
ERROR: ORA-24374: define not done before fetch or execute and fetch
Below is the code, where I'm describing and defining. I haven't used any fetch statement in the code.
/* Struct used for describing and defining the columns */
struct ColDescr
{
ub2 m_Datatype ;
text* m_ColName ;
ub4 m_ColNmLength ;
ub1 m_Data[128] ;
sb4 m_DataSize ;
} SelCols[30] ;
...
int main ()
{
... /* Declaration */
/* Initialization and connect */
m_Query = (text *) "SELECT * FROM TBL_BUSINESS" ;
if ( OCIStmtPrepare ( p_sql, p_err, m_Query,
(ub4) strlen (m_Query),
OCI_NTV_SYNTAX, OCI_DEFAULT ) )
{
HandleError ( p_err ) ;
ExitClean () ;
}
fprintf ( stderr, "Statement Prepared!\n " ) ;
if ( OCIStmtExecute ( p_svc, p_sql, p_err, (ub4) 1,
(ub4) 0, (OCISnapshot *) NULL,
(OCISnapshot *) NULL, OCI_DEFAULT ) )
{
HandleError ( p_err ) ;
//ExitClean () ;
}
fprintf ( stderr, "Statement Executed successfully!\n" ) ;
do
{
//static int Pos = 1 ;
if ( OCIParamGet ( p_sql, OCI_HTYPE_STMT, p_err,
(dvoid *) &p_Param, (ub4) Pos )
!= OCI_SUCCESS )
{
HandleError ( p_err ) ;
break ;
}
OCIAttrGet ( (dvoid *) p_Param, OCI_DTYPE_PARAM,
(dvoid *) &SelCols[Pos - 1].m_Datatype,
(ub4 *) 0, (ub4) OCI_ATTR_DATA_TYPE, p_err ) ;
OCIAttrGet ( (dvoid *) p_Param, OCI_DTYPE_PARAM,
(dvoid **) &SelCols[Pos - 1].m_ColName,
(ub4 *) &SelCols[Pos -1].m_ColNmLength,
OCI_ATTR_NAME, p_err ) ;
OCIAttrGet ( (dvoid *) p_Param, OCI_DTYPE_PARAM,
(dvoid *) &SelCols[Pos - 1].m_DataSize,
(ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, p_err ) ;
OCIDefineByPos ( p_sql, &p_dfn, p_err, (ub4) Pos,
(ub1 *) SelCols[Pos -1].m_Data,
( SelCols[Pos -1].m_DataSize + 1 ),
SelCols[Pos - 1].m_Datatype,
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0,
OCI_DEFAULT ) ;
fprintf ( stderr, "Column: %s(%d) => %d \n",
SelCols[Pos - 1].m_ColName,
SelCols[Pos - 1].m_DataSize,
SelCols[Pos - 1].m_Datatype ) ;
Pos ++ ;
}while ( 1 ) ;
/* No Fetch Statement - in rest of the code */
... /* Code to logoff and free handles */
}
However, the above code works fine if Statement is executed as OCI_DESCRIBE_ONLY (I commented the OCIDefineByPos). I'm able to get the column info from the query.
Is it necessary that a fetch be called?
Thanks in advance.
Regards,
Srini
|
|
|
Goto Forum:
Current Time: Tue Dec 17 22:48:46 CST 2024
|