How to add the collection

Hello

I use oracle 10g

I need help to add the output (collection) of a procedure in the main proc. How acchive with it, using temporary tables.
CREATE OR REPLACE TYPE t_domain_obj
AS
   OBJECT (
      account_id varchar2 (60),
      org_id varchar2 (60),
      org_name varchar2 (100),
      org_role number,
      associated_id varchar2 (60)
   );

CREATE OR REPLACE TYPE t_domain_tab IS TABLE OF t_domain_obj;

CREATE OR REPLACE TYPE array_element AS TABLE OF number;
/

CREATE TABLE t_acc (
   acc_no number
);


INSERT INTO t_acc (acc_no)
VALUES(1);

INSERT INTO t_acc (acc_no)
VALUES(2);

CREATE TABLE t_domain (
   account_id varchar2 (60),
   org_id varchar2 (60),
   org_name varchar2 (100),
   org_role number,
   associated_id varchar2 (60)
);

INSERT INTO t_domain
(
    account_id, org_id, org_name, org_role, associated_id
)
VALUES('1', '2', 'ORGID_1', 1, SUP_1');

INSERT INTO t_domain
(
    account_id, org_id, org_name, org_role, associated_id
)
VALUES('1', '2', 'ORGID_1', 3, NULL);

INSERT INTO t_domain
(
    account_id, org_id, org_name, org_role, associated_id
)
VALUES('1', '3', 'ORGID_1', 1, 'SUP_1');

INSERT INTO t_domain
(
    account_id, org_id, org_name, org_role, associated_id
)
VALUES('2', '1', 'ORG_2', 1, NULL);

CREATE OR REPLACE PROCEDURE domain (accid IN number,
                                    domain_out OUT t_domain_tab
)
AS
BEGIN
   SELECT t_domain_obj (account_id, org_id, org_name, org_role, associated_id
         )
   BULK COLLECT INTO domain_out
   FROM t_domain
   WHERE account_id = accid;
END;
/

/*
This below procedure is giving me error
PLS-00801: internal error [*** ASSERT at file pdw4.c, line 2076; Type 0x0x2a97373090 has no MAP method.; DOMAIN_ALL__ADHAS__P__318160[16, 1]]
*/

CREATE OR REPLACE PROCEDURE domain_all (domain_out OUT t_domain_tab)
AS
   acc_lst      array_element;
   domain_lst   t_domain_tab;
BEGIN
   domain_out   := t_domain_tab (t_domain_obj (NULL, NULL, NULL, NULL, NULL));

   SELECT acc_no
   BULK COLLECT INTO acc_lst
   FROM t_acc;

   FOR i IN 1 .. acc_lst.LAST
   LOOP
      domain (acc_lst (i), domain_lst);
      -- I need to append the data to the excisting collection

      domain_out   := domain_out MULTISET UNION domain_lst;
   END LOOP;
END;
/

/*
--To display all from the table

DECLARE
   domain_lst   t_domain_tab;
BEGIN
  domain_all(domain_lst);

   IF domain_lst IS NOT NULL
   THEN
      FOR i IN 1 .. domain_lst.LAST
      LOOP
         DBMS_OUTPUT.put_line ('account_id : ' || domain_lst (i).account_id);
         DBMS_OUTPUT.put_line ('org_id : ' || domain_lst (i).org_id);
         DBMS_OUTPUT.put_line ('org_name : ' || domain_lst (i).org_name);
         DBMS_OUTPUT.put_line ('org_role : ' || domain_lst (i).org_role);
         DBMS_OUTPUT.put_line('associated_id : '|| domain_lst (i).associated_id);
      END LOOP;
   END IF;
END;

*/
Thank you
Alen

Alendhas wrote:
Thanks michael, but I am using oracle 10 g, if I use
domain_out: = domain_out multiset union domain_lst
its me gives error.

So what stops you to create map method as suggested by William Robertson (I'll assume character CHR (0) may not be present in the t_domain_obj ob object attributes):

SQL> select * from v$version
  2  /

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

SQL> CREATE OR REPLACE TYPE t_domain_obj
  2  AS
  3     OBJECT (
  4        account_id varchar2 (60),
  5        org_id varchar2 (60),
  6        org_name varchar2 (100),
  7        org_role number,
  8        associated_id varchar2 (60),
  9     MAP MEMBER FUNCTION weight
 10       RETURN VARCHAR2
 11     )
 12  /

Type created.

SQL> CREATE OR REPLACE TYPE BODY t_domain_obj
  2  AS
  3     MAP MEMBER FUNCTION weight
  4       RETURN VARCHAR2
  5       IS
  6       BEGIN
  7           RETURN CHR(0) || account_id || CHR(0) || org_id || CHR(0) || org_name || CHR(0) || org_role || CHR(0) || associated_id || CHR(0);
  8      END;
  9  END;
 10  /

Type body created.

SQL> CREATE OR REPLACE TYPE t_domain_tab IS TABLE OF t_domain_obj
  2  /

Type created.

SQL> CREATE OR REPLACE TYPE array_element AS TABLE OF number;
  2  / 

Type created.

SQL> CREATE TABLE t_acc(
  2                     acc_no number
  3                    )
  4  /

Table created.

SQL> INSERT INTO t_acc (acc_no)
  2  VALUES(1)
  3  /

1 row created.

SQL> INSERT INTO t_acc (acc_no)
  2  VALUES(2)
  3  /

1 row created.

SQL> CREATE TABLE t_domain (
  2     account_id varchar2 (60),
  3     org_id varchar2 (60),
  4     org_name varchar2 (100),
  5     org_role number,
  6     associated_id varchar2 (60)
  7  )
  8  /

Table created.

SQL> INSERT INTO t_domain
  2  (
  3      account_id, org_id, org_name, org_role, associated_id
  4  )
  5  VALUES('1', '2', 'ORGID_1', 1, 'SUP_1')
  6  /

1 row created.

SQL> INSERT INTO t_domain
  2  (
  3      account_id, org_id, org_name, org_role, associated_id
  4  )
  5  VALUES('1', '2', 'ORGID_1', 3, NULL)
  6  /

1 row created.

SQL> INSERT INTO t_domain
  2  (
  3      account_id, org_id, org_name, org_role, associated_id
  4  )
  5  VALUES('1', '3', 'ORGID_1', 1, 'SUP_1')
  6  /

1 row created.

SQL> INSERT INTO t_domain
  2  (
  3      account_id, org_id, org_name, org_role, associated_id
  4  )
  5  VALUES('2', '1', 'ORG_2', 1, NULL)
  6  /

1 row created.

SQL> CREATE OR REPLACE PROCEDURE domain (accid IN number,
  2                                      domain_out OUT t_domain_tab
  3  )
  4  AS
  5  BEGIN
  6     SELECT t_domain_obj (account_id, org_id, org_name, org_role, associated_id
  7           )
  8     BULK COLLECT INTO domain_out
  9     FROM t_domain
 10     WHERE account_id = accid;
 11  END;
 12  /

Procedure created.

SQL> CREATE OR REPLACE PROCEDURE domain_all (domain_out OUT t_domain_tab)
  2  AS
  3     acc_lst      array_element;
  4     domain_lst   t_domain_tab;
  5  BEGIN
  6     domain_out   := t_domain_tab (t_domain_obj (NULL, NULL, NULL, NULL, NULL));
  7
  8     SELECT acc_no
  9     BULK COLLECT INTO acc_lst
 10     FROM t_acc;
 11
 12     FOR i IN 1 .. acc_lst.LAST
 13     LOOP
 14        domain (acc_lst (i), domain_lst);
 15        -- I need to append the data to the excisting collection
 16
 17        domain_out   := domain_out MULTISET UNION domain_lst;
 18     END LOOP;
 19  END;
 20  /

Procedure created.

SQL> DECLARE
  2     domain_lst   t_domain_tab;
  3  BEGIN
  4    domain_all(domain_lst);
  5
  6     IF domain_lst IS NOT NULL
  7     THEN
  8        FOR i IN 1 .. domain_lst.LAST
  9        LOOP
 10           DBMS_OUTPUT.put_line ('account_id : ' || domain_lst (i).account_id);
 11           DBMS_OUTPUT.put_line ('org_id : ' || domain_lst (i).org_id);
 12           DBMS_OUTPUT.put_line ('org_name : ' || domain_lst (i).org_name);
 13           DBMS_OUTPUT.put_line ('org_role : ' || domain_lst (i).org_role);
 14           DBMS_OUTPUT.put_line('associated_id : '|| domain_lst (i).associated_id);
 15        END LOOP;
 16     END IF;
 17  END;
 18  /
account_id :
org_id :
org_name :
org_role :
associated_id :
account_id : 1
org_id : 2
org_name : ORGID_1
org_role : 1
associated_id : SUP_1
account_id : 1
org_id : 2
org_name : ORGID_1
org_role : 3
associated_id :
account_id : 1
org_id : 3
org_name : ORGID_1
org_role : 1
associated_id : SUP_1
account_id : 2
org_id : 1
org_name : ORG_2
org_role : 1
associated_id :

PL/SQL procedure successfully completed.

SQL> 

SY.

Tags: Database

Similar Questions

  • How to add the column to Adobe flex mxml or actionsctpt mx:DataGrid?

    I have the simple mxml code

    <mx:DataGrid id="DGG"
                
    editable="true">
       
    <mx:dataProvider>
           
    <mx:Object scheduledDate="4/1/2006"/>
       
    </mx:dataProvider>
    </mx:DataGrid>
    <mx:Button id="SetBut"
              
    label="Set Array as Data Provider"
              
    click="SetDP(); AddBut.visible = true;"
              
    x="100.5"
              
    y="164"
              
    width="211"/>
    <mx:Button id="AddBut"
              
    label="Add a column!"
              
    click="AddCol();"
              
    x="100.5"
              
    y="194"
              
    width="211"
              
    visible="false"/>
    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.collections.ArrayCollection;

            [Bindable]
            public var MyAC:ArrayCollection=new ArrayCollection([{scheduledDate: "4/1/2006", homeTeam: "Chester Bucks"}]);

            public function SetDP():void
            {
                DGG.dataProvider=MyAC
            }

            public function AddCol():void
            {
                MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                DGG.columns.push(new DataGridColumn("Umpire"));
            }
        ]]>
    </mx:Script>

    I want to add lines to my datagrid table how do such thing?

    How to add the column to Adobe flex mxml or actionsctpt mx:DataGrid?

    (You can place this code in a Flash or AIR application - it compiles without error, but will not add any columns =)

    Change this:

    public void SetDP (): void
    {
    DGG.dataProvider = MyAC
    MyAC.addItem ({scheduledDate: "05/04/2007", homeTeam: "long hitters Valley", umpire: "Amanda Hugenkis"});
    }
               
    public void AddCol (): void
    {
    var dgc:DataGridColumn = new DataGridColumn ("Umpire");
    var ca:Array = DGG.columns;
    CA.push (DGC);
    DGG.columns = ca;
    }

    Dany

  • How to add the name of the title of graph in Excel

    Dear friends

    I'm using LabVIEW 8.0.I need how to add the name of the title of graph in Excel.

    You have the report generation tool? If so, the VI of graph Easy Excel has an entry for this.

    If you don't have the Toolbox, then you need to use ActiveX. Please do a search on the use of the ActiveX (there are examples provided with LabVIEW) to control Excel. Also, there are many examples in the thread Excel. NOTE: DON'T POST QUESTIONS IN THIS THREAD.

    In the end, you will need to search for information contained in MSDN.

  • How to add the full value of two buttons?

    How to add the full value of two buttons (any key) VI and display it in the output text box? I am attaching a sample program, but I know that his evil... Help, please

    Try this

  • How to add the quick launch of the desktop icon bar

    How to add the toolbar launch quick icon on the desktop. I can't find a desktop icon that will drag on

    The following Microsoft KB article

    http://support.Microsoft.com/kb/190355/en-us

    will help you.

    Good bye.

  • How to add the translation application to my email add FB?

    Original title: translation

    I need to know how to ADD the TRANSLATION software to my email add FB? Any help?

    Try here: https://www.facebook.com/help/100117036792266

    Translate the updated Facebook application on the road

  • How to add the Quazip library

    Hi, I want to try to use Quazip. Since I read, I have to add the library before use.

    I downloaded from http://quazip.sourceforge.net/

    How to add the Quazip library? Please explain the step, never add lib before.

    Thank you

    I have change the .pro file

    Like this:

    http://StackOverflow.com/questions/13341234/unzip-files-downloaded-from-Server

  • How to add the profile of lenses?

    How to add the profile of lenses?

    At the bottom of the link, you will find a link for the lens profile downloader. With this tool, you can download the profiles shared by other users.

    Work with lenses profiles in Adobe Photoshop, Lightroom and Camera Raw

  • How to add the new column in existing table to our desired location?

    How to add the new column in existing table to our desired location?

    For example, I have to add the new column 'course' before the salary column in the emp table.

    I think the best way is to add the column at the end of the table and create a new view with the order of the columns...

    Another option...

    places the data into a temporary table and recreate the table with the correct order of the columns, and then insert data to the table from the temporary table

    Refer

    Add column (from table) in the desired position

    Example:

    CREATE TABLE temp_my_user LIKE)

    SELECT * FROM password);

    DROP TABLE password;

    (Password) CREATE TABLE

    userID NUMBER

    , first name VARCAHR2 (25)

    , middleInitial VARCHAR2 (1)

    (, name VARCHAR2 (25));

    INSERT INTO password (userID, firstName, lastName)

    (SELECT username

    first name

    lastName

    OF temp_my_user);

    DROP TABLE temp_user;

  • How to add the bar at the bottom of the page [Dreamweaver]

    Hello!

    How to add the bar at the bottom of the page that helps me to make changes in my creation page?

    Not sure I understand.  Looking for the properties panel?  Press Ctrl + F3 or go to window > properties.

    Nancy O.

  • Please tell me how to add the English language in photoshop?

    Hello! Please tell me How to add the English language in photoshop? I'm from Russia and acquired, respectively, also in Russia()

    Cloud of swap language http://helpx.adobe.com/creative-cloud/kb/change-installed-language.html

    or

    A product of Adobe for another language or version of trading platform for CS6

  • How to add the date felxfiled in OFA

    How to add the date felxfiled in OFA

    Hi gurus,

    How to add a date in the form OFA field. I tried but no optin schedule it. I need to add the calendar options before the flexfiled.

    Concerning

    Hello

    Allocate FND_STANDARD_DATE segment value your FDF everywhere where you want to see the calendar on the page of the OFA.

    Let me know if you need more help on this.

    Kind regards

    Hemant

  • How to add the collapsible functionality to the Spry Menu?

    Dear Adobe community,

    How to add the functionality of collapsible for the Spry Menu like the one on the White House | whitehouse.gov ?

    Load the White House Web site and minimize your browser window as observe you what happends to the menu bar when you pass a certain limit.

    This is the feature that I want to put in place and I would be happy if one of you could direct me to or share relevant information.

    Concerning

    Andreas

    This isn't a menu Spry Spry do not appear on mobile devices.

    Use any sensitive menu you like for example:

    CSS & jQuery Mobile Navigation Menu Demo

    The tutorial is here:

    CSS and jQuery Menu of Navigation Mobile reactive

  • How to add the form designed in adobe acrobat pro live cycle Designer?

    How to add the form designed in adobe acrobat pro live cycle Designer?

    I want to add the form designed in adobe acrobat pro live cycle Designer. I saved the form designed in adobe live cycle designer in pdf format. But you can't change the same in Adobe Acrobat format. I would like to add a few fields and use the fields designed by Adobe Live cycle Designer.

    You can only modify this form in LiveCycle Designer. Forms Acrobat and LCD are not interchangeable.

  • How to add the blank page to existing Document in Adobe Dc

    How to add the blank page to existing Document in Adobe Dc Pro

    Hi thashrifs16749461,

    You can add a blank page using Adobe Acrobat DC by following the instructions below:-

    (1) open your PDF in Acrobat DC.

    (2) choose the form of option "Organize the Page" of the tool pane on the right as shown below in the screen shoot.

    (3) now, at the top, you will see all the tools to organize the page, click "Insert" & select 'White Page' in the drop down menu to insert blank pages.

    * Shortcut: If you are using a windows computer you can use the key "Shift + Ctrl + T" to insert blank pages.

    In case if you have any problem or have any questions please let us know. We will be happy to help you.

    Kind regards

    Nicos

Maybe you are looking for

  • Import a txt in figures

    I have a txt file with a lot of data in what I want to analyze by number. How can I import it. I can change it to a file cvs by using find and replace, then changing the extension of the file, but that imports all the data as a single column. Is ther

  • Skype messages are not fall properly

    I have had this problem since I decided to update my Skype yesterday with a bunch of my friends. I am extremely frustrated since I've tried everything, even raising the solution online and can't find literally any form of solution to the problem. My

  • Portege 2010 does not start-&gt; white screen

    Hello I need help because my 2010 does not start. When I press the power button, the power light turns on but I get nothing on the screen. He worked when my brother used it until the mouse has frozen and then turns off. He then lit it back in which c

  • laptop battery indicator always flashes

    Hello Why did the laptop battery indicator is always green / orange flashing? is there any solution outside the battery failure? Thank you Lanzartel

  • I can't activate Microsoft Word with a missing product key.

    I bought a second hand laptop and I can not activate Micrsoft Word 2007 with a missing product key (laptop don't have the program cd with it when I bought it). Tried to activate it online. Any kind of help would be appericated.