关于从Ms Sql Server向Oracle移植的问题

Ykang 2002-03-14 10:29:44
我在MS SQLSerer做一个汇总查询,程序框架如下:
Create Table #Temp(...) -- 我在里面创立了一个局部临时表
.
.
.
--然后使用了几个游标对临时表进行插入和更新操作
select * from #temp --将数据集返回给BCB
整个程序有几百行,全放在TQuery控件里面的,使用的是参数查询,运行情况很好。

但现在没想到移植到Oracal里面来竟然如此困难重重。
花了九牛二虎之力,总算解决了游标问题,但还有两个问题没有解决:
1:创立局部临时表问题
2: 最后返回数据集的问题

我的感觉是在Ms SQL Server里面写程序很自由。
请各位大侠多多指教
...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ykang 2002-04-04
  • 打赏
  • 举报
回复
谢谢各位
tonkeycn 2002-03-29
  • 打赏
  • 举报
回复
create or replace package testoutput is
TYPE toutput is TABLE of varchar2(255)
INDEX BY BINARY_INTEGER;
procedure testoutput(iinput IN NUMBER,ioutput OUT toutput);
end testoutput;
/
show errors
---------- 包头


create or replace package body testoutput As
procedure testoutput(iinput IN NUMBER,ioutput OUT toutput) is
cursor c_output is
select tname from tab where rownum <=10;
icount number default 1;
begin
for c_output_rec in c_output loop
ioutput(icount) :=c_output_rec.tname;
icount := icount + 1;
end loop;
end testoutput;
end testoutput;

/
show errors
---------- 包体

说明
1、Type toutput is table of varchar2(255) Index by Binary_integer;
table 是 pl/sql的一个数据结构,相当于可变数组
可以用table这个数据结构返回数据集
必须在包内定义,而不是再存储过程中定义
吧需要传出的值(这里是ioutput)的类型附成table型,参数类型为out
Ykang 2002-03-28
  • 打赏
  • 举报
回复
各位捧捧场啊
tonkeycn 2002-03-28
  • 打赏
  • 举报
回复
up
xzou 2002-03-14
  • 打赏
  • 举报
回复
oracle 8i以上提供了临时表,不过不太好用,临时表需要先建立
procedure中,做插入,插入完成后,然后安一般表的方法查询临时表即可
create GLOBAL TEMPORARY table RET_STATCustomer
(
CustNum Number(8) not null,
CustType Char(2) not null,
Branch VarChar2(10) not null,
STATTime Char (14) not null
);

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧