Can I use a variable for a column or table name
Posted in 1999
Topics: Stored Procedures & SPL, Data Types & Schema Design
In informix 7.3 on UNIX i want to do the following in the Stored Procedure
Language:
create procedure test( colName varchar(18))
select colName from customers into temp temp1;
end procedure;
then run
execute procedure test(customer_name);
David Gress wrote:
> In informix 7.3 on UNIX i want to do the following in the
> Stored Procedure Language:
>
> create procedure test( colName varchar(18))>
> select colName from customers into temp temp1;>
> end procedure;
>
> then run
>
> execute procedure test(customer_name);
You're snookered three times.
3. The execute would presumably use a quoted string? This is the
least of the problems.
2. SPL does not allow dynamic SQL, and your statement would surely
change at runtime, making it dynamic.
1. Even if SPL allowed dynamic SQL, the underlying SQL language does
not allow either column names or table names to be specified as
host variables.
In ESQL/C, you'd have to prepare and execute (or execute immediate)
the statement, having formatted a string to contain it.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>