Focal Point
[CLOSED] Store Procedure - Oracle "Nested Table"

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4137095516

January 18, 2012, 05:28 PM
prodrigu
[CLOSED] Store Procedure - Oracle "Nested Table"
Question:
Can WebFocus call an Oracle stored procedure that returns an Oracle NESTED TABLE containing a collection of Oracle RECORDS?

Business Background:
We have a business requirement to order the results of a query in a way that is not possible using the ORDER BY clause in the query.
The ordering is based on evaluating several attributes of our business objects in a decision tree.
The decision tree is implemented as a “comparator” function, and our ordering implementation is based on a bubble sort that calls the “comparator” function.

  
--Here's a sample script you can run in an SQLNavigator editor to test the procedure.
--Be sure to turn the “Server Output” on. DECLARE
   my_inv_table wmgappl.inv_sort.inv_table_type; --The return type is an Oracle NESTED TABLE.
   temp_inv_rec wmgappl.inv_sort.inv_rec_type; --The RECORD type that is in the table.
   i NUMBER;
   tableSize NUMBER;
BEGIN
   --Calling the sorting procedure example implementation.
   --We need to be able to call this from inside a .fex. (And possibly hold in a HOLD TABLE?)
   wmgappl.inv_sort.sort_inv_by_query(
      place_holder1=>'x',
      v_inv_table=>my_inv_table
   );
   
   i:=0;
   tableSize:=my_inv_table.COUNT;
   WHILE i<tableSize LOOP
      i:=i+1;
      temp_inv_rec := my_inv_table(i);
      DBMS_OUTPUT.put_line('INV_TABLE('||i||'): hlPk='||temp_inv_rec.hl_pk
            ||', woPk='||temp_inv_rec.wo_pk
            ||', legNum='||temp_inv_rec.leg_n
            ||', frTo='||temp_inv_rec.fr_to_x
            ||', prevHlpk='||temp_inv_rec.prev_hl_pk
            ||', nextHlpk='||temp_inv_rec.next_hl_pk
            ||', cmpltDate='||temp_inv_rec.cmplt_t
            ||', tkId='||temp_inv_rec.tk_id
      );
   END LOOP;
END;

This message has been edited. Last edited by: Kerry,


Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats
January 24, 2012, 05:07 PM
Kerry
Hi prodrigu,

This looks like a more involved issue, so the best channel for assistance would be to open a case with Customer Support Services. Please call at 1-800-736-6130, or access online at InfoAssist.

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
January 25, 2012, 08:21 AM
njsden
prodrigu, as far as I now all WebFOCUS expects when querying an Oracle stored procedure is a REF CURSOR it can fetch from, so you'll have to handle this within the stored procedure itself.

One idea that comes to mind would be to assign your NESTED TABLE structure to the "returning" REF CURSOR in your stored procedure.

You'll have to check Oracle's documentation on that for particular details and examples but this is usually the way a collection object is assigned to a cursor in Oracle PL/SQL:

OPEN my_ref_cursor FOR
SELECT * FROM TABLE(CAST(my_collection AS my_collection_type));


Once your data is wrapped by the REF CURSOR, WebFOCUS will just "see" it.

Hope this helps.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
January 25, 2012, 08:25 AM
njsden
Hmm, given your sample code I'll dare to say that this may work:

OPEN my_ref_cursor FOR
SELECT * FROM TABLE(CAST(my_inv_table AS wmgappl.inv_sort.inv_table_type));


Replace my_ref_cursor with the REF CURSOR output parameter in your stored procedure as required by WebFOCUS.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
October 22, 2015, 02:38 PM
Ricardo Augusto
I am getting this error :

(FOC1400) SQLCODE IS 6550 (HEX: 00001996)
: ORA-06550: line 1, column 41:
: PLS-00103: Encountered the symbol "," when expecting one of the
: following:
: ( ) - + case mod new not null select
:
: table continue avg count current exists max min prior sql
: stddev sum variance execute multiset the both leading
: trailing forall merge year month day hour minute second
: timezone_hour timezone_minute timezone_region timezone_abbr
: time timestamp interval date
L (FOC1405) SQL PREPARE ERROR.



At procedure i have this ref cursors:

type HLHeader_type is ref cursor return recHLHeader;
type HLMain_type is ref cursor return recHLMain;


WebFOCUS 8.1.05 / APP Studio
Trudy
Did you ever get a resolution to this? We are getting the same error
PLS-00103.....

Thanks


WF8
Windows
prodrigu
Trudy,

We decide to use a Web Service Call. Now we are using a FILEDEF to call a HTTP Web Service which runs a query in JAVA and sorts it then returns the data in XML. Then we use a XML adapter to convert the XML data into a temp Master Table which then we can TABLE FILE the data out.

Thanks,
prodrigu


Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats
Ricardo Augusto
I still cannot create a master file to that nested oracle procedure, but I am able to access it.


SET SQLENGINE = SQLORA

SQL SET SERVER bzmkttst

SQL SQLORA

ex svstst.pack1.proc1 1;

TABLE FILE SQLOUT
PRINT *
END
  



http://forums.informationbuild...237099876#5237099876


WebFOCUS 8.1.05 / APP Studio