Re: some esql syntax questions
Posted in 1996
}From: byteshif@cs.tu-berlin.de (Michael Agbaglo) }Date: 03 Jan 1996 18:13:05 GMT }X-Informix-List-Id: <news.20016> } }1 .) Why do I get }esqlc: file "dbactions.ec", line 31: Syntax error on keyword or symbol ':'.(sqlnhost.y) } }when using the following expression ? } }EXEC SQL BEGIN DECLARE SECTION; } }char tab1[30]; } }EXEC SQL END DECLARE SECTION; }[...] } } EXEC SQL LOCK TABLE :tab1 IN EXCLUSIVE MODE; You can't use variables for table names. In this case, you would prepare, execute and free a statement formatted with sprintf(). Or use EXECUTE IMMEDIATE. }2.) What's wrong with the connect ? } EXEC SQL CONNECT TO DEFAULT; } }esqlc: file "dbactions.ec", line 25: Syntax error on keyword or symbol 'connect'. (sqlhost.y) You are using an obsolete version of ESQL/C, almost certainly. What does esql -V say. If it is earlier than 6.00, then CONNECT will not be understood. I think you may be using a very early version, }3.) How can I do a COUNT(*) in esql/c ? } EXEC SQL SELECT COUNT(*) FROM :tab1 INTO :n; }fails... Same as answer 1 -- you can't use variables for table names. In this case, you would prepare, declare, open, fetch, close and free a statement formatted with sprintf() and a cursor. }4.) Can you recommend a good book on esql/c ? The 7.x ESQL/C Manual is pretty good. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>