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

Home -> Community -> Usenet -> c.d.o.server -> oracle 10g pro*c error (ORA-24374 )

oracle 10g pro*c error (ORA-24374 )

From: guorke <guorke_at_gmail.com>
Date: 13 Apr 2007 05:39:02 -0700
Message-ID: <1176467942.055265.81450@n59g2000hsh.googlegroups.com>


Hi, all

    I meet a question in oracle 10g when do some pro*c code. ora-24374:define not done before fetch or execute and fetch...

here's my c++ code:
Recordset::select()
{
EXEC SQL BEGIN DECLARE SECTION;

	char szsqlstament[10240];
	char colname[50];
	char colvalue[1024];
	int      coltype;
	int      collength;
	int   numcols = 0;
	int   numrows = 0;

    int index_colcnt;
    char szusr[10];
	char szpwd[10];
	char szsid[10];
	EXEC SQL END DECLARE SECTION;
    strcpy(szusr,"xxx");
	strcpy(szpwd,"xxxx");
	strcpy(szsid,"xxx");
	strcpy(szsqlstament, psqlstr);

    pRecorder = new char **[pmaxrows];

	int aa;
	char abc[2000];
   EXEC SQL CONNECT :szusr identified by :szpwd using 	:szsid;
    strcpy(abc,sqlca.sqlerrm.sqlerrmc);
	aa=sqlca.sqlcode;
	printf("%s\n",abc);

    exec sql allocate descriptor 'big_desc' with max 1000; ;     exec sql prepare dynstmt from :szsqlstament;     exec sql declare c2 cursor for dynstmt;     exec sql open c2 using sql descriptor 'big_desc';     strcpy(abc,sqlca.sqlerrm.sqlerrmc);
		  aa=sqlca.sqlcode;
	printf("%s\n",abc);

    while (sqlca.sqlcode == 0)
    {

               exec sql fetch c2 into descriptor 'big_desc'; -----error here!

		  strcpy(abc,sqlca.sqlerrm.sqlerrmc);
		  aa=sqlca.sqlcode;
		 printf("%s\n",abc);
     	  if (sqlca.sqlcode == 0)
     	  {
     	      exec sql get descriptor 'big_desc' :numcols = count;
     	      pRecorder[numrows] = new char *[numcols];
              for (index_colcnt=1; index_colcnt<=numcols; index_colcnt+
+)
              {
     	          exec sql get descriptor 'big_desc'
value :index_colcnt :colname = name,
																	   :coltype = type,
 
	                                                               :collength
= length;
                  exec sql get descriptor 'big_desc'
value :index_colcnt :colvalue =
data;
		  pRecorder[numrows][index_colcnt - 1]=new char[collength];
		  if (!pRecorder[numrows][index_colcnt - 1]) cout << "new string
fail!" << endl;
		  strcpy(pRecorder[numrows][index_colcnt - 1], colvalue);
              }
              numrows++;
     	  }
    }
       cout <<"sqlcode=%d,sqlerrmc=

%s"<<sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc;

    rdcolumncount = numcols;
    rdrownumber = numrows;

    exec sql close c2;
    exec sql deallocate descriptor 'big_desc'; return 1;
}

and this is my tnsadmin.ora
abc =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ora-server)(PORT = 1521))     (CONNECT_DATA =

      (SERVER = DEDICATED)
      (SERVICE_NAME =abc)

    )
  )

 proc.exe dynamic=ansi lib.cpp code=cpp oname=lib.c Received on Fri Apr 13 2007 - 07:39:02 CDT

Original text of this message

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