从包中的参考光标获取所有记录 [英] Get all records from a Ref Cursor in a Package

查看:70
本文介绍了从包中的参考光标获取所有记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调用以下函数时,我想获取每一行:

I'd like to fetch each row when I call the following function:

CpuReporting.getgridusage(300)

此功能在CpuReporting程序包中提供.它具有:

This function was provided in a CpuReporting package. It has:

Function GetGridUsage(minutes_Input in Number) Return CurGridUsage;
Type CurGridUsage is Ref Cursor Return RecGridUsage;
Type RecGridUsage is Record (ConfigId Number,
                           Phase VarChar2(400),
                           Environment VarChar2(400),
                           SessionStartTime Date,

我已经在PL/SQL Developer中浏览了GetGridUsage函数,它具有两个参数:(结果)REF CURSOR和MINUSTES_INPUT IN NUMBER

I've browsed the GetGridUsage function in PL/SQL Developer, it has two parameters: (Result) REF CURSOR and MINUSTES_INPUT IN NUMBER

我希望能够获取所有行,并且由于我以前从未使用过Ref Cursor,所以我真的很想知道您将如何编写PL/SQL.

I want to be able to fetch all the rows and since I haven't worked with Ref Cursor before, I'm really interested in knowing how will you going to write the PL/SQL.

推荐答案

假设包名称为CpuReporting,则需要类似

Assuming CpuReporting is the package name, you'd want something like

DECLARE
  l_cursor CpuReporting.CurGridUsage;
  l_rec    CpuReporting.RecGridUsage;
BEGIN
  l_cursor := CpuReporting.getGridUsage( 300 );
  LOOP
    FETCH l_cursor INTO l_rec;
    EXIT WHEN l_cursor%notfound;

    -- Do something with l_rec.  As an example, print the Environment
    dbms_output.put_line( l_rec.Environment );
  END LOOP;

  CLOSE l_cursor;
END;

这篇关于从包中的参考光标获取所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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