惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
V
Visual Studio Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
K
Kaspersky official blog
博客园 - 叶小钗
月光博客
月光博客
S
Schneier on Security
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
量子位
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
P
Privacy & Cybersecurity Law Blog
Cyberwarzone
Cyberwarzone
S
Securelist
Hugging Face - Blog
Hugging Face - Blog
B
Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Vulnerabilities – Threatpost
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
V
V2EX
MongoDB | Blog
MongoDB | Blog
博客园_首页
Recorded Future
Recorded Future
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Fortinet All Blogs
GbyAI
GbyAI
Microsoft Security Blog
Microsoft Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Troy Hunt's Blog
罗磊的独立博客
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
O
OpenAI News
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
N
News | PayPal Newsroom
G
GRAHAM CLULEY
H
Hacker News: Front Page
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - Leetle

win2000/xp/2003下完全卸载ORACLE Oracle9i中分区partition的使用 [ZT]Oracle数据库字符集问题解决方案大全 Oracle 8.1.6 for Win2000 系统文件解释 如何连接oracle数据库及故障解决办法 Oracle 9i初始化参数文件 简单冷备份恢复操作步骤 Win 下常用的oracle 9i服务的介绍 oracle初始化参数说明 Oracle中的数据字典技术初级入门 【转帖】揭露不为人所知的招聘网站的秘密, 业内人士告诉你:为何你的简历石沉大海?! 市场盈亏指标CYS的使用技巧 炒股短线招术(完整版) DBA常用SQL语句系列 Oracle 9i 分析函数参考手册 使用Oracle的分析函数ROW_NUMBER、DENSE_RANK、RANK oracle日期处理完全版(三) oracle日期处理完全版(二) oracle日期处理完全版(一)
Function怎么返回一个数据集
Leetle · 2007-04-27 · via 博客园 - Leetle

1.CREATE OR REPLACE PACKAGE ROME AS
AS
TYPE RefCursor IS REF CURSOR;
Function GetCompany(key IN char) return RefCursor;
END;
/
CREATE OR REPLACE PACKAGE BODY ROME IS
IS
Function GetCompany(key IN char) return RefCursor
Is
v_temp RefCursor;
BEGIN
OPEN v_temp FOR
SELECT * FROM Company WHERE com_ID =key;
return v_temp;
END GetCompany;
END;
  
2.(适用于PLSQL类型)
Type shifts_ty is RECORD(
     comp_code    varchar2(10),
     SHIFT_CODE    varchar2(10),  
     sft_flg        varchar2(10),
     beg_tm        number,
     end_tm        number,
     skills        varchar2(10)) ;
Type shifts is Table of shifts_ty index by binary_integer;
  
FUNCTION test_proc(test varchar2)
  
return shifts is
shiftspkg SHIFTS;   --表变量shiftspkg
  
cursor q1 is select  
shifts.comp_code,shifts.shift_code,shifts.WRK_BEG_TM,shifts.WRK_end_TM,
shifts.skills from str_shifts shifts where comp_code ='TSI';  --str_shifts是与表变量shiftspkg结构完全相同的真实表
qty q1%rowtype;
begin
  
     open q1;
     loop
         fetch q1 into qty;
         exit when q1%notfound;
      
         for iCount in 1.. qty.skills.count
         loop
             shiftspkg(icount).comp_code:= qty.comp_code;
             shiftspkg(icount).SHIFT_CODE:= qty.shift_code;
             shiftspkg(icount).sft_flg:= 'SLOTS';
             shiftspkg(icount).beg_tm:= qty.wrk_beg_tm;
             shiftspkg(icount).end_tm:= qty.wrk_end_tm;
             shiftspkg(icount).skills:= qty.skills(icount);
         end loop;
     end loop;
     return    shiftspkg;
end;
end;
  
3.使用于SQL类型
  
create or replace type myScalarType as object
    ( comp_code varchar2(10),
      shift_code varchar2(10),
      sft_flg        varchar2(10),
      beg_tm        number,
      end_tm        number,
      skills        varchar2(10)
       )
  
create or replace type myArrayType as table of myScalarType
   
     
FUNCTION test_proc(test varchar2) return myArrayType
     is
         l_data  myArrayType := myArrayType()  ;
     begin
        for i in 1 .. 5
        loop
            l_data.extend;
            l_data( l_data.count ) := myScalarType( 'cc-'||i,
                                                    'sc-'||i,
                                                    'flg-'||i,
                                                    i,
                                                    i,
                                                    test||i );
        end loop;
     
        return l_data;
    end;
     
    end;
  
select *
       from THE ( select cast( pkg_test.test_proc('hello') as myArrayType )
                    from dual ) a

select *
       from table ( cast( my_function() as mytabletype   ) )
      order by seq