I am writing a function and I want to wrap it with a table function so that I can use it with select query.
Here is my type declaration and some lines of my functions
CREATE OR REPLACE PACKAGE TYPES AS TYPE CURSORTYPE IS REF CURSOR; TYPE vbugsrec IS RECORD ( bug_id bugs.bug_id%TYPE, facility bugs.facility%TYPE ); TYPE vbugstable IS TABLE OF vbugsrec INDEX BY BINARY_INTEGER; END; / CREATE OR REPLACE PACKAGE BODY CustomQueries AS FUNCTION pendverifylist (myldapid IN userpass.ldapalias%TYPE, maxrows IN PLS_INTEGER:= CustomQueries.maxrecords) RETURN types.vbugstable IS datarows types.vbugstable; var_useralias userpass.ldapalias%TYPE := UPPER (pendverifylist.myldapid) ; CURSOR pendverify_cur ( cursor_var_alias IN userpass.ldapalias%TYPE, cursor_var_mybugstatus IN bugs.bug_status%TYPE, cursor_var_wild IN qa_list.component%TYPE ) IS SELECT buglist.bug_id, buglist.facility FROM bugs buglist, (SELECT qa.product, qa.component FROM qa_list qa, userpass UP WHERE qa.qa_id = UP.userid AND UP.ldapalias = cursor_var_alias) plist WHERE buglist.bug_status = cursor_var_mybugstatus AND buglist.smr_state IN (SELECT fs.finalstate FROM finalstates fs) AND buglist.facility = plist.product AND (buglist.product LIKE plist.component OR plist.component = cursor_var_wild); BEGIN OPEN pendverifylist.pendverify_cur (cursor_var_alias => pendverifylist.var_useralias, cursor_var_mybugstatus => CustomQueries.default_bugstatus, cursor_var_wild => CustomQueries.wildcard); FETCH pendverifylist.pendverify_cur BULK COLLECT INTO pendverifylist.datarows LIMIT LEAST (GREATEST (0, pendverifylist.maxrows), CustomQueries.MAXRECORDS); CLOSE pendverifylist.pendverify_cur; RETURN pendverifylist.datarows; END pendverifylist; END CustomQueries; /
When I want to use the TABLE function as shown below, I get error.ORA-00902: invalid data type
SELECT * FROM TABLE(CUSTOMQUERIES.PENDVERIFYLIST ( 'product', 50 ));
Can anyone help what I am doing wrong here?
Thanks in advance
Jeevan
source share