免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4882 | 回复: 6
打印 上一主题 下一主题

为什么可以declare global temporary table,但是不能select? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-03-10 18:39 |只看该作者 |倒序浏览
我想在procedure里头用global temporary table,db2的sql reference告诉我 只要有 user temporary tablespace的使用权限就可以了
因此,我create user temporary tablespace usertemp .....并且也grant use of tablespace usertemp to public,好像ok了。
(grant use of tablespace usertemp to user tt 也做过)

我用db2的clp,connect to sample user tt using tt (tt是普通linux os用户)

在db2的命令行上,我可以declare global temporary table tmptest (id integer),也可以select * from session.tmptest

但是,在写的procedure里头,比如:
[[db2inst@mail-test scripts]$ db2 -td@ -vf test.db2
drop procedure test
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "TT.TEST" is an undefined name. SQLSTATE=42704

create procedure test()
begin
declare v_count integer;
DECLARE GLOBAL TEMPORARY TABLE tmptest (id integer);
select count(*) into v_count from session.tmptest;
drop table session.tmptest;

end
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0551N "TT" does not have the privilege to perform operation "SELECT" on
object "SESSION.TMPTEST". LINE NUMBER=8. SQLSTATE=42501

procedure里头可以declare global temporary table,也可以drop session.tmptest,但就是select/update/insert等操作不可以。郁闷


可友好心人,告诉我,还缺少什么权限啊?因为在另外一个数据库中(是我以前测试用的,加了些什么权限给tt都忘了),同样的用户是可以的

论坛徽章:
0
2 [报告]
发表于 2003-03-11 22:27 |只看该作者

为什么可以declare global temporary table,但是不能select?

-_-nobody knows?
aca000 该用户已被删除
3 [报告]
发表于 2003-03-11 23:12 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
4 [报告]
发表于 2003-03-12 19:10 |只看该作者

为什么可以declare global temporary table,但是不能select?

我给用户tt赋予了dbadm权限,暂时可以解决,但是这个权限太大-_-

用临时表当然是出于需求,比如db2没有oracle那样的array结构,我只能找temp table,数据其实很少的,用不着建索引
aca000 该用户已被删除
5 [报告]
发表于 2003-03-13 07:13 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
6 [报告]
发表于 2003-03-13 20:09 |只看该作者

为什么可以declare global temporary table,但是不能select?

无论如何,都谢谢你

顺便帮自己up一下

论坛徽章:
0
7 [报告]
发表于 2003-04-11 11:13 |只看该作者

为什么可以declare global temporary table,但是不能select?

打pack
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP