How to join two pl/sql tables .,.,,Urgent pls help

Hi,
Please tell me how to join to pl/sql tables with example
thanks
asp

If your main intention is to get the common records/or getting whole records from the 2 different pl/sql arrays then , pls check this piece of code & explanation
The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.
Let's take a look at some of the syntax needed to do this, starting with UNION.
First, I create a schema-level nested table type:
CREATE OR REPLACE TYPE strings_nt
IS TABLE OF VARCHAR2(100);
Then I define a package and within it create and populate two nested tables of this type, each containing some of my father's and my favorite things:
CREATE OR REPLACE PACKAGE favorites_pkg
IS
my_favorites strings_nt
:= strings_nt ('CHOCOLATE'
, 'BRUSSEL SPROUTS'
, 'SPIDER ROLL'
dad_favorites strings_nt
:= strings_nt ('PICKLED HERRING
, 'POTATOES'
, 'PASTRAMI'
, 'CHOCOLATE'
PROCEDURE show_favorites (
title_in IN VARCHAR2
, favs_in IN strings_nt
END;
In this package, I also include a procedure to show the contents of a strings_nt nested table. This will come in very handy shortly.
By defining these collections in a package, outside any program, they persist (they maintain their state and values) for the duration of my session or until I change or delete them. This means that I can now write programs outside the package to manipulate the contents of those collections.
Note that this package has been simplified for the purposes of presenting collection functionality. In a production application, you should always take care to "hide" your package data, as with these collections, in the package body, and then provide procedures and functions to manage the data.
Suppose, for example, that I would like to combine these two collections into a single collection of our favorites. Prior to Oracle Database 10g, I would have to write a loop that transfers the contents of one collection to another. Now, I can rely on the MULTISET UNION operator, as shown below:
DECLARE
our_favorites
strings_nt := strings_nt ();
BEGIN
our_favorites :=
favorites_pkg.my_favorites
MULTISET UNION ---- Use INTERSECT , if you want to know common records
favorites_pkg.dad_favorites;
favorites_pkg.show_favorites (
'ME then DAD', our_favorites);
END;
The output from this script is:
ME then DAD
1 = CHOCOLATE
2 = BRUSSEL SPROUTS
3 = SPIDER ROLL
4 = PICKLED HERRING
5 = POTATOES
6 = PASTRAMI
7 = CHOCOLATE
------------------------------

Similar Messages

  • How to Join two diff pl/sql table  ???

    i have three queries
    1.One Query returns office and city
    2.Second Query return City - State
    3.Third Query returns State and Sub region
    I use three cursors and i want the output as Office -City -State -Sub region
    city is the joining for 1 and 2
    state is the joining for 2 and 3
    I am thinking of putting into pl/sql table .if it is okay tell me by giving how u will join the two pl/sql tables and if there is any other way kindly let me know .It is urgernt and please give me the code logic so that i can proceed

    First thing why are you using cursors? You can do it
    using SQL.Agreed, it can all be specified in a single SQL statement.
    Secondly I don't think there is some as Pl/Sql TableThere used to be something called a PL/SQL Table, but these have now, thankfully, been renamed to Associative Arrays, because that is what they are, Arrays, not tables. You can't treat Assoc. Arrays as database tables so you can't do Joins in the same way as you would with an SQL statement. To implement a join using arrays would require some (possibly recursive) loops to process each of the arrays to get the required data. This would of course be a lot slower than just using SQL on database tables.
    ;)

  • How to join two internal table rows in alternative manner into one internal table?

    How to join two internal table rows in alternative manner into one internal table?
    two internal tables are suppose itab1 &  itab2 & its data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    d
    e
    f
    g
    h
    i
    Header 1
    Header 2
    Header 3
    1
    2
    3
    4
    5
    6
    7
    8
    9
    INTO itab3 data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    1
    2
    3
    d
    e
    f
    4
    5
    6
    g
    h
    i
    7
    8
    9

    Hi Soubhik,
    I have added two additional columns for each internal table.
    Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
    Row_Count  - It represents the Row Count Number, increase the row count value 1 by one..
    ITAB1:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    a
    b
    c
    1
    1
    d
    e
    f
    1
    2
    g
    h
    i
    1
    3
    ITAB2:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    1
    2
    3
    2
    1
    4
    5
    6
    2
    2
    7
    8
    9
    2
    3
    Create the Final Internal table as same as the ITAB1/ITAB2 structure.
    "Data Declarations
    DATA: IT_FINAL LIKE TABLE OF ITAB1.          "Final Internal Table
    FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1,     "TAB1
                                   <FS_TAB2> TYPE TY_TAB2.     "TAB2
    "Assign the values for the additional two column for ITAB1
    LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
         <FS_TAB1>-TABLE_COUNT = 1.             "Table value same for all row
         <FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
    ENDLOOP.
    "Assign the values for the additional two column for ITAB2
    LOOP AT ITAB2 ASSIGNING <FS_TAB2>.    
         <FS_TAB2>-TABLE_COUNT = 2.                  "Table value same for all row
         <FS_TAB2>-ROW_COUNT = SY-TABIX.      "Index value
    ENDLOOP.
    "Copy the First Internal Table 'ITAB1' to Final Table
    IT_FINAL[] = ITAB1[].
    "Copy the Second Internal Table 'ITAB2' to Final Table
    APPEND IT
    LOOP AT ITAB2 INTO WA_TAB2.
    APPEND WA_TAB2 TO IT_FINAL.
    ENDLOOP.
    "Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
    SORT IT_FINAL BY  ROW_COUNT TABLE_COUNT.
    After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
    Regards
    Rajkumar Narasimman

  • How to join two tables

    hi
    how to join two tables using inner join  if the first table has two primary keys and second table has 3 primary keys

    Would describe type of joins in ABAP, which might differ with other joins.
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of INNER JOIN or LEFT OUTER JOIN. Depending on the type of join, a join expression can be either an inner (INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following additions not be used: NOT, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Note
    If the same column name occurs in several database tables in a join expression, they have to be identified in all remaining additions of the SELECT statement by using the column selector ~.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.

  • Is it possible to show data from two different sql tables?

    Is it possible to show data from two different sql tables? Either to show combined data by using a join on a foreign key or showing a typical master detail view?
    I have one table With data about a house, and another table With URL's to images in the blob. Could these two be combined in the same Gallery?
    Best regards Terje F - Norway

    Hi Terje,
    If you have a unique key, you could use one of the following functions for your scenarios:
    If you only have one image per house, you can use LookUp:
    http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745501
    If you have multiple images per house, you can use Filter:
    http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745487
    Thanks
    Robin

  • How to join two ITAB

    Hai
             i have created an program using ALV and i had created two internal tables namely ITAB and ITAB1.But i wasn't unable to get an output.so i like to know how to join two ITAB in ALV.

    MAhesh,
    Check this ex:
    ITAB1 is having fields  "A","B", "C".
    ITAB2 is having fields  "A","D", "E".
    Create i_final internal table to have all fields of 2 internal tables.
    i_final is having "A","B","C","D","E".
    SORT itab1 ,itab2 by A
    LOOP AT ITAB1.
      READ TABLE itab2 WITH KEY a = itab1-a BINARY
                                                                  SEARCH.
       IF SY-SUBRC EQ 0.
         MOVE : itab1-a  TO i_final-a,
                      itab1-b  TO i_final-b,
                      itab1-c  TO i_final-c,
                      itab2-d  TO i_final-d,
                      itab2-e  TO i_final-e.
        APPEND i_final.
       ENDIF.
    ENDLOOP.
    Don't forget to reward if useful.....

  • How to join two similar layers together?

    Hey all! Please help me out, It is a little thing to do, but I am really stocked at this. How to join two layers together?? For example two Text layers or anything. Pleas can you describe the way to do it and write (if it exist) the shortcut for it?
    Now I know, that layers in AAF can't be joined, there is just a "Pre-Compose". But this function is disabled the FX colone, and I have to have it there.
    In this tut http://www.videocopilot.net/tutorials/shatterize/ he joined two text layers. But with some shortcut so I don't know, how he did it.
    Can anyone help me plz?
    THX for reply

    Lufty09 wrote:
    Yes, but this is disabled the Fx button :/
    Now you need to look up precomposing in the help system. It's all explained there.
    Nesting and precomping are advanced functions and require careful planning or inspired improvisation within the limits of the software. You also need to look up how the rasterization button works in its two operation modes.
    bogiesan

  • How to join two open endpoints?

    How to join two open endpoints?
    I keep getting this error message even though the endpoints do not have this: "To join, you must select two open endpoints. If they are not the same path, they cannot be on text paths nor inside graphs, and if both of them are grouped, they must be in the same group."
    I've ungrouped everything.
    I've tried using the pen tool to manually join.
    I've moved the endpoint, then tried joining them.
    I've tried command+J.
    Same message everytime.
    And if I use the Pathfinder, I'll get unwanted results (i.e. a new path going right though the art)
    What's going on!?

    blueribb,
    While uploading an AI file is unsorted, you may consider at least one option:
    One is that you have at least one hidden extra Anchor Point, either on one of the paths or as stray or belonging to a third path.
    You may find out by:
    1) Using the Direct Selection Tool to click, not drag over, both end Anchor Point and then Cmd+J, and/or
    2) Using the Direct Selection Tool to click, not drag over, each end Anchor Point by itself and then move it a bit.

  • How to join two distribution rule together in one distribution rule

    how to join two distribution rule together in one distribution rule,and every dist. rule has many cost center.

    Hi,
    Welcome you post on the forum.
    You can create a new rule to include these two rules.
    Thanks,
    Gordon

  • How to import XML into SQL Table

    Dear all,
    There are a lot of books about exporting data into XML format.
    Actually, how to use XML Documents? Sorry I am new that I ask such a question.
    What i think may be exchange or save data using xml. If so, How to import into MS SQL table? Do it need to do any mapping?
    Appreciate for your hints

    Are you sure you want to use XML with tables for this? No doubt importing XML into tables is useful for some specialized tasks, such as importing formatting information inside the XML itself, but for most of the familiar tasks that XML excels at, tables are neither necessary nor useful.
    In my (limited) experience, if the XML elements are well-differentiated, by which I mean different types of data have their own distinctive tags, then the special powers of XML can be exploited more fully using the more familiar tagged text, nested tags etc. in ordinary text frames using paragraph breaks, tab characters, etc. to achieve a suitably "tabular" finished appearance.
    If you must import XML into tables, I recommend Adobe's own PDF "Adobe InDesign CS3 and XML: A Technical Reference" availabe here:
    http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf
    It sounds very daunting -- the words "technical reference" make me shudder -- but actually it's very readable and not very technical at all. Some nice pics and everything!
    Jeremy

  • Global_attribute20 field in ap_payment_schedules_all table - Urgent Pls

    All,
    Version: 11.5.10.2
    I created an invoice, from the 'Scheduled Payments' tab I checked the 'Hold' flag. After the flag is checked in the UI, I noticed the global_attribute20 field in the ap_payment_schedules_all updates to 'EP' along with the hold_flag='Y'. I want to know the significance of global_attribute20 and what are all the other possible values of this field like 'EP'??
    this is quite urgent, pls help.
    rgds
    sen

    Have you tried to enable trace on this form to find out how this column gets populated?
    FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12 [ID 296559.1] -- 3. How does one enable trace in the Oracle Application screens / forms?
    Can you reproduce the issue with other invoices?
    Do you have any other instance where you can try the same and see if the issue is reproducible?
    Thanks,
    Hussein

  • Select statement- very urgent pls help

    hi
    i want to extract following fields into one internal table.
    anyone pls help me to do this?
      mara-mandt, mara-matnr, mara-meins, mara-laeda, mara-aenam, marc-werks, makt-maktx, sy-datum, sy-uzeit, sy-uname
    Thanks
    Kumar

    Hi Kumar K,
    TABLES: MARA, MARC, MAKT.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    PARAMETERS : P_WERKS LIKE MARC-WERKS  OBLIGATORY.
    DATA :      BEGIN OF WA_FINAL,
         MANDT LIKE MARA-MANDT,
         MATNR LIKE MARA-MATNR,
         MEINS LIKE MARA-MEINS,
         LAEDA LIKE MARA-LAEDA,
         AENAM LIKE MARA-AENAM,
         WERKS LIKE MARC-WERKS,
         MAKTX LIKE MAKT-MAKTX,
    DATE TYPE SY-DATUM,
    TIME TYPE SY-UZEIT,
    UNAME TYPE SY-UNAME,
         END OF WA_FINAL,
         BEGIN OF WA_MARA,
         MANDT LIKE MARA-MANDT,
         MATNR LIKE MARA-MATNR,
         MEINS LIKE MARA-MEINS,
         LAEDA LIKE MARA-LAEDA,
         AENAM LIKE MARA-AENAM,
         END OF WA_MARA,
         BEGIN OF WA_MAKT,
         MATNR LIKE MAKT-MATNR,
         MAKTX LIKE MAKT-MAKTX,
         END OF WA_MAKT,
         BEGIN OF WA_MARC,
         MATNR LIKE MARC-MATNR,
         WERKS LIKE MARC-WERKS,
         END OF WA_MARC.
    DATA : IT_MARA LIKE STANDARD TABLE OF WA_MARA WITH HEADER LINE,
    IT_FINAL LIKE STANDARD TABLE OF WA_FINAL WITH HEADER LINE,
    IT_MAKT LIKE STANDARD TABLE OF WA_MAKT WITH HEADER LINE,
    IT_MARC LIKE STANDARD TABLE OF WA_MARC WITH HEADER LINE.
    SELECT   MANDT
         MATNR
         MEINS
         LAEDA
         AENAM
    FROM MARA
    INTO TABLE IT_MARA
    WHERE MATNR IN S_MATNR.
    IF IT_MARA[] IS NOT INITIAL.
    SELECT MATNR
    WERKS
    FROM MARC
    INTO TABLE IT_MARC
    FOR ALL ENTRIES IN IT_MARA
    WHERE MATNR = IT_MARA-MATNR
    AND WERKS = P_WERKS.
    ENDIF.
    IF IT_MARA[] IS NOT INITIAL.
    SELECT MATNR
                 MAKTX
    FROM MAKT
    INTO TABLE IT_MAKT
    FOR ALL ENTRIES IN IT_MARA
    WHERE MATNR = IT_MARA-MATNR.
    ENDIF.
    LOOP AT IT_MARA.
    IT_FINAL-MANDT = IT_MARA-MANDT.
    IT_FINAL-MATNR = IT_MARA-MATNR.
    IT_FINAL-MEINS = IT_MARA-MEINS.
    IT_FINAL-LAEDA = IT_MARA-LAEDA.
    IT_FINAL-AENAM = IT_MARA-AENAM.
    READ TABLE IT_MARC WITH KEY MATNR = IT_MARA-MATNR.
    IF SY-SUBRC = 0.
    IT_FINAL-WERKS = IT_MARC-WERKS.
    ENDIF.
    READ TABLE IT_MAKT WITH KEY MATNR = IT_MARA-MATNR.
    IF SY-SUBRC = 0.
    IT_FINAL-MAKTX = IT_MAKT-MAKTX.
    ENDIF.
    IT_FINAL-DATE = SY-DATUM.
    IT_FINAL-TIME = SY-UZEIT.
    IT_FINAL-UNAME = SY-UNAME.
    APPEND IT_FINAL.
    CLEAR : IT_FINAL, IT_MARA , IT_MAKT, IT_MARC.
    ENDLOOP.
    now IT_FINAL table contains the final data which you want...
    Hope it will solve your problem
    Reward points if useful...
    Thanks & Regards
    ilesh 24x7

  • Why is my powerpoint not working 10.9? i can't play my existing file and new files that i work..? how to fix that one..? pls help..!

    why is my powerpoint not working 10.9? i can't play my existing file and new files that i work..? how to fix that one..? pls help..!

    R Cubss,
    You might want to read down this thread. There are a lot of tips-n-tricks, and maybe one will be right for you.
    http://www.adobeforums.com/webx/.59b6565c/43
    Good luck,
    Hunt

  • How to join two tables using EJB-QL

    Hi There,
    How to join tables using EJB-QL ?
    Thanks.
    Edited by: vamseebobby on Nov 6, 2007 8:12 AM

    You might try
    SELECT b.entity2property FROM Entity1 a JOIN a.entity2 b
    for example, to retrieve players names, from a Players table, that belong to the team 'My Team' in the Teams table
    SELECT b.playerName FROM Teams a JOIN a.players b WHERE a.teamName = 'My Team'

  • [HOW TO] comare 2 PL/SQL tables

    I want to compare 2 PL/SQL tables, something like this pseudo code:
    TYPE type_tbl IS TABLE OF table123%ROWTYPE
    INDEX BY BINARY_INTEGER;
    test1 type_tbl;
    test2 type_tbl;
    BEGIN
    insert a couple rows into each table
    IF test1 = test2 then EQUAL!
    ELSE NOT EQUAL
    END IF
    Based on this link I would think it's possible in 10g but I get a compile time error on the IF statement.
    [http://www.oracle.com/technology/oramag/oracle/03-sep/o53plsql.html]
    I understand that I could write my own Equal function but I it looks like it should be built in functionality.
    Thanks in advance for the help!

    Here is how it's going to be used: 2 separate developers are going to write code, each will create an in memory table, call them table1 and table2. These two tables then need to be compared against each other to see if every row and every column are identical. If they are equal we will take the data from one of the in memory tables and write that data to a physical table.
    If the 2 in memory tables are not equal then we want to abort and throw an error.

Maybe you are looking for

  • How do I change the page it goes to win opening a new tab?

    Okay. So I recently downloaded something that made my new tab into a Bing thing. That's not very descriptive, so... Basically when I used to open a tab, it would just be a blank, white page. But after downloading Gimp 2, an editing software, it also

  • ADF faces tables - range navigation table footer

    Hi, I have a strage situation using ADF Faces' table, sometimes it displays range navigation on top and bottom of the table and sometimes only on top of the table. Is it possible to show always the range navigation on top and bottom of the table? How

  • HT4235 Having trouble syncing itunes playlist to ipod

    I am having trouble syncing my itunes playlist to the ipod touch. When I connect the ipod to the computer and open itunes, the ipod shows that it is in the sync process. However, the playlist does not show up. The Diagnostic Test shows "no ipod found

  • TLS/SSL in Contribute CS 5?

    There seems to be a disconnect between the FTP protocols used by Dreamweaver and Contribute. I just downloaded the DM CS5.5 to see if it would work with FTP over SSL/TLS and it does. However when you try to connect using Contribute, all you get is an

  • Error message when emptying trash

    Hello, I am trying to empty Video TS and and Audio TS folders from Trash but I keep getting this error message "noAskRightPermissionTitlePur". So I click okay and the files aren't deleted. Any idea on what I can do to empty the trash? Nothing came up