Type of Source of type MULTISET

UPDATE CUSTOMERS_DEMO cd
  SET cust_address_ntab = 
    CAST(MULTISET(SELECT cust_address
                    FROM customers c
                    WHERE c.customer_id =
                          cd.customer_id) as cust_address_tab_typ);
What is the source of the above CAST function type? TX.
So, if the cust_address is of NUMBER type then the MULTISET expression IS NUMBER TYPE as well?

No,
Since this is a multiset, there will be a collection of number.

See:
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions016.htm

for samples

Kind regards

Published by: Peter vd Zwan on June 14, 2012 02:58

Tags: Database

Similar Questions

  • Can we use type multiset and with the clause the two

    Please let me know how to use the multiset type and with the clause.

    You need more inlining, as for example in:

    SQL> select *
    from table (cast (multiset (select *
                                from (with t as (select deptno from dept)
                                      select * from t)) as sys.dbms_debug_vc2coll))
    /
    COLUMN_VALUE
    ----------------------------------------
    10
    20
    30
    40
    50                                      
    
    5 rows selected.
    
  • type multiset operators

    I'm trying to follow an example to
    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/operators006.htm

    but it does not work, and I'm not able to understand why. the code is:
    SQL> CREATE TABLE customers_demo AS
      2    SELECT * FROM customers;
    
    Tabella creata.
    SQL> CREATE TYPE cust_address_tab_typ AS
      2    TABLE OF cust_address_typ;
      3  /
    "Interim: tipo creato con if di registration" which means WARNING: type created with compilation error
    SQL> ALTER TABLE customers_demo
      2    ADD (cust_address_ntab cust_address_tab_typ,
      3         cust_address2_ntab cust_address_tab_typ)
      4      NESTED TABLE cust_address_ntab STORE AS cust_address_ntab_store
      5      NESTED TABLE cust_address2_ntab STORE AS cust_address2_ntab_store;
      ADD (cust_address_ntab cust_address_tab_typ,
                                         *
    ERRORE alla riga 2:
    ORA-00902: tipo di dati non valido
    Why in this case, cust_address_tab_typ is a defined collection.

    Thank you
    F.

    francy77 wrote:
    but it does not work, and I'm not able to understand why. the code is:

    SQL > CREATE TYPE cust_address_tab_typ AS
    2 THE cust_address_typTABLE;
    3.

    WARNING: type created with compilation error

    You didn t create cust_address_typ TYPE:
    (It does not appear in the original example.)

    CREATE TYPE cust_address_typ
      AS OBJECT
        ( street_address     VARCHAR2(40)
        , postal_code        VARCHAR2(10)
        , city               VARCHAR2(30)
        , state_province     VARCHAR2(10)
        , country_id         CHAR(2)
        );
    
  • question of type multiset

    Hello

    How do you find many lines in multiset if the multiset is a column in a table?
    customer information table
    CUSTOMER_ID, multiset of (customer addresses i.e. several office locations)

    How can I get information on customers who have more than 5 address?

    Thank you

    multiset is used in conjunction with a dominant to map a subquery to a collection.
    If you have a multiset in a column, you have a nested table or varray column, Yes?

    If so, you should be able to use the CARDINALITY function to return the number of items in your collection/multiset.

    select 'Customer '||customer||' has '||cardinality(my_multiset)|' addresses' from my_table;
    
  • bitmaps multiset - how to make part of a bitmap

    Hi all.

    Does anyone know how can I copy a portion of a bitmap?

    BB is already doing. You can see if you look at plazmic resources Kit.

    For example, wireless power indicator is a file of type multiset png, and when the force is changed, a different part of a larger bitmap (mulitset) is displayed.

    I tried to do something like that, but a problem to convert a PNG to a byte [] (as can be seen on some forum discussions, this is not very intuitive)

    Currently, I'm stuck with the approach of the png by loading InputStreamReader.

    But wouldn't be easier to reuse the (already loaded) Bitmap and simply copy the requested part?

    Someone at - it look more deep on this?

    I don't know if I quite understand what you mean, but you can use

    public void drawBitmap(int x,
                           int y,
                           int width,
                           int height,
                           Bitmap bitmap,
                           int left,
                           int top)
    

    In this case, your bitmap image would be the image of large ensemble, and you would use the width, height, left and top to paint only the part of the bitmap you want.

  • See Multiset Union value of slider

    Hello world

    I'm new to the concept of pseudo functiona and was just trying to use the union of type multiset. I wrote a slider that gives me a 'buyer' column and a dataset. Now my dilemma is how to access the elements in the dataset using the slider. Could someone please help?
    CREATE TABLE BUYER
    (
      BUYER        NUMBER(4)                        NOT NULL,
      BUYER_NAME   VARCHAR2(120 BYTE)               NOT NULL,
      BUYER_PHONE  VARCHAR2(20 BYTE),
      BUYER_FAX    VARCHAR2(20 BYTE)
    );
    
    SET DEFINE OFF;
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
     Values
       (110, 'Kendr', '5147, 876', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
     Values
       (101, 'Amelie Dube', '(514),808', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
     Values
       (102, 'Jennifer Baie', '51962,860', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
     Values
       (103, 'Loriannstris', '5333962,785', NULL);
    Insert into RMS.BUYER
       (BUYER, BUYER_NAME, BUYER_PHONE, BUYER_FAX)
     Values
       (104, 'Sandra St-re', '513962,736', NULL);
    
    COMMIT;
    --------------------------------------------------------------------------------------------------------------
    create or replace type tab1 is table of varchar2 (30);     
    --------------------------------------------------------------------------------------------------------------      
    DECLARE
    cursor c1 is
    select buyer,
          CAST (multiset(select buyer_name from buyer where rownum<4) as tab1) as data1
          from buyer 
    MULTISET UNION ALL
    select  buyer,
              CAST(multiset(select buyer_name from buyer where rownum<5) as tab1) as data2
    from buyer;
    
    BEGIN
      for c_rec in c1
        loop
          DBMS_OUTPUT.PUT_LINE(c_rec.buyer||'~'||c_rec.column_value(1)); --  i want to print all the values in the 'data set' along with the buyer id.
       end loop;
    end;
    
    error:
    PLS-00302: component 'COLUMN_VALUE' must be declared

    >
    PLS-00302: component 'COLUMN_VALUE' must be declared.
    >
    Do you see something named 'column_value' in your queries? It works

    DECLARE
    cursor c1 is
    select buyer,
          CAST (multiset(select buyer_name from buyer where rownum<4) as tab1) as data1
          from buyer
    MULTISET UNION ALL
    select  buyer,
              CAST(multiset(select buyer_name from buyer where rownum<5) as tab1) as data2
    from buyer;
    
    BEGIN
      for c_rec in c1
        loop
          DBMS_OUTPUT.PUT_LINE(c_rec.buyer||'~'||c_rec.data1(1));
        end loop;
    end;
    
  • Select with LESS vs two VARRAYS with MULTISET

    Hi all

    I just wanted to know, which one of the two following is faster and results in better performance.

    1. SELECT statement containing 200 + columns in a Table with operator LESS. (TWO SELECTS with operator between them LESS)

    2. loading of the individual SELECT statement (with some LESS) result sets in two different VARRAYS and then use these two operators of type MULTISET.

    That one is faster and uses less memeory?

    Thank you
    REDA

    Direct SQL is still fast compared to the PLSQL. When you use varrays, there will be change of context. Even if you use Bulk collect for loading data yu have to put a limit of 1000 and not beyond.

  • How to make SQL * more count the comment and blank line numbers?

    Hello

    Parameter
    Value of the parameter
    Oracle versionEnterprise Edition Release 11.2.0.1.0 - 64 bit
    OPERATING SYSTEMLinux Fedora Core 17 (X86_64)

    I would like to know, is it possible to force SQL * Plus to provide the number of the current in the source file line whenever there is an error? I often put in the first line of my script SQLBLANKLINES the VALUE ON that I may be able to put several consecutive blank lines in my code (I do that sometimes, when I find that it is appropriate to make my code more readable or a sequence of instructions which I believe make their logic more comprehensible for the reader of the Group)

    Now the problem is that SQL * Plus will ignore these empty lines and whenever there is an error, the line number in the error message does not match the actual line number in the source file, but it seems to be the last non-empty line in the file.  Consider the following example:

    SET SQLBLANKLINES ON;

    DECLARE
        var PLS_INTEGER := 10;
    BEGIN


       
        var := 20
    END;
    /

    In the code above on line 9 (also counting blank lines), there is an error (no semicolon at the end of the var: = 20) but when I run the script

    SQL * also, here is the error message I get


    SQL > @myscript.sql;

    END;

    *

    ERROR on line 8:

    ORA-06550: line 8, column 1:

    PLS-00103: encountered the symbol "END" when expected in the following way:

    * & = - + ; <>/ is mod remains not rem

    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or

    like4 likec between | submultiset of type multiset Member

    The symbol ';' was replaced by 'END' continue.


    SQL >


    As you can see the error message indicates that the error was found on line 8, while in the file, it's really on line 9

    As long as the number of lines in the script is limited, this may not be a problem and we can quickly find the actual line number in the code that causes the error, but for a code, including hundreds (or even thousands) of lines and with many comments and blank lines, find line number given by SQL * error message more becomes complicated.

    So my question: is it possible to make SQ * more properly draw the line numbers, as they appear in the source file?

    Thanks in advance,

    Kind regards

    Dariyoosh

    Hi, Dariyoosh,

    The line numbers in error messages are always from the beginning of the statement, but not the file.  The back-end which checks the errors and generates the error message, has no idea if this statement has appeared in your file, even if the statement was in a file at all, or if it comes from multiple files, each with its own line 1.

    You can divide your scripts into parts, so that the long statements, which may lead to error messages, are each in a separate file, so the statement starts on the line 1 of the file.

    For example, you can call a script called fubar.sql, which looks like this:

    SET SQLBLANKLINES ON;
    
    @@fubar_1
    

    Which calls another script, called fubar_1.sql, located on the same directory as fubar.sql, that looks like this

    DECLARE
        var PLS_INTEGER := 10;
    BEGIN
    
        var := 20
    END;
    /
    

    You never call him directly fubar_1.

  • Error export/import of the application to the Apex 4.1 on ORACLE 11 g 2 XE

    We have an ApEx application, what is migrated several ApEx 3 times through 3.2 to 4.1.
    There is no problem import/export demand, when we use ORACE 11 GR 2 (SE or EE).

    A few days go that put us the application on a database of the XE 11 GR 2. There was no significant or problems by running.

    Now, we have changed something and wanted to export the aplication of the database of XE and back to a different database.
    Importing (no questions about the origin of the XE) application or any other edition, we get an error:

    p_region_id = > 83466451 p_form_element_id = > null,

    *+
    ERROR on line 7:
    ORA-06550: line 7, column 26:
    PLS-00103: encountered the symbol "P_FORM_ELEMENT_ID" when awaits an of the
    Next:
    +), * & = - + <>/ at mod is rest not rem +.
    + < an exponent (*) > <>or! = or ~ = > = < = <>and or as like2 +.
    like4 likec between | submultiset of type multiset Member
    Symbol ',' was replaced by 'P_FORM_ELEMENT_ID' to.

    Looking at the source, I found:

    declare
    s varchar2 (32767): = null;
    Start
    s: = null;
    () wwv_flow_api.create_report_columns
    P_ID = > 83576346930344697 wwv_flow_api.g_id_offset, +.
    p_region_id = > 83466451 # p_form_element_id = > null,
    p_column_alias = > 'APP_USER2 ',.
    p_column_display_sequence = > 2,
    p_column_heading = > 'Benutzer ',.
    +...+

    It is absent from the code in the place where I put the #.

    Does anyone has an idea, what's not to export?

    We use a GR 11, 2 on OpenSUSE 12.1 Apex 4.1.0 ORACLE XE. The export file is about 2 MB.

    Thanks for your help
    Tilman

    If you are still able to access the original (where you got the export)

    try to export on the command-line as well... http://ruepprich.wordpress.com/2011/07/15/Exporting-an-apex-application-via-Command-Line/

    Kind regards
    Richard
    -----
    blog: http://blog.warp11.nl
    Twitter: @rhjmartens
    If you answer this question, please mark the thread as closed and give points where won...

  • Armi code cannot


    Hi all

    I was PL/SQL challenge question https://plsqlchallenge.oracle.com/pls/apex/f?p=10000:23:112798514303414:NO: but unable to understand a few line of code, I appreciate if someone help out me. Thank you

    drop table plch_ingredients;
    /
    DROP TABLE plch_recipes;
    /

    create table plch_recipes)
    primary key of the entire recipe_id
    , recipe_name varchar2 (20) not null
    )
    /

    create table plch_ingredients)
    recipe_id integer not null
    Reference plch_recipes (recipe_id)
    , varchar2 (20) ingredient non-null
    unique (recipe_id, ingredient)
    )
    /
    insert into plch_recipes values (100, 'Cookies')
    /
    insert into plch_recipes values (200, "Brownies")
    /
    insert into plch_recipes values (300, "pancakes")
    /

    insert into plch_ingredients values (100, 'Chocolate')
    /
    insert into plch_ingredients values (100, 'eggs')
    /
    insert into plch_ingredients values (100, 'flour')
    /
    insert into plch_ingredients values (100, ' sugar')
    /
    insert into plch_ingredients values (100, 'butter')
    /

    insert into plch_ingredients values (200, "cocoa")
    /
    insert into plch_ingredients values (200, "flour")
    /
    insert into plch_ingredients values (200, ' sugar')
    /
    insert into plch_ingredients values (200, "butter")
    /

    insert into plch_ingredients values (300, "flour")
    /
    insert into plch_ingredients values (300, 'eggs')
    /
    insert into plch_ingredients values (300, 'milk')
    /

    Commit
    /
    CREATE TYPE plch_ingredients_type AS TABLE OF VARCHAR2 (20)
    /
    Select recipe.recipe_name
    , cast ( )
    MULTISET
    (
    Select ingredient.ingredient
    the ingredient plch_ingredients
    where ingredient.recipe_id = recipe.recipe_id
    order of ingredient.ingredient
    ) as plch_ingredients_type
    ) of the ingredients
    plch_recipes recipe
    ORDER BY recipe.recipe_name
    ;

    The query result

    RECIPE_NAME, INGREDIENTS

    "Brownie" JEN. PLCH_INGREDIENTS_TYPE ('Butter', 'Cocoa', 'Flour', 'Sugar')

    JEN cookies. PLCH_INGREDIENTS_TYPE ('Butter', 'Chocolate', 'Eggs', 'Flour', 'Sugar')

    JEN pancakes. PLCH_INGREDIENTS_TYPE ('Eggs', 'Flour', 'Milk')

    I don't know what the real purpose of melting and multiset in above query and really grateful if someone guide me. Thank you

    Concerning

    Matt

    A multiset is a kind of game, but allows an element to appear more than once.

    Value = {a, b}

    Multiset = {a, a, a, b, b}

    Your query in question receives a set of values of the query lines and put them in a single type which is being able to represent a multiset.  The command of type MULTISET did this...

    one

    b

    c-online {a, b, c, d, d, e}

    d

    d

    e

    Where {a, b, c, d, d, e} are the elements of the plch_ingredients_type.  The CASTING shows just the parser what type the multiset operator is making it in.

  • Statement of Pivot complex?

    Hi all

    I need to fix a bunch of code hack which consists of several union statements that I can count. All unions use the same table and where clauses.

    What we currently have, is something like:

    Select asset_id,

    cases where construction_date is null then 1 or 0 end as long as documents,.

    -case when construction_date is null then 'date invalid construction' as problem

    of asset_table

    UNION

    Select asset_id,

    When construction_date is null and that payment_date-case < sysdate-50 and 0 otherwise 1 end as long as documents,.

    When construction_date is null and that payment_date-case < sysdate-50 then 'paid but not built"as problem

    of asset_table

    So, as it looks that I went and did the following:

    Select asset_id,

    case when construction_date is null then 1 or 0 end as "date invalid construction."

    When construction_date is null and that payment_date-case < sysdate - 50 then 1 0 otherwise end as "paid but not built."

    of asset_table

    The issue I'm facing now, is that I have a few capital records that meet several conditions, i.e. they have no valid and paid construction dates but not built in a single resource row 1 (historically, there are 2 ranks - I need to have 2 rows to generate reports.)

    How can I go on making rotate this return all about give 2 + ranks when several conditions are met?

    Thank you so so so much!

    Several ways to address the issue, but the collections are a good approach.  With a collection you can add several controls you want, everything will be solved independently.

    CREATE or REPLACE type TY_NUMBERS as array of numbers

    /

    CREATE or REPLACE type TY_ARGUMENTS as table of varchar2 (32767)

    /

    with asset_table (asset_id, construction_date, payment_date) as)

    Select 1, null, sysdate-50 in all double union

    Select option 2, null, sysdate-52 Union double all the

    Select 3, null, sysdate-50 in all double union

    Select 4, null, sysdate-53 double

    ),

    qryValues as)

    Select asset_id,

    TY_NUMBERS (case when construction_date is null then 0 otherwise 1 end)

    where construction_date is null and payment_date< sysdate="" -50="" then="" 1="" else="" 0="" end)="" multiset="" except="" distinct="" ty_numbers(null)="" as="">

    TY_ARGUMENTS (case when construction_date is null then end 'date of the invalid construction',

    where construction_date is null and payment_date< sysdate="" -50="" then="" 'paid="" but="" not="" constructed'="" end)="" multiset="" except="" distinct="" ty_arguments(null)="" as="">

    of asset_table

    )

    Select asset_id, r.COLUMN_VALUE as a RECORD, p.COLUMN_VALUE as ISSUE

    of qryValues v

    Join table (v.records) r 1 = 1

    Join table (v.problems) p on 1 = 1

    ASSET_ID RECORD PROBLEM
    1 1 "invalid construction date.
    1 0 "invalid construction date.
    2 1 "invalid construction date.
    2 1 "paid but not built."
    3 1 "invalid construction date.
    3 0 "invalid construction date.
    4 1 "invalid construction date.
    4 1 "paid but not built."

    Note: Operators of type multiset in the query clear up collections after the resolution, you can change these as required. For example, multiset except TY_NUMBERS (null) separate = eliminates duplicates and nulls

  • Please help debug a PL/SQL

    Hello

    I try to use in bulk collect to change an old PL/SQL (runs, but runs slowly).

    -the original

    DECLARE
    CURSOR C_CURSOR IS SELECT * FROM MF_S224_RPT WHERE UIDY_LO IS NOT NULL AND PATN_LIST IS NOT NULL;
    V_DEF_DATA C_CURSOR % ROWTYPE;
    str_new_uidy_lo VARCHAR2 (255);

    CURSOR C_CURSOR_LN IS SELECT * FROM MF_S224_RPT_LN WHERE UIDY_LO IS NOT NULL;
    V_DEF_DATA_LN C_CURSOR_LN % ROWTYPE;
    str_new_uidy_lo_ln VARCHAR2 (255);

    BEGIN
    C_CURSOR OPEN;
    EXTRACT THE C_CURSOR IN V_DEF_DATA;
    C_CURSOR % LOOP WHILE
    str_new_uidy_lo: = (' & 6084 &'|) V_DEF_DATA. FISC_YEAR | ' &' | V_DEF_DATA. FISC_MNTH | ' &' | V_DEF_DATA. VR | ' &' | V_DEF_DATA. BENEFITS | ' &' | V_DEF_DATA. PATN_LIST | ' &' | V_DEF_DATA. (SLA);
    UPDATE T1 SET T1 MF_S224_RPT. UIDY_LO is str_new_uidy_lo WHERE T1. UIDY_LO = V_DEF_DATA. UIDY_LO;
    UPDATE T2 T2 SET MF_S224_RPT_LN. PRPT_ID_LO is str_new_uidy_lo WHERE T2. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;
    UPDATE MF_S224_RPT_ACT T5 T5 SET. PRPT_ID_LO is str_new_uidy_lo WHERE T5. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;
    EXTRACT THE C_CURSOR IN V_DEF_DATA;
    END LOOP;
    CLOSE C_CURSOR;

    C_CURSOR_LN OPEN;
    EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;
    C_CURSOR_LN % LOOP WHILE
    str_new_uidy_lo_ln: = ('& 6085' |) SUBSTR (V_DEF_DATA_LN. PRPT_ID_LO, 6). ' &' | V_DEF_DATA_LN. TSYM | ' &' | V_DEF_DATA_LN. GLAC | ' &' | V_DEF_DATA_LN. ACMP_YEAR | ' &' | V_DEF_DATA_LN. ACMP_MNTH | ' &' | V_DEF_DATA_LN. RCPT_DISB_IN | ' &' | V_DEF_DATA_LN. PATN);
    UPDATE MF_S224_RPT_LN SET T3 T3. UIDY_LO is str_new_uidy_lo_ln WHERE T3. UIDY_LO = V_DEF_DATA_LN. UIDY_LO;
    UPDATE MF_S224_RPT_ACT SET T4 T4. PRPT_LINE_ID_LO is str_new_uidy_lo_ln WHERE T4. PRPT_LINE_ID_LO = V_DEF_DATA_LN. UIDY_LO;
    EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;
    END LOOP;
    CLOSE C_CURSOR_LN;

    END;
    /

    -Change, to help collect in bulk

    DECLARE

    CURSOR C_CURSOR IS SELECT * FROM MF_S224_RPT WHERE UIDY_LO IS NOT NULL AND PATN_LIST IS NOT NULL;
    TYPE of c_arr1 IS the TABLE OF C_CURSOR % ROWTYPE;
    c_rows1 c_arr1;
    str_new_uidy_lo VARCHAR2 (500);

    CURSOR C_CURSOR_LN IS SELECT * FROM MF_S224_RPT_LN WHERE UIDY_LO IS NOT NULL;
    TYPE of c_arr2 IS the TABLE OF C_CURSOR_LN % ROWTYPE;
    c_rows2 c_arr2;
    str_new_uidy_lo_ln VARCHAR2 (500);


    BEGIN
    C_CURSOR OPEN;
    EXTRACT the C_CURSOR BULK COLLECT INTO c_rows1 LIMIT 2000;
    FORALL i IN c_rows1. FIRST... c_rows1. LAST
    str_new_uidy_lo: = (' & 6084 &'| c_rows1 (i).) FISC_YEAR | ' &' | c_rows1 (i). FISC_MNTH | ' &' | c_rows1 (i). VR | ' &' | c_rows1 (i). BENEFITS | ' &' | c_rows1 (i). PATN_LIST | ' &' | c_rows1 (i). (SLA);
    UPDATE T1 SET T1 MF_S224_RPT. UIDY_LO is str_new_uidy_lo WHERE T1. UIDY_LO = c_rows1 (i). UIDY_LO;
    UPDATE T2 T2 SET MF_S224_RPT_LN. PRPT_ID_LO is str_new_uidy_lo WHERE T2. PRPT_ID_LO = c_rows1 (i). UIDY_LO;
    UPDATE MF_S224_RPT_ACT T5 T5 SET. PRPT_ID_LO is str_new_uidy_lo WHERE T5. PRPT_ID_LO = c_rows1 (i). UIDY_LO;
    WHEN c_rows1 EXIT. COUNTY, 2000;
    END LOOP;
    CLOSE C_CURSOR;

    C_CURSOR_LN OPEN;
    EXTRACT the C_CURSOR_LN BULK COLLECT INTO c_rows2 LIMIT 2000;
    FORALL i IN c_rows2. FIRST... c_rows2. LAST
    str_new_uidy_lo_ln: = ('& 6085' |) SUBSTR (c_rows2 (i). PRPT_ID_LO, 6). ' &' | c_rows2 (i). TSYM | ' &' | c_rows2 (i). GLAC | ' &' | c_rows2 (i). ACMP_YEAR | ' &' | c_rows2 (i). ACMP_MNTH | ' &' | c_rows2 (i). RCPT_DISB_IN | ' &' | c_rows2 (i). PATN);
    UPDATE MF_S224_RPT_LN SET T3 T3. UIDY_LO is str_new_uidy_lo_ln WHERE T3. UIDY_LO = c_rows2 (i). UIDY_LO;
    UPDATE MF_S224_RPT_ACT SET T4 T4. PRPT_LINE_ID_LO is str_new_uidy_lo_ln WHERE T4. PRPT_LINE_ID_LO = c_rows2 (i). UIDY_LO;
    WHEN c_rows2 EXIT. COUNTY, 2000;
    END LOOP;
    CLOSE C_CURSOR_LN;

    END;
    /

    (although, error)

    Error report:
    ORA-06550: line 18, column 3:
    PLS-00103: encountered the symbol "STR_NEW_UIDY_LO" during the expected in the following way:

    . (* @ % & -+ / to rest rem mod select update with)
    < an exponent (*) > remove insert | run save type multiset
    Fusion
    ORA-06550: line 18, column 172:
    PLS-00103: encountered the symbol ";" when expecting one of the following values:

    ), * & = - + <>/ is mod remains not rem
    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or
    like4 likec between duplication | multise
    ORA-06550: line 24, column 3:
    PLS-00103: encountered the symbol "CLOSE" when expecting one of the following conditions:

    not end up dominant static of final instantiable order pragma
    manufacturer membership card
    ORA-06550: line 29, column 7:
    PLS-00103: encountered the symbol "STR_NEW_UIDY_LO_LN" during the expected in the following way:

    . (* @ % & -+ / to rest rem mod select update with)
    < an exponent (*) > remove insert | run save type multiset
    Fusion
    ORA-06550: line 29, column 221:
    PLS-00103: encountered the symbol ";" when expecting one of the following values:

    ), * & = - + <>/ is mod remains not rem
    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or
    like4 likec between duplication | multise
    ORA-06550: line 34, column 3:
    PLS-00103: encountered the symbol "CLOSE" when expecting one of the following conditions:

    not end up dominant static of final instantiable order pragma
    manufacturer membership card
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.
    * Action:

    I don't see anything wrong yet... could you help take a look?

    Thank you very much!!!

    DECLARE
    
       CURSOR c_cursor IS
          SELECT *
            FROM mf_s224_rpt
           WHERE uidy_lo IS NOT NULL
             AND patn_list IS NOT NULL;
    
       TYPE c_arr1 IS TABLE OF c_cursor%ROWTYPE;
    
       c_rows1 c_arr1;
       str_new_uidy_lo VARCHAR2(500);
    
       CURSOR c_cursor_ln IS
          SELECT *
            FROM mf_s224_rpt_ln
           WHERE uidy_lo IS NOT NULL;
    
       TYPE c_arr2 IS TABLE OF c_cursor_ln%ROWTYPE;
    
       c_rows2 c_arr2;
       str_new_uidy_lo_ln VARCHAR2(500);
    
    BEGIN
    
       OPEN c_cursor;
    
       FETCH c_cursor
        BULK COLLECT
        INTO c_rows1
       LIMIT 2000;
    
       FORALL i IN c_rows1.FIRST .. c_rows1.LAST 
    
          UPDATE mf_s224_rpt t1
             SET t1.uidy_lo = str_new_uidy_lo
           WHERE t1.uidy_lo = c_rows1(i).uidy_lo;
    
          UPDATE mf_s224_rpt_ln t2
             SET t2.prpt_id_lo = str_new_uidy_lo
           WHERE t2.prpt_id_lo = c_rows1(i).uidy_lo;
    
          UPDATE mf_s224_rpt_act t5
             SET t5.prpt_id_lo = str_new_uidy_lo
           WHERE t5.prpt_id_lo = c_rows1(i).uidy_lo; 
    
          --EXIT WHEN c_rows1.COUNT < 2000;
    
          --END LOOP;
    
          str_new_uidy_lo :=('&6084&'||c_rows1(i).fisc_year||'&'||c_rows1(i).fisc_mnth||'&'||c_rows1(i).vrsn||'&'||c_rows1(i).agcy||'&'||c_rows1(i).patn_list||'&'||c_rows1(i).alc);
    
      CLOSE c_cursor;
    
      OPEN c_cursor_ln;
    
      FETCH c_cursor_ln
       BULK COLLECT
       INTO c_rows2
      LIMIT 2000;
    
      FORALL i IN c_rows2.FIRST..c_rows2.LAST
    
         UPDATE mf_s224_rpt_ln t3
            SET t3.uidy_lo = str_new_uidy_lo_ln
          WHERE t3.uidy_lo = c_rows2(i).uidy_lo;
    
         UPDATE mf_s224_rpt_act t4
            SET t4.prpt_line_id_lo = str_new_uidy_lo_ln
          WHERE t4.prpt_line_id_lo = c_rows2(i).uidy_lo;
    
         --EXIT WHEN c_rows2.COUNT < 2000;
         --END LOOP;
         str_new_uidy_lo_ln :=('&6085'||SUBSTR(c_rows2(i).prpt_id_lo, 6)||'&'||c_rows2(i).tsym||'&'||c_rows2(i).glac||'&'||c_rows2(i).acmp_year||'&'||c_rows2(i).acmp_mnth||'&'||c_rows2(i).rcpt_disb_in||'&'||c_rows2(i).patn);
    
      CLOSE c_cursor_ln;
    
    END;
    

    A FORALL statement submit your statement number 'x' DML time all of a sudden.  Why do you 2 UPDATE instructions, I'm not sure.  But also your assignment to a string variable cannot be fair after the FORALL as it is NOT a loop.

  • mutiset separate union inside the collection

    
    DROP TYPE list_number;
    /
    
    DROP TYPE t_number;
    /
    
    CREATE OR REPLACE TYPE t_number IS OBJECT (a NUMBER);
    /
    
    CREATE OR REPLACE TYPE list_number IS TABLE OF t_number;
    /
    
    -- this code doesnt raise exception
    DECLARE
       w    list_number := list_number (t_number (1), t_number (2));
       w1   list_number := list_number (t_number (1), t_number (2));
       w2   list_number;
    BEGIN
       w2 := w MULTISET UNION  w2;
    END;
    /
    
    -- this code  raise exception when using distinct inside multiset with user defined collection
    --ORA-06550: line 6, column 10:
    --PLS-00306: wrong number or types of arguments in call to 'MULTISET_UNION_DISTINCT'
    DECLARE
       w    list_number := list_number (t_number (1), t_number (2));
       w1   list_number := list_number (t_number (1), t_number (2));
       w2   list_number;
    BEGIN
       w2 := w MULTISET UNION distinct w2;
    END;
    /
    
    -- this dosent raise exception when using distinct inside multiset 
    DECLARE
       TYPE list_num IS TABLE OF NUMBER;
    
       w    list_num := list_num (1, 2);
       w1   list_num := list_num (2, 2);
       w2   list_NUM;
    BEGIN
       w2 := w MULTISET UNION distinct  w2;
    END;
    /
    

    Hi gurus,

    When you use separate inside a collection of type multiset for schema-owned type exception is thrown for which I am unable to find the root cause

    Version

    11.2.0.3.0 Production NLSRTL

    Oracle Database 11g Enterprise Edition 11.2.0.3.0 64 bit Production

    PL/SQL 11.2.0.3.0 Production

    AMT for Linux: 11.2.0.3.0 Production

    SEPARATE means by comparing and throws exception since it does not know how to compare objects of type T_NUMBER. The map method, you must:

    SQL > CREATE OR REPLACE
    T_number TYPE 2
    3. IS ITEM)
    4 a certain NUMBER.
    5 FUNCTION of MEMBER card compare the RETURN NUMBER
    6              );
    7.

    Type of creation.

    SQL > CREATE OR REPLACE
    2 BODY of TYPE t_number
    3 EAST
    4 MEMBER card FUNCTION compare the RETURN NUMBER
    5 EAST
    6 BEGIN
    RETURN 7;
    8 END;
    9 END;
    10.

    Type the body created.

    SQL >
    SQL > CREATE or REPLACE TYPE list_number IS TABLE OF THE t_number;
    2.

    Type of creation.

    SQL > DECLARE
    2 w list_number: = list_number (t_number (1), t_number (2));
    3 w1 list_number: = list_number (t_number (1), t_number (2));
    W2 4 list_number;
    5 BEGIN
    6 w2: MULTISET UNION w2 w = separate;
    7 END;
    8.

    PL/SQL procedure successfully completed.

    SQL >

    SY.

  • How to use special characters (single quote) in input values?

    I have a query that contains a clause: field: tags_set

    (the field contains string values)

    I would like to test in sqlplus.

    I found this article https://asktom.oracle.com/pls/apex/f?p=100:11:0:P11_QUESTION_ID:113012348062 explaining how to define variables in sqlplus.

    However, my variable should contain something like ("xyz", "abc")

    I tried

    SQL > tags_set varchar2 variable

    "SQL > exec: tags_set: = '(' musique');

    "START: tags_set: = '(' musique'); END;

    *

    ERROR on line 1:

    ORA-06550: line 1, column 23:

    PLS-00103: encountered the symbol "MUSIC" when expected in the following way:

    * & = - + ; <>/ is mod remains not rem

    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or

    like4 likec between | submultiset of type multiset Member

    The symbol ' * was inserted before 'MUSIC' to continue. '

    ;

    Then I did some research and found: characters in queries

    Therefore, I changed the previous for:

    SQL > exec: tags_set: = '(\'Music\')';

    START: tags_set: = '(\'Music\')'; END;

    *

    ERROR on line 1:

    ORA-06550: line 1, column 24:

    PLS-00103: encountered the symbol "MUSIC" when expected in the following way:

    * & = - + ; <>/ is mod remains not rem

    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or

    like4 likec between | submultiset of type multiset Member

    and finally

    SQL > exec: tags_set: = "{('a ')}";

    START: tags_set: = "{('a ')}"; END;

    *

    ERROR on line 1:

    ORA-06550: line 1, column 24:

    PLS-00103: encountered the symbol "A" when expecting one of the following conditions:

    * & = - + ; <>/ is mod remains not rem

    < an exponent (*) > <>or! = or ~ = > = < = <>and like2 or

    like4 likec between | submultiset of type multiset Member

    The symbol ' * was inserted before 'A' to continue. '

    What is the way to make it work? (I know that I can move to something like "xyz ~ abc' and treat inside the query")

    Thanks in advance.

    A number of things.  When you define a string variable, you must give him a length or default is 1.  You can escape a quote character by doubling it (i.e. two single quotes) or you can use the q rating:

    SQL > tags_set variable varchar2 (100);

    "SQL > exec: tags_set: = '('' musique '');

    PL/SQL procedure successfully completed.

    SQL > print tags_set

    TAGS_SET

    --------------------

    ("Music")

    SQL > exec: tags_set: = q '{("music", "Drama")}';

    PL/SQL procedure successfully completed.

    SQL > print tags_set

    TAGS_SET

    --------------------

    ("Music", "Drama")

    John

  • Divide a line into several lines based on the amount

    Dear all,

    Please provide a solution for this scenario.

    The query...

    Select line_id, component, sizes, quantity of sales_tab;

    and the result...

    LINE_IDCOMPONENTSIZESQUANTITY
    8BODYSMALL214.33
    4BODYMEDIUM187.89
    1BODYLARGE230.87
    7BODYEXTRA LARGE205.03
    3BODYXX LARGE148,52
    2SLEEVESMALL197.57
    6SLEEVEMEDIUM176.4
    5SLEEVELARGE193.8
    10SLEEVEEXTRA LARGE184.87
    9SLEEVEXX LARGE138.53

    Business rule: for all rows where the quantity is greater than 200, generate a new identical line with quantity = quantity - 200 like - we. This is the quantity of each line must not exceed 200.

    The required result is...

    LINE_IDCOMPONENTSIZESQUANTITY
    8BODYSMALL200
    8BODYSMALL14.33
    4BODYMEDIUM187.89
    1BODYLARGE200
    1BODYLARGE30,87
    7BODYEXTRA LARGE200
    7BODYEXTRA LARGE5.03
    3BODYXX LARGE148,52
    2SLEEVESMALL197.57
    6SLEEVEMEDIUM176.4
    5SLEEVELARGE193.8
    10SLEEVEEXTRA LARGE184.87
    9SLEEVEXX LARGE138.53

    Thank you

    Usman

    Use:

    Select line_id,

    component,

    sizes,

    amount of column_value

    of sales_tab.

    table)

    cast)

    MultiSet)

    Select less (200, - 200 quantity * (level - 1))

    of the double

    connect in quantity > 200 * (level - 1)

    )

    as sys. OdciNumberList

    )

    )

    order of line_id,

    amount desc

    /

    For example:

    SQL > with sales_tab like)
    2 Select line_id 8, component 'Body', 'SMALL' amount 214.33 of all sizes the double union
    3. Select 4, 'BODY', 'WAY', 187.89 double Union all
    4 Select 1, 'BODY', 'LARGE', 230.87 double Union all
    5. Select 7, 'BODY', 'EXTRA LARGE', 205.03 double Union all
    6 select 3, 'BODY', 'XX-LARGE', 148,52 of double union all
    7. Select 2, 'CHANNEL', 'SMALL', 197.57 double Union all
    8. Select 6, 'CHANNEL', 'WAY', 176.4 from dual union all
    9. Select 5, 'ROUND', 'BIG', 193.8 double Union all
    10. Select 10, 'ROUND', 'EXTRA LARGE', 184.87 double Union all
    11. Select 9, 'ROUND', 'XX-LARGE', double 138.53
    12                  )
    13. Select line_id,
    14 components,
    15 sizes,
    amount of 16 column_value
    sales_tab 17,
    Table 18)
    19 mount)
    (20) type multiset
    21 select less (200, - 200 quantity * (level - 1))
    22 double
    23 connect quantity > 200 * (level - 1)
    24                            )
    25 as sys. OdciNumberList
    26                    )
    27              )
    28 order of line_id,
    29 quantity desc
    30.

    LINE_ID COMPON QUANTITY SIZES
    ---------- ------ ----------- ----------
    1 BODY 200 GRAND
    1 BODY GRAND 30,87
    2 SLEEVES SMALL 197.57
    3 BODY XX LARGE 148,52
    4 WAY 187.89 BODY
    5 SLEEVES 193.8 GRAND
    SLEEVE 6 MEANS 176.4
    7 BODY 200 EXTRA-LARGE
    7 BODYWORK 5.03 EXTRA-LARGE
    8 200 SMALL BODY
    8 BODY SMALL 14.33

    LINE_ID COMPON QUANTITY SIZES
    ---------- ------ ----------- ----------
    CHANNEL 9 XX GRAND 138.53
    10 SLEEVES EXTRA-LARGE 184.87

    13 selected lines.

    SQL >

    SY.

Maybe you are looking for