demo1.ec (ESQL/C)
Posted in 2000
Hi All,
I can't run properly the demo1.ec (an ESQL/C example program)
Our environment is composed of an application server and a database
server. Both run HP-UX.
I want to run ESQL/C programs on my Linux that will query the database
server. Compilation is fine, but when I start the program, the "WHENEVER
SQLERROR STOP" throws exception 404 (statement names a cursor that has
been released with the FREE statement"), which I believe is not true.
I was wondering that maybe the database server configuration forbids
communication with any other machine except the application server, or
that maybe it listens on a different port than that mentioned in
/etc/services (port 1525, service name execsql). How can I check this?
Below is the source I'm using. It does not get past "1.step".
-------------------------cut----------------
#include <stdio.h>
EXEC SQL define ID_LEN 1;
/* EXEC SQL define AMOUNT_LEN 40;*/
EXEC SQL define TEXT_LEN 20;
main()
{
EXEC SQL BEGIN DECLARE SECTION;
char id[ ID_LEN + 1 ];
int amount;
char text[ TEXT_LEN + 1 ];
EXEC SQL END DECLARE SECTION;
printf( "Testing program for ESQL-C.\\n\\n");
EXEC SQL WHENEVER SQLERROR STOP;
EXEC SQL connect to 'test';
printf( "1. step\\n");
EXEC SQL declare my cursor for
select id, text
into :id, :text
from primary;
printf( "2. step\\n");
EXEC SQL open my;
for (;;)
{
EXEC SQL fetch my;
if (strncmp(SQLSTATE, "00", 2) != 0)
break;
printf("%s %s\\n",id, text);
}
if (strncmp(SQLSTATE, "02", 2) != 0)
printf("SQLSTATE after fetch is %s\\n", SQLSTATE);
EXEC SQL close my;
EXEC SQL free my;
EXEC SQL disconnect current;
printf("\\nEnd of the test program.\\n\\n");
}
-------------------- cut -------------------------
--
Milos Prudek