Re: variable used for "CREATE TABLE"
Posted in 1997
Use:
CREATE TEMP TABLE ...
and the same temporary table name for everybody. Temporary
tables are private to a process, so everybody could be running
the same report on each of three different screens, and each
instance would have a different temp table. You can create
indexes on temporary tables too. You can't create named
constraints either, but that usually isn't a problem. When
you've finished, you can drop the temp table, so the same program
can re-run the report.
Another option may be to let the report do the work for you. If
it is a two-pass report (typically because you say ORDER
{INTERNAL} BY rather than ORDER EXTERNAL BY), then I4GL will
create and fill a table with data, and then sort it, etc. In
fact, it doesn't index the table because the table is used just
once, and writing the sorted information back to disk for an
index is wasteful by comparison with simply doing the SELECT with
an appropriate ORDER BY clause.
Also note that the more recent versions of I4GL do not have an
arbitrary limit of 8 columns in the report's ORDER BY clause, any
more than the engines do.
If you insist on using unique table names per program, then
you'll have to PREPARE and EXECUTE the statements which
manipulate the table.
Yours,
Jonathan Leffler (johnl@informix.com) #include <witticism.h>
>Date: Mon, 28 Jul 1997 16:14:09 -0400
>From: ggodin@wbn.ca (Gerard Godin)
>X-Informix-List-Id: <list.15659>
>
>I am modifying a 4GL application that prints a report.
>To print this report, the application creates a table (Not a TEMP table)
>and it's index. This table is then used to hold data to be processed for
>this report. When the program ends, the table is destroyed.
>
>My problem is that I want the program to be useable by more than one person
>at a time. I would like to be able to check if the table exists already
>because user1 is running the application.. If it's running, then I would
>use another table name for user2, user3, and so on.
>
>I should be able to use a variable instead of hard-coding the table name in
>the create statement.
>
>example: LET table_name = "my_table"
> LET index_variable = "i_my_table"
> CREATE TABLE table_name
> ...
> CREATE UNIQUE INDEX index_variable ON table_variable
> ...