【问题标题】:selecting multiple columns in pl/sql collection在 pl/sql 集合中选择多个列
【发布时间】:2011-10-22 08:37:49
【问题描述】:

实际上我已经创建了以下程序,它工作正常。

CREATE or REPLACE PROCEDURE GET_NOS(
firstDate IN DATE,
secondDate IN DATE,
thirdDate IN DATE,
fourthDate IN DATE,
test IN VARCHAR2,
Slnt_Entity OUT TEST.RefCsr
)
AS
 DemoTable CRITERIA_LIST_TABLE;
 BEGIN


SELECT column1 BULK COLLECT INTO DemoTable FROM opr_test where call_date between firstDate AND secondDate AND id=test
MINUS
SELECT column1 FROM opr_test where call_date between thirdDate AND fourthDate AND id=test;


OPEN Slnt_Entity FOR SELECT * FROM TABLE(
                                            CAST (
                                                    DemoTable AS CRITERIA_LIST_TABLE
                                                 )
                                    ) Nos;

END;
/

2。第二个

create or replace TYPE "CRITERIA_LIST_TABLE" as table of varchar2(20);
/
  1. 第三

    create or replace PACKAGE "TEST"
    AS
    TYPE RefCsr IS REF CURSOR;
    END TEST;
     /
    

    现在我想像这样更改我的查询

    SELECT column1,column2 BULK COLLECT INTO DemoTable FROM opr_test where call_date between firstDate AND secondDate AND id=test
    MINUS
    SELECT column1,column2 FROM opr_test where call_date between thirdDate AND fourthDate AND id=test;
    

所以我改变了程序

CREATE or REPLACE PROCEDURE GET_NOS(
firstDate IN DATE,
secondDate IN DATE,
thirdDate IN DATE,
fourthDate IN DATE,
test IN VARCHAR2,
Slnt_Entity OUT TEST.RefCsr
 )
AS

CURSOR c1 IS SELECT column1,column2 FROM opr_test;
  create or replace TYPE "ABC" IS TABLE OF c1%ROWTYPE;
DemoTable ABC;

BEGIN


 SELECT column1 BULK COLLECT INTO DemoTable FROM opr_test where call_date between firstDate AND secondDate AND id=test
 MINUS
 SELECT column1 FROM opr_test where call_date between thirdDate AND fourthDate AND id=test;


  OPEN Slnt_Entity FOR SELECT * FROM TABLE(
                                            CAST (
                                                    DemoTable AS CRITERIA_LIST_TABLE
                                                 )
                                    ) Nos;

  END;
  /

但这是不正确的,请告诉我程序是什么样子的

【问题讨论】:

  • 如果您提供了错误信息等,那么回复会更容易...

标签: oracle oracle11g plsqldeveloper


【解决方案1】:

user595014,帮助您解决您遇到的问题,并在 StackOverflow 上提出几个问题。阅读 ORACLE-BASE 中关于创建和返回 oracle REF_CURSOR 类型的这篇文章。

如果您阅读了所有内容,它还会向您展示如何将 ref_cursor 返回到调用 Java 程序(您在上一个问题中问过我的问题)。

它将为您提供解决问题所需的一切。

http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php

【讨论】:

  • 在您的答案中包含链接内容的相关部分可能很有用。以防万一该网站更改或死亡。
猜你喜欢
  • 1970-01-01
  • 2022-01-03
  • 2023-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-06
相关资源
最近更新 更多