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!). You cannot use a host variable for the table name. However, what you can do is use sprintf() to build the query as a string (using a %s to represent the table and make the variable containing the table name an argument to sprintf). Then you can PREPARE the string to a statement ID and EXECUTE or DECLARE a CURSOR for the statement ID. Art S. Kagel