将 select 语句的结果存储在存储过程中 [英] Store the result of a select statement within a stored procedure

查看:60
本文介绍了将 select 语句的结果存储在存储过程中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 Teradata v14 的特定问题.

This is a Teradata v14 specific question.

如何将查询结果存储在存储过程中以供进一步处理.

How to store the result of a query within a stored procedure for further processing.

我看过的选项:

  • volatile 临时表 - 但需要在存储之前创建程序
  • 派生表 - 但它只保存一次查询期间的结果

结果需要在存储过程的持续时间内可用.

The result needs to be available for the duration of the stored procedure.

还有其他选择吗?

2014 年 6 月 16 日更新:根据答案和评论,似乎 volatile table 是最好的答案.但是,然后我们尝试使用 volatile 表,存储过程抱怨该表不存在.有没有办法解决这个问题?

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?

推荐答案

你考虑过全局临时表吗?

Have you considered a global temporary table?

表定义存储在 DBC 数据字典中,并在 SQL 引用时在会话期间实例化.像易失性表一样,全局临时表是特定于会话的.与 volatile 表不同,全局临时表依赖于用户的临时空间而不是 spool 空间.

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.

这篇关于将 select 语句的结果存储在存储过程中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆