【问题标题】:How to return table and additional local variable from oracle stored procedure?如何从 oracle 存储过程中返回表和附加局部变量?
【发布时间】:2013-04-18 11:21:17
【问题描述】:

在我的存储过程中,我需要为工作台生成报告。我需要直接从数据库表中获取记录(通过使用选择查询),另外我需要添加一些操作变量。我必须将这个结果集合从程序返回为sys_refcursor

例如: 我的表为emp(id, name)。 我有变量job 现在我想从我的程序中返回(emp.idemp.namejob)。

如果您能提供帮助,那就太好了。 提前致谢。

【问题讨论】:

    标签: oracle plsql


    【解决方案1】:

    将 PL/SQL 变量与表中的数据组合起来很容易......

    Create or replace function get_some
       return sys_refcursor
    as
        return_value sys_refcursor;
        l_whatever varchar2(10) := 'JOB';
    begin
        open return_value for
            select emp_id, emp_name, l_whatever
            from your_table;
        return return_value;
    end;
    /
    

    我怀疑这不是你的意思。如果是这种情况,您需要编辑您的问题,以详细说明您在做什么。尤其是“一些被操纵的变量(sic)”的意思。提供一些示例输入和输出会很有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-25
      • 1970-01-01
      • 2010-12-18
      • 2023-04-05
      • 2013-04-05
      • 2017-05-12
      • 2022-08-07
      • 2017-01-07
      相关资源
      最近更新 更多