Re: embedded sql in C
Posted in 1998
Bill Turner wrote: > > i am writing programs (i am new to unix/c) using embedded sql in c > precompiling with the informix esql compiler. our tables are appended > with a company id. for example table master for company 101 would be > master101. i would like to be able to make the table name used in my > queries to be dynamic so that i can choose which company i want to work > with. is there any way to do this? i expected to use a shell variable > for the company name and append that to the table name, but the compiler > does not seem to like host variables for table names (even though the > informix documentation seemed to indicate that you could!). > > your help is greatly appreciated! > > bill You need to use the PREPARE and DECLARE statements. Directly embedding the SQl statements in the C won't work. The manuals explain this quite clearly, although it can get complicated. Anyway, if you are reusing the statements it's a good idea to PREPARE for efficiency. -- Peter Lancashire Information Systems Specialist, Bayer plc Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK Tel: +44-1635-562258, Fax: +44-1635-562281 Mail: Peter.Lancashire.PL1@bayer.co.uk --- My Internet plumbing does not allow me to mail and post news together. Sorry. All opinions are my own and not those of Bayer plc. --- Join Infuse, the UK Informix User Group at http://www.infuse.co.uk/