Archives of the TeradataForum
Message Posted: Fri, 25 Oct 2002 @ 22:46:13 GMT
Subj: | | Re: Variables as Table Name(s) in Stored Procedure |
|
From: | | Jason Fortenberry |
I had this same question a while back and received the following answer which worked for me and so I now forward on....
You could attempt something similar to the example quoted in "Teradata RDBMS SQL Reference Volume-6" on Dynamic SQL statements within a
stored procedure
CREATE PROCEDURE new_sales_table(my_table VARCHAR(30), my_database VARCHAR(30))
BEGIN
DECLARE sales_columns VARCHAR(128)
DEFAULT '(item INTEGER, price DECIMAL(8,2), sold
INTEGER)';
CALL DBC.SysExecSQL('CREATE TABLE ' || :my_database || '.' || :my_table || :sales_columns);
END;
|