Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!uccba!mead!gordon From: gordon@mead.UUCP (Gordon Edwards) Newsgroups: comp.databases Subject: Ingres ESQL question. Message-ID: <1269@meaddata.mead.UUCP> Date: 4 Sep 90 20:26:07 GMT Sender: usenet@mead.UUCP Reply-To: mead!gordon@uccba.uc.edu Distribution: comp Organization: Mead Data Central, Dayton OH Lines: 65 According to the ESQL documentation the statement_name in PREPARE can be a string constant or a host string variable. This works: char dsql[100]; strcpy(dsql, "select a, b from y"); EXEC SQL PREPARE s FROM :dsql; This does not: char dsql[100]; char *s; strcpy(dsql, "select a, b from y"); EXEC SQL PREPARE :s FROM :dsql; I did a similar thing for declaring cursors as host string variables (see the test program below) which worked. There are no examples of statement_ name as a host string variable. Has anyone ever used this construct? Would an Ingres person like to comment? Below is the entire test program: EXEC SQL INCLUDE sqlca; main() { EXEC SQL BEGIN DECLARE SECTION; int a_val, b_val; char *c, *s; char dsql[100]; EXEC SQL END DECLARE SECTION; EXEC SQL CONNECT 'iilibdb'; strcpy(dsql, "select a, b from y"); EXEC SQL PREPARE :s FROM :dsql; ^^ works if just ... PREAPRE s FROM ... EXEC SQL DECLARE :c CURSOR FOR :s; ^^ works if just ... FOR s; EXEC SQL OPEN :c; do { EXEC SQL FETCH :c INTO :a_val, :b_val; printf("\ta = %d\tb = %d\n", a_val, b_val); } while (sqlca.sqlcode == 0); EXEC SQL CLOSE :c; EXEC SQL DISCONNECT; } Thanks. -- Gordon Edwards Mead Data Central, Dayton OH