Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 28 Jan 2002 @ 20:25:06 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Using a variable for a table name in Stored Procedure
 
From:   Shirish Mallavolu

Hi Girija,

No you can't do it. To create the query dynamically, there is a constraint in teradata. You, cannot use Select statement.

You can do something like this,

CREATE PROCEDURE sample_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;

The following SQL statements cannot be used as dynamic SQL in stored procedures:

- CALL
- CREATE PROCEDURE
- DATABASE
- EXPLAIN
- HELP
- REPLACE PROCEDURE
- SELECT
- SELECT - INTO
- SET SESSION ACCOUNT
- SET SESSION COLLATION
- SET SESSION DATEFORM
- SET TIME ZONE
- SHOW

Hope this helps you.


Thanks,

Shirish Mallavolu
Saama Technologies



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016