2

私のパッケージでは、recordタイプと対応するtableタイプを定義しました。次に、カーソルを開き、各結果をパイプラインで出力しようとするパイプライン関数があります。問題は、型の不一致エラーが発生することです。カーソルを自分のレコード タイプにキャストしようとしましたが、うまくいきませんでした。何が間違っているのでしょうか?

create or replace package myTest as
  type myRec is record(
    id  integer,
    foo varchar2(10)
  );
  type myTable is table of myRec;

  function output() return myTable pipelined;
end myTest;
/

create or replace package body myTest as
  function output() return myTable pipelined
  as
  begin
    for myCur in (
      select id, foo from someTable
    )
    loop
      pipe row(cast(myCur as myRec));
    end loop;

    return;
  end output;
end myTest;
/
4

1 に答える 1

4
create or replace package body myTest as
  function output return myTable pipelined
  as
    --   Add a "record" variable":
    xyz  myRec;
  begin
    for myCur in (
      select id, foo from someTable
    )
    loop
      -- Fill the record variable with the
      -- values from the cursor ...
      xyz.id  := myCur.id;
      xyz.foo := myCur.foo;
      -- ... and pipe it:
      pipe row(xyz);
    end loop;

    return;
  end output;
end myTest;
于 2012-08-21T12:21:58.827 に答える