Need help creating a Stored Procedure for creating tables.

General
Highlighted
Teradata Employee

Need help creating a Stored Procedure for creating tables.

Greetings,

 

I am fairly new with SP development in TD and I need help or at least a point in the right direction on how to create a stored procedure, which will loop through a SQL query say "select requesttext  from DB.TEMPTABLEDDLLIST" and from that list of table DDLs execute and create the tables within that loop. From what I know the way to achieve this is through a cursor and loop through the results, but if there is a better way to do it I am ok also with this approach. Appreciate the help.

 

regards,

 

Karl

 

Tags (1)
1 REPLY
Senior Supporter

Re: Need help creating a Stored Procedure for creating tables.

Check the dynamic SQL option in stored proceedures - you need a specific exec right for this.

 

http://stackoverflow.com/questions/13895370/how-to-execute-dynamic-sql-in-teradata

and

https://community.teradata.com/t5/Database/DDL-Statement-Dynamic-SQL-in-a-FOR-cursor-LOOP-SQLCODE-37...

might give you some hints...

Ulrich