1

Is it possible to do create a function to take in a query result and do some processing and return me a pipeline table. If it works for a normal function, i can get it to work for pipelined. Its not called from a stored proc, so don't know how to use cursor in this scenario.

select SF_PROCESS_FUNCTION(
    select 'abcd' as keyVal, 'first value' as descVal from dual
    union
    select 'efgh' as keyVal, 'second value' as descVal from dual) from dual;

Any help will be greatly appreciated. Thanks

3
  • Does this help? dbasupport.com/forums/… Commented Jan 19, 2018 at 17:34
  • do some processing what kind of ?? Commented Jan 19, 2018 at 18:03
  • @clinomaniac : I tried that approach, but i am not able to make it to work even from a plsql block DECLARE testTyp Z_TEST_ROW_TBL := Z_TEST_ROW_TBL(); BEGIN select * into testTyp from ( select 'abcd' as keyVal, 'first value' as descVal from dual union select 'efgh' as keyVal, 'second value' as descVal from dual ); --SF_B_TEST_FN_WTIH_TBL(testVal); DBMS_output.put_line('end:'); END; Commented Jan 19, 2018 at 20:37

1 Answer 1

2

You could probably wrap the query using a CURSOR expression. Since you want it to be PIPELINED, you need to use select * FROM TABLE() syntax

select * FROM TABLE ( SF_PROCESS_FUNCTION(
CURSOR
 (
    select 'abcd' as keyVal, 'first value' as descVal from dual
    union
    select 'efgh' as keyVal, 'second value' as descVal from dual) 
) );

Your function should have a SYS_REFCURSOR as input argument.

CREATE OR REPLACE FUNCTION 
SF_PROCESS_FUNCTION (inpquery IN SYS_REFCURSOR) RETURN keydesc_typ 
    PIPELINED 
    AS
..
..
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.