Store the result of a select statement within a stored procedure

一世执手 提交于 2019-12-13 03:34:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!