Following this question is a watered down version of the program that I am trying to write. I get an invalid sql statement error during the parse portion, the statement is valid, is there some other bit of voodoo, that I do not know that is causing this. If anyone can shed some light, I will be very grateful. tks .... here it is. It works when I use the commented out version of the statement ( insert into.... ) but craps out when I use the other ( exec IMPLOAD... )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <oratypes.h>
#include <ocidfn.h>
#ifdef __STDC__
#include <ociapr.h>
#else
#include <ocikpr.h>
#endif
#include <ocidem.h>
/* Define an LDA, a HDA, and a cursor. */
Lda_Def lda;
ub4 hda[HDA_SIZE/sizeof(ub4)];
Cda_Def cda1;
text *szUID = "UPLOAD" ;
text *szPWD = "UPLOAD" ;
text *szSID = "REARDON" ;
text *szConString = "UPLOAD/UPLOAD@REARDON" ;
text *szQuery = (text *) "exec IMPLOAD( 'Col Number One', 2, 3, 'four')" ;
//text *szQuery = (text *) "INSERT INTO IMPTEST VALUES ( 'Col Number One', 2, 3, 'four')" ;
void err_report(cursor)
Cda_Def *cursor;
{
sword n;
text msg[512];
printf("\n-- ORACLE error--\n"
printf("\n"
n = oerhms(&lda, cursor->rc, msg, (sword) sizeof msg);
fprintf(stderr, "%s\n", msg);
if (cursor->fc > 0)
fprintf(stderr, "Processing OCI function %s\n\n",
oci_func_tab[cursor->fc]);
}
/*
* Exit program with an exit code.
*/
void do_exit(exit_code)
sword exit_code;
{
sword error = 0;
if (oclose(&cda1))
{
fprintf(stderr, "Error closing cursor 1.\n"
error++;
}
if (ologof(&lda))
{
fprintf(stderr, "Error on disconnect.\n"
error++;
}
if (error == 0 && exit_code == EXIT_SUCCESS)
printf ("\nG'day\n"
exit(exit_code);
}
void myfflush()
{
eb1 buf[50];
fgets((char *) buf, 50, stdin);
}
int main( int argc, char * argv[] )
{
/* Connect to the DB server */
printf("Conecting...\n\n"
if (olog(&lda, (ub1 *)hda, szConString, -1, szPWD, -1,
(text *) 0, -1, (ub4)OCI_LM_DEF))
{
err_report(&lda);
exit(EXIT_FAILURE);
}
printf("Connected to ORACLE as %s\n\n", szConString);
/* Open a cursor */
if (oopen(&cda1, &lda, (text *) 0, -1, -1, (text *) 0, -1))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Cursor is open\n\n"
/* Parse the procedure exec statement */
if( oparse(&cda1, szQuery, -1, 0, 2 ) )
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Query parsed\n\n"
/* Execute the statement */
if (oexec(&cda1) && cda1.rc != 1)
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Query executed\n\n"
/* Close the cursor */
if (oclose(&cda1))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Cursor closed\n\n"
/* Close the db connection */
if (ologof(&lda))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Connection closed\n\n"
return 0 ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <oratypes.h>
#include <ocidfn.h>
#ifdef __STDC__
#include <ociapr.h>
#else
#include <ocikpr.h>
#endif
#include <ocidem.h>
/* Define an LDA, a HDA, and a cursor. */
Lda_Def lda;
ub4 hda[HDA_SIZE/sizeof(ub4)];
Cda_Def cda1;
text *szUID = "UPLOAD" ;
text *szPWD = "UPLOAD" ;
text *szSID = "REARDON" ;
text *szConString = "UPLOAD/UPLOAD@REARDON" ;
text *szQuery = (text *) "exec IMPLOAD( 'Col Number One', 2, 3, 'four')" ;
//text *szQuery = (text *) "INSERT INTO IMPTEST VALUES ( 'Col Number One', 2, 3, 'four')" ;
void err_report(cursor)
Cda_Def *cursor;
{
sword n;
text msg[512];
printf("\n-- ORACLE error--\n"
printf("\n"
n = oerhms(&lda, cursor->rc, msg, (sword) sizeof msg);
fprintf(stderr, "%s\n", msg);
if (cursor->fc > 0)
fprintf(stderr, "Processing OCI function %s\n\n",
oci_func_tab[cursor->fc]);
}
/*
* Exit program with an exit code.
*/
void do_exit(exit_code)
sword exit_code;
{
sword error = 0;
if (oclose(&cda1))
{
fprintf(stderr, "Error closing cursor 1.\n"
error++;
}
if (ologof(&lda))
{
fprintf(stderr, "Error on disconnect.\n"
error++;
}
if (error == 0 && exit_code == EXIT_SUCCESS)
printf ("\nG'day\n"
exit(exit_code);
}
void myfflush()
{
eb1 buf[50];
fgets((char *) buf, 50, stdin);
}
int main( int argc, char * argv[] )
{
/* Connect to the DB server */
printf("Conecting...\n\n"
if (olog(&lda, (ub1 *)hda, szConString, -1, szPWD, -1,
(text *) 0, -1, (ub4)OCI_LM_DEF))
{
err_report(&lda);
exit(EXIT_FAILURE);
}
printf("Connected to ORACLE as %s\n\n", szConString);
/* Open a cursor */
if (oopen(&cda1, &lda, (text *) 0, -1, -1, (text *) 0, -1))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Cursor is open\n\n"
/* Parse the procedure exec statement */
if( oparse(&cda1, szQuery, -1, 0, 2 ) )
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Query parsed\n\n"
/* Execute the statement */
if (oexec(&cda1) && cda1.rc != 1)
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Query executed\n\n"
/* Close the cursor */
if (oclose(&cda1))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Cursor closed\n\n"
/* Close the db connection */
if (ologof(&lda))
{
err_report(&cda1);
do_exit(EXIT_FAILURE);
}
printf("Connection closed\n\n"
return 0 ;
}