pipe rows

------------------------------------------------------------------ Sometimes maybe you are forbided to create any temporary table when doing the coding. If so, perhaps you should first keep the data in a record and then regard this record as a table for doing some operations like join by some means. ------------------------------------------------------------------ Here is a way recommended to handle it : --Firstly create a record test_rec and test_typ which is the table of test_rec type test_rec is record (id number ,name varchar2(10)); type test_typ is table of test_rec; v_test test_typ := test_typ(); --Then generate data for v_test v_test.delete; for i in 1..10 loop v_test.extend; v_test.id := i; v_test.name := chr(i); end loop; --Then create a function keeping the data which can be specified as a table create function gen_tbl return test_typ pipelined as begin for i in 1..v_test.count loop pipe row(v_test(i)); end loop; return; end gen_tbl; --At last you could doing any operation specifying v_test as a table select a.* from TABLE(gen_tbl(v_test)) a where a.id = 3; ---Example : create or replace package p_test as type test_rec is record (id number ,name varchar2(10)); type test_typ is table of test_rec; v_test test_typ := test_typ(); function gen_tbl return test_typ pipelined; procedure main_exec; end; / create or replace package body p_test as function gen_tbl return test_typ pipelined as begin for i in 1..v_test.count loop pipe row(v_test(i)); end loop; return; end gen_tbl; procedure main_exec is type rc is ref cursor; v_cur rc; id number; name varchar2(10); begin v_test.delete; for i in 1..26 loop v_test.extend; v_test(i).id := i+64; v_test(i).name := chr(i+64); end loop; open v_cur for select a.* from TABLE(gen_tbl) a; for i in 1..26 loop fetch v_cur into id,name; dbms_output.put_line(id||' with name is '||name); end loop; end; end; /
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全评估测试题大模型安全评估测试题关键词库生成内容测试题库应拒答测试题库非拒答测试题大模型安全
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值