Re: Variables in SP
Posted in 1997
Daniel Cernotto wrote:
>
> =20
> What I need to know is the way in which I can use a table variable name
> within the sentence "CREATE TABLE" in a Stored Procedure?
>
> Example:
>
> CREATE PROCEDURE new_tabla()>
> CREATE TABLE tabla_name_var
> (field_1 char(1),
> field_2 char(2))>
> END PROCEDURE
Daniel,
the procedure code above, when executed, will create a table named
tabla_name_var. Currently it is not possible to specify table or column
names through a variable in SPL. (I doubt if it ever will but I keep
hoping.) You are trying to PREPARE a "create table" statement and SPL
simply has no syntax for this.
However, you CAN have the procedure run a shell program using the
"system" syntax. You piece together the Unix command - in this case, to
run a shell script you already written - and that shell script can use
the command line parameters to run dbaccess and create the table named
as you desire.
One warning - if your intention was to create a temp table, that temp
table will be known only to the dbaccess that script runs; as soon as
that dbaccess session is over, the temp table vanishes. So this
workaround can be used only to create a regular table. This is not so
bad - after you are done, you can always drop it anyway.
I hope this helps.
--
-- Jake Salomon
-. .-
_..-'( )`-.._
./'. '||\\\\. (\\_/) .//||` .`\\.
./'.|'.'||||\\\\|.. )o o( ..|//||||`.`|.`\\.
./'..|'.|| |||||\\`````` '`"'` ''''''/||||| ||.`|..`\\.
./'.||'.|||| ||||||||||||. .|||||||||||| ||||.`||.`\\.
/'|||'.|||||| ||||||||||||{ }|||||||||||| ||||||.`|||`\\
'.|||'.||||||| ||||||||||||{ }|||||||||||| |||||||.`|||.`
'.||| ||||||||| |/' ``\\||`` ''||/'' `\\| ||||||||| |||.`
|/' \\./' `\\./ \\!|\\ /|!/ \\./' `\\./ `\\|
V V V }' `\\ /' `{ V V V
` ` ` V ' ' '
+-----------------------------------------------------------+
| Diplomacy: The art of getting something off your |
| chest without losing your shirt |
+------------------------Alfred E. Neuman-------------------+