Can I use variable substitution in create table sql ?
Posted in 2000
Topics: Storage & Space Management
Hi Listers, I need to create a table everytime in a specific dbspace. Our Application uses a batch process that drops and recreates the table every night using predefined create table sql's. Instead of hardcoding the in 'dbspacename' in each SQL file, can I use a variable such as in $DBSPACENAME in the SQL which is defined in the users' .profile. Actually, I tried this already but it did not work. Is there any way to accomplish this? Thanks in advance, Denmark W.
>>>>> " " == Denmark B Weatherburn <dweatherb@btl.net> writes:
> Hi Listers,
> I need to create a table everytime in a specific dbspace. Our
> Application uses a batch process that drops and recreates the
> table every night using predefined create table sql's. Instead
> of hardcoding the in 'dbspacename' in each SQL file, can I use
> a variable such as in $DBSPACENAME in the SQL which is defined
> in the users' .profile. Actually, I tried this already but it
> did not work. Is there any way to accomplish this?
Something like this should work for you:
#!/bin/sh
fi
#
DBACCESS="$INFORMIXDIR/bin/dbaccess -e $DB_NAME"
DBSPACENAME=dbspace1
#
$DBACCESS <<SQLSTMTS
CREATE TABLE grids
(
source CHAR(20) UNIQUE,
mxmn_grid BYTE IN TABLE,
[...]
) IN $DBSPACENAME;
CLOSE DATABASE;
SQLSTMTS
HTH,
Mark
--
"All our knowledge merely helps us to die a more painful death than
animals that know nothing."
-- Maurice Maeterlinck