ESQL/C - compile error
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Security, Permissions & Auditing
Dear Lady, Dear Sir,
I try to compile the code below and get a compile error (see also
below).
Is
$connect ...
a feature that has been introduced to informix esql/c after
Informix ESQL/C 5.02 uc1 ??
If so, in what version it became part of Informix ESQL/C?
/*
Run the program
bugblob database user password create
OR IF THE TABLE Z ALREADY EXISTS THEN JUST
bugblob database user password
create table z (z text, z1 serial);
begin work
insert into z values(?, 0) "1234"
commit work
UPDATE Z from file (which does not exist) USING CURSOR
causes segmentation violation and brings down the server
*/
main(int argc, char **argv) {
$loc_t iloc, sloc, uloc;
$char *db, *uid, *pw, *cmd;
$int found;
if (argc < 4) {
printf("Usage: bugblob database user password
[create]\\n");
exit(1);
}
db = argv[1];
uid = argv[2];
if (*uid == '\\0') uid = (char *)0L;
pw = argv[3];
if (*pw == '\\0') pw = (char *)0L;
cmd = argv[4];
$connect to $db user $uid using $pw;
chk_status("CONNECT", db);
if (cmd) {
$execute immediate "create table z (z text, z1 serial)";
chk_status("EXECUTE IMMEDIATE", "CREATE TABLE");
iloc.loc_loctype = LOCMEMORY;
iloc.loc_buffer = "TEST 123";
iloc.loc_bufsize = strlen(iloc.loc_buffer) + 1;
$insert into z values($iloc, 0);
chk_status("INSERT INTO", "Z");
}
uloc.loc_loctype = LOCFNAME;
uloc.loc_fname = "/NOSUCHDIR/NOSUCHFILE/FORTEST";
uloc.loc_oflags = LOC_RONLY;
uloc.loc_size = -1;
$begin work;
chk_status("BEGIN", "WORK");
$declare cur cursor for select 1 from z where 1 = 1 for update
of z;
chk_status("DECLARE CURSOR", "UPDATE Z");
$open cur;
chk_status("OPEN CURSOR", "UPDATE Z");
$fetch cur into $found;
chk_status("FETCH CURSOR", "UPDATE Z");
$update z set z = $uloc where current of cur;
chk_status("UPDATE CURRENT OF CURSOR", "Z");
/* If program reaches this, then things look good !
Ignore rollback and disconnect of database for this test !
*/
printf("LOOKS GOOD!\\n");
exit(0);
}
int chk_status(char *p1, char *p2) {
if (sqlca.sqlcode < 0) {
printf("SQL ERROR %d WHILE %s %s\\n", sqlca.sqlcode, p1,
p2);
exit(1);
}
}
gmake bugblob.ec
gmake: Nothing to be done for `bugblob.ec'.
ws5512% gmake bugblob.o
/usr/informix/bin/esql -KPIC -c -Xa -v -I. -I/usr/local/include
-I/usr/informix/incl/esql bugblob.ec
esqlc: "bugblob.ec", line 45: Error -33200: Invalid statement on symbol
'connect'.
esqlc: "bugblob.ec", line 45: Error -33051: Syntax error on identifier
or symbol '$'.
2 error(s) found
gmake: *** [bugblob.o] Error 1
--
#-------With best regards, Mit freundlichen Gruessen, Met vriendelijke groet, ------
# Piet Vloet
# Siemens AG Austria
# Boschstrasse 10 Phone : +43-51707-42906
# A-1190 Vienna Fax : +43-51707-52606
# mailto:petrus.vloet@siemens.at WWW:http://www.siemens.at