Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

recursive pipeline function

kaericnOct 5 2016 — edited Oct 22 2016

I Have this procedure that I want to convert to a pipeline function.

Its from this discussion:

sql - recursive permutation algorithm in plsql - Stack Overflow

The original solution from stackflow works but once I try to convert it to pipeline function it fails. I am on oracle12c

The compile error is

Compilation failed,line 16 (21:41:43)

PLS-00221: 'PRINT_ANAGRAMS2' is not a procedure or is undefinedCompilation failed,line 16 (21:41:43)

PL/SQL: Statement ignored

My code is

CREATE OR REPLACE EDITIONABLE TYPE "T_TF_ROW" AS OBJECT (

  --id NUMBER,

  description VARCHAR2(500)

)

/

CREATE OR REPLACE EDITIONABLE TYPE "T_TF_TAB" IS TABLE OF t_tf_row

/

create or replace function print_anagrams2

  (pre in varchar2, str in varchar2) RETURN t_tf_tab PIPELINED AS

    prefix varchar2(30);

    stringg varchar2(30);

    strlen number;

  begin

    strlen := length(str);

    if NVL(strlen, 0) = 0 then

     --dbms_output.put_line(pre);

--PIPE ROW(t_tf_row(i, 'Description for ' || i));

PIPE ROW(t_tf_row(pre));

    else

      for i in 1..strlen loop

        prefix := pre || SUBSTR(str,i,1);

        stringg := SUBSTR(str,1,i - 1) || SUBSTR(str,i+1,strlen);

        print_anagrams2(prefix,stringg);

      end loop;

    end if;

  end;

Message was edited by: kayaman808

This post has been answered by sdstuber on Oct 5 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2016
Added on Oct 5 2016
13 comments
2,013 views