问题
This is a Teradata v14 specific question.
How to store the result of a query within a stored procedure for further processing.
Options I have looked at:
- volatile temporary table - but that needs to be created prior to stored procedure
- derived table - but it only holds the result for the duration of one query
The result needs to be available for the duration of the stored procedure.
Are there any other options?
Update 16 June 2014: Based on the answers and comments it seems that volatile table is the best answer. However then we try to use volatile table the stored procedure complains that the table doesn't exist. Is there a way around this?
回答1:
Have you considered a global temporary table?
The table definition is stored in the DBC data dictionary and instantiated for the duration of the session when referenced by SQL. Like a volatile table the global temporary table is session specific. Unlike a volatile table, a global temporary table relies on the user's temporary space instead of spool space.
来源:https://stackoverflow.com/questions/24185966/store-the-result-of-a-select-statement-within-a-stored-procedure