Re: c precompiler
Date: 1997/03/07
Message-ID: <5fp4dc$o5r_at_camelot.dsccc.com>#1/1
Try adding
if (sqlca.sqlcode < 0) { fprintf (stderr, "%s, %s\n", sqlstm.stmt, sqlca.sqlerrm.sqlerrmc) ; sql_error ; }
after each EXEC SQL statement then post the question with the results. and add
EXEC SQL INCLUDE SQLCA ;
after your
EXEC SQL END DECLARE SECTION ;
ps:
it might be
fprintf (stderr, "%s, %s\n", (char *)sqlstm.stmt, (char*)sqlca.sqlerrm.sqlerrmc) ;
if your compiler complains;
Fuzhen Yang (fyang1_at_tiger.towson.edu) wrote:
: Hi, I got a serious problem with the following program which is used to
: create a table (DEPT_LOCATION) and insert two lines of values. I compiled the
: program using oracle C Precompiler and run it successfully. But when I went to
: my oracle system, I used statement "select Table_Name from USER_TABLES", the
: table I created using Pre C program didn't show up, which means the table
: "DEPT_LOCATION" was not created. I don't know does the table created using pre
: C program only exists during runtime of the program or should exist forever?
: I need idea for that.
: Good luck to everybody!!!
: fyang1_at_tiger.towson.eud
: #include <stdio.h>
: char *username = "fyang1";
: char *password = "fuzhen";
: char dlocation[15];
: int dnumber;
: void sql_error();
: #include <sqlca.h>
: main()
: {
: EXEC SQL WHENEVER SQLERROR do sql_error("oracle error");
: EXEC SQL CONNECT:username IDENTIFIED BY:password;
: printf("Connected.\n");
: EXEC SQL CREATE TABLE DEPT_LOCATION(DNUM int,
: DLOC varchar(15));
: EXEC SQL COMMIT;
: EXEC SQL INSERT INTO DEPT_LOCATION VALUES(1, "Baltimore");
: EXEC SQL INSERT INTO DEPT_LOCATION VALUES(2, "Houston");
: EXEC SQL COMMIT;
: EXEC SQL COMMIT WORK RELEASE;
: exit(0);
: }
: void sql_error(msg)
: char *msg;
: {
: char buf[500];
: int buflen, msglen;
: EXEC SQL WHENEVER SQLERROR CONTINUE;
: EXEC SQL ROLLBACK WORK RELEASE;
: buflen = sizeof (buf);
: sqlglm(buf, &buflen, &msglen);
: printf("%s\n", msg);
: printf("%*.s\n", msglen, buf);
: exit(1);
: }
:
-- This posting represents the personal opinions of the author. It is not the official opinion or policy of the author's employer. Warranty expired when you opened this article and I will not be responsible for its contents or use.Received on Fri Mar 07 1997 - 00:00:00 CET