다른 파이프라인 함수를 호출하는 파이프라인 함수
다음은 파이프라인 기능이 두 가지인 패키지입니다.
create or replace type tq84_line as table of varchar2(25);
/
create or replace package tq84_pipelined as
function more_rows return tq84_line pipelined;
function go return tq84_line pipelined;
end tq84_pipelined;
/
해당 패키지 본체를 앤트합니다.
create or replace package body tq84_pipelined as
function more_rows return tq84_line pipelined is
begin
pipe row('ist');
pipe row('Eugen,');
return;
end more_rows;
function go return tq84_line pipelined is
begin
pipe row('Mein');
pipe row('Name');
/* start */
for next in (
select column_value line from table(more_rows)
)
loop
pipe row(next.line);
end loop;
/* end */
pipe row('ich');
pipe row('weiss');
pipe row('von');
pipe row('nichts.');
end go;
end tq84_pipelined;
/
중요한 것은 전화를 걸어오는 것입니다.more_rows와 함께for next in ...사이에/* start */그리고./* end */
저는 다음과 같이 패키지를 사용할 수 있습니다.
select * from table(tq84_pipelined.go);
이 모든 것이 훌륭하고 훌륭하지만, 그 사이의 선들을 교체할 수 있기를 바랐습니다./* start */그리고./* end */라는 간단한 전화로more_rows.
그러나 PLS-00221: 'MORE_ROWs'는 프로시저가 아니거나 정의되지 않았기 때문에 이는 분명히 불가능합니다.
그래서, 제 질문은, 정말로 루프를 단축시킬 방법이 없을까요?
편집
분명히 지금까지의 답변을 보면 제 질문은 명확하지 않았습니다.
말씀하신 대로 패키지가 작동합니다.
하지만 저는 마커 사이의 6개(즉, SIX) 라인이 신경 쓰입니다./* start */그리고./* end */. 이것들을 한 줄로 교체하고 싶습니다.하지만 저는 그렇게 할 방법을 찾지 못했습니다.
파이프라인 기능의 핵심은 TABLE() 기능을 공급하는 것입니다.저는 그것을 피할 방법이 없다고 생각합니다.안타깝게도 우리는 PL/SQL 변수에 그 출력을 할당해야 합니다.이와 같이 중첩된 테이블에 파이프라인 함수를 할당할 수 없습니다.nt := more_rows;때문에
PLS-00653: aggregate/table functions are not allowed in PL/SQL scope
그렇게SELECT ... FROM TABLE()그래야 한다.
당신이 고려할 수 있도록 조금 다른 해결책이 있습니다.그것이 당신의 근본적인 문제를 해결해 줄 수 있을지 모르겠습니다.
create or replace package body tq84_pipelined as
function more_rows return tq84_line pipelined is
begin
pipe row('ist');
pipe row('Eugen,');
return;
end more_rows;
function go return tq84_line pipelined is
nt1 tq84_line;
nt2 tq84_line;
nt3 tq84_line;
nt0 tq84_line;
begin
nt1 := tq84_line('Mein','Name');
select *
bulk collect into nt2
from table(more_rows);
nt3 := tq84_line('ich','weiss','von','nichts.');
nt0 := nt1 multiset union nt2 multiset union nt3;
for i in nt0.first..nt0.last
loop
pipe row(nt0(i));
end loop;
return;
end go;
end tq84_pipelined;
/
여러분도 아시다시피 (그러나 다른 추구자들의 이익을 위해) 함께 글램핑 컬렉션을 위한 MULTIESET UNION 구문이 Oracle 10g에 도입되었습니다.
GO()의 이 버전은 원래 구현과 동일한 출력을 생성합니다.
SQL> select * from table( tq84_pipelined.go)
2 /
COLUMN_VALUE
-------------------------
Mein
Name
ist
Eugen,
ich
weiss
von
nichts.
8 rows selected.
SQL>
해라select column_value line from table(tq84_line.more_rows)즉, 쿼리에 패키지 이름을 포함합니다.
언급URL : https://stackoverflow.com/questions/2779495/pipelined-function-calling-another-pipelined-function
'programing' 카테고리의 다른 글
| CSS 애니메이션 종료 시 최종 상태 유지 (0) | 2023.10.11 |
|---|---|
| WordPress get_posts를 제목별로 예를 들어 다음과 같이 입력합니다. (0) | 2023.10.11 |
| 구분 기호를 사용한 MySQL 부분 문자열 추출 (0) | 2023.10.11 |
| Mysql 색상 체계 (0) | 2023.10.11 |
| 관련이 없는 SELECT 문으로 다른 결과를 반환하는 동시 MYSQL 프로시저 호출 (0) | 2023.10.11 |