How to run the type of object...

HI team,

Please let me know how to run pl/SQL object type.

create or replace TYPE  T_PARTY_ID_LIST  AS TABLE OF T_PARTY_ID; 
create or replace TYPE  T_PARTY_ID AS OBJECT
 (SEQ NUMBER(10,0)
 ,COUNTRY_ID CHAR(2)
 ,ID VARCHAR2(50)
 ,ID_TYPE VARCHAR(3)
 ,DATE_FROM DATE
 ,DATE_TO DATE
 );

create or replace PROCEDURE P_UPDATE_RICA_COUNT_ID
 (A_PARTY_IDS IN T_PARTY_ID_LIST
 ,A_ICAP_ID  IN number
 ) as
v_id      sa_id_registration_counts.id%TYPE;

--
BEGIN
    FOR C IN (SELECT X.id_type, X.ID FROM TABLE (CAST(A_party_ids AS T_PARTY_ID_LIST)) X
             WHERE X.ID_Type IN ('N','P','B')
             ORDER BY X.ID_Type)
   LOOP
--
      BEGIN
 --             
         UPDATE sa_id_registration_counts
         SET no_of_registrations = no_of_registrations-1
         WHERE id = V_ID
               AND id_type = C.ID_Type;
--
         IF SQL%ROWCOUNT < 1 THEN
            RAISE NO_DATA_FOUND;
         END IF;
--
      EXCEPTION
         WHEN NO_DATA_FOUND THEN
            BEGIN
--
               INSERT
               INTO sa_id_registration_counts
                  (id ,id_type,exclude_yn,no_of_registrations)
               SELECT V_ID,C.ID_Type,'N',1 
               FROM dual;
--
            EXCEPTION
               WHEN OTHERS THEN
                  RAISE_APPLICATION_ERROR(-20000,'Error updating RICA ID count ['||SQLERRM||']');
            END;  
      END;
--
   END LOOP;  
--
END;
--

I'm trying, but receive an error message

DECLARE
  A_PARTY_IDS SCOTT.T_PARTY_ID_LIST;
  A_ICAP_ID NUMBER :=12323;
BEGIN

A_PARTY_IDS.extend(1);
  SELECT T_PARTY_ID(1,'1','1','1',null,null) INTO A_PARTY_IDS(1)
   FROM DUAL;
   
  P_UPDATE_RICA_COUNT_ID(
    A_PARTY_IDS => A_PARTY_IDS,
    A_ICAP_ID => A_ICAP_ID );

END;
Error report -
ORA-06531: Reference to uninitialized collection

I do not know why you do what you do that is row-by-row (aka slow-by-slow), when you could do all this in a single merge - something like statement:

create or replace PROCEDURE P_UPDATE_RICA_COUNT_ID
   (A_PARTY_IDS IN T_PARTY_ID_LIST,
    A_ICAP_ID  IN number)
as
begin
  merge into sa_id_registration_counts tgt
  using (select x.id_type, x.id, count(*) cnt
         from   table(cast(a_party_ids as t_party_id_list)) x
         where  x.id_type in ('N', 'P', 'B')
         group by x.id_type, x.id) src
     on (tgt.id_type = src.id_type
         and tgt.id = src.id)
  when matched then
    update set no_of_registrations = no_of_registrations - src.cnt
  when not matched then
    insert (tgt.id, tgt.id_type, tgt.exclude_yn, tgt.no_of_registrations)
    values (src.id, src.id_type, 'N', 1);
end;
/

You v_id in your procedure, but you never defined anywhere, for as far as I could tell, so I made a few assumptions about the join condition. You will need to change if necessary.

Meanwhile, for your procedure, you should do something like:

DECLARE
  A_PARTY_IDS T_PARTY_ID_LIST := t_party_id_list();  -- initialised the collection here
  A_ICAP_ID NUMBER :=12323;
BEGIN  

  A_PARTY_IDS.extend(1);
  A_PARTY_IDS(1) := T_PARTY_ID(1,'1','1','1',null,null); 

  P_UPDATE_RICA_COUNT_ID(
      A_PARTY_IDS => A_PARTY_IDS,
      A_ICAP_ID => A_ICAP_ID );
end;
/

Another thing - you seem to like selection of the many double - if you're in PL/SQL, then you can just assign variables directly (overall; there are a few exceptions, depending on your version of the database).

Tags: Database

Similar Questions

  • How to change the type of object?

    I have an object type, as shown below:

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );

    create or replace type test_type1 is table of the test_object1;


    Now I want to change the type of object. I want to increase the size of val1 to varchar2 (100).

    Any body could help for the alter script.

    Thank you
    Lavan

    >
    SQL > alter type test_object1 change attribute (varchar2 (100)) val1;
    >
    Which won't work OPs example. Your example does not include the second type of object that depends on the first type.

    You cannot change the underlying type unless you use the CASCADe or INVALIDATE option.
    >
    change the type of test_object1 change attribute (val1 varchar2 (100)) waterfall;
    >
    See the CASCADE clause in the link provided by Osame
    >
    CASCADE clause

    Specify the CASCADE clause if you want to propagate the type change to the tables and dependent types. Oracle database abandons the statement if errors are found in the dependent types or tables, unless you also specify the FORCE.

    If you change the property of the type between FINAL and NON-FINAL, you must specify this clause to convert data in the tables and dependent columns. Please refer to [NOT] FINAL.

  • [CS2] [VB] How can I determine the type of object to a PageItem?

    I use InDesign CS2 and VBScript

    Loop to the bottom of the PageItems in a Page, I need determine the Type of object (TextFrame, group, GraphicLine... each process) and PageItem accordingly.

    Is there a method/function VBS wiil returns the Type of an object as a string or a value. Or what I need to check the existence/non-existence of a particular property associated with a particular object for this type?

    Alternatively, is there a JavaScript function that will do what I can call VBScript?

    For the record: TypeName is what you need.

    For example, when the cursor is planted in the text return TypeName (Ind.Selection (1)) 'PointInsertion.' When a text block is selected, it returns "TextFrame.

  • Need help to identify the type of object in the loop of pl/sql

    Hello

    I need help to identify the Type of object declared beneath a procedure as shown below:

    I need to pass the parameter to the procedure as a TYPE of OBJECT and also refer to variables of Type Object in a loop

    create or replace type TEST_VALIDATION_REC is RECORD (order_num varchar2 (30),)

    number of inventory_item_id

    reserved_YN varchar2 (1).

    error_flag varchar2 (1).

    Error_message varchar2 (2000)

    );

    CREATE OR REPLACE TYPE VALD_TBL AS VARRAY (10000) OF TEST_VALIDATION_REC;

    PROCEDURE ADD_TO_ORD)

    p_lot_number_list IN VALD_TBL,

    p_ord_number IN Varchar2,

    p_user_id in NUMBER: = fnd_profile.value ('USER_ID'),-change 1.10

    p_responsibility_id in NUMBERS: = fnd_profile.value ('RESP_ID'),-change 1.10

    p_application_id IN VARCHAR2: = 'PO',-change 1.10

    x_error_flag OUT Varchar2,

    x_error_msg OUT Varchar2

    )

    In the above procedure, I had the VALD_TBL. Is it OK?

    And how in the loop if the records if I use:

    FOR indx1 IN 1.p_lot_number_list. COUNTY

    LOOP

    BEGIN

    SELECT

    inventory_item_id

    IN

    ln_item_id

    Of

    dummy_lot_tab

    WHERE

    lot_number = p_lot_number_list (indx1); - > how direct the item here?

    EXCEPTION

    WHILE OTHERS THEN

    ln_item_id: = NULL;

    END;

    Records are PL/SQL objects.  They are not the SQL objects.  You can create a SQL TYPE (schema level) as a collection (variable-tables only, tables nested).

    So therefore your first statement is syntactically incorrect

    CREATE OR REPLACE TYPE TEST_VALIDATION_REC IS RECORD
    (order_num VARCHAR2(30),
    inventory_item_id NUMBER,
    reserved_YN VARCHAR2(1),
    error_flag VARCHAR2(1),
    Error_message VARCHAR2(2000)
    );
    

    You must put in an anonymous PL/SQL block or the stored procedure

    DECLARE
    
       TYPE test_validation_rec IS RECORD
       (
        order_num VARCHAR2(30),
        inventory_item_id NUMBER,
        reserved_YN VARCHAR2(1),
        error_flag VARCHAR2(1),
        error_message VARCHAR2(2000)
       );
    
       TYPE vald_tbl iS VARRAY(10000) OF test_validation_rec;
    
       lv_tbl vald_tbl;
    
    BEGIN
    
       lv_tbl := vald_tbl();
      -- insert your code here 
    
    END;
    
  • [JS] How to change the type of stroke?

    app.selection[0].strokeWeight = 3;     // app.selection[0] = [object TextFrame]
    app.selection[0].strokeCornerAdjustment = StrokeCornerAdjustment.DASHES;
    

    Hello.

    I tried this code, but error.

    error message: property is not applicable to the current state.

    How to change the type of dotted line?

    You must use the strokeType method, try this

    App.Selection [0] .strokeWeight = 3;

    App.Selection [0]. StrokeType = "dashes (3 and 2).

  • How to change the type of light?

    Does anyone know how to change the type of light?

    What happens is that I have a button I want to create a Point of light, but just create a spot light.

    Does anyone know how to change it to create a point of light?

    My code is:

    Add a Point of Comp light active

    addLightCtrl.onClick = function(){}

    pointLight var = proj.layers.addLight ("Light," [960, 540]);

    }

    See the attribute of the lightType LightLayer object. Page 100 of the script AE CS6 guide.

    pointLight = activeItem.layers.addLight ("Light," [960, 540]);

    pointLight.lightType = LightType.POINT;

  • [CS4:JS] How to run the file ".sh" via Javascript

    Dear all,

    How to run the file ".sh" through Adobe InDesign Javascript, I used the code below:

    //================== Code =============================//

    var myFile = File("xxx/xxx/xxx/Test.sh");

    var Exec = "sh" + "" + "\""+myFile+"\;"

    Leader (exec). Execute();

    //================== End =========================//

    codes above does not work, I checked before without the "sh" in addition, it does not work.

    Please can someone give me the solutions and the suggestion, and I'd appreciate it.

    Thanks and greetings

    SudhaN T.R.Harihara.,.

    Have your IDMLExportparse.sh file runs permission set?

    If you open Terminal.app and type

    /Applications/MacXinPro/IDMLExportparse.sh

    It work? Or do you need to run "sh"? If so, either adjust the

    permissions with

    chmod a + x /Applications/MacXinPro/IDMLExportparse.sh

    or modify the JavaScript code for:

    shell("sh "+myFile);
    
  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • Ask about the types of objects

    Hello

    I have a question about the type of object. I want to see the script for the type of object created, that is already stored in the database. How can I see who


    Concerning

    Hello

    So, you can try [DBMS_METADATA. GET_DDL | http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_metada.htm#ARPLS640]...

    MHO%xe> create or replace type mytype as object( col varchar2( 10 ));
      2  /
    
    Type is aangemaakt.
    
    Verstreken: 00:00:00.37
    MHO%xe> select dbms_metadata.get_ddl('TYPE', 'MYTYPE') from dual;
    
    DBMS_METADATA.GET_DDL('TYPE','MYTYPE')
    ------------------------------------------------------------------------------
    
      CREATE OR REPLACE TYPE "MHO"."MYTYPE" as object( col varchar2( 10 ));
    
  • Lean how to run the stop code when the highest level VI ends

    Hi people.

    I am a newbie of LV with 30 years of experience in embedded SW engineering.  I searched for how to run the stop code when a VI of highest level ends.  I found many examples, but they are horribly complicated.  A little birdie told me that such a model of simple design should not be so compilicated.

    My application is an application of high tension control to disable all HV checkpoints when the SW ends.  My VI code is running in a while loop with a stop button that leads out of the loop.  I can easily accomplish my requirement by programming with a sequence of plate that runs after the end of the main loop.  The technique of flat sequence does not work when the user clicks the Cancel button in the toolbar of façade, more than that market when the user clicks the close button of the application (X button) when you run the exe application.

    Can someone tell me please a simple technique, the code example that can show me a lean and elegant way to accomplish my task?  It doesn't have to be an obvious solution (for example a stop induced watchdog seems simple enough).

    Thank you - John Speth

    1. place this code in a VI:

    (also attached)

    Calling code in your VI of highest level like this:

  • How to run the VI developed in labVIEW 2011 in its previous versions

    Hi all

    I am currently using LabVIEW 2011 in my PC at home.

    But, all my school's computers are installed with LabVIEW 2010 and 2010 SP1.

    How to run the VI developed in LabVIEW 2011 in its previous versions?

    Is there any conveter why?

    Concerning

    Prasanth T

    Open the VI in LabVIEW 2011 and use the file menu option, save for the previous Version.

  • How to check the type of memory installed (ECC or not)?

    all!

    I have some servers Dell PowerEdge R420 and I want to upgrade memory, install more...

    How to check the type of memory installed (ECC or not)?

    Dmidecode output here:

    Drive.google.com/.../View

    Hello.

    Unfortunately, we are not able to open the link you have provided. You can display information about your memory on the web iDRAC under hardware and memory interface. You see the type of error correction (ECC or Non ECC) within the information memory page. You can also view the same information on OpenManage Server Administrator and even make use of the memory part number to find out more information.

  • How to change the type of user account in the registry editor

    Hello.

    Can someone tell me how to change the type of user account in the registry editor

    Thanks in advance... :-)

    Kind regards
    Rambeau

    Hello.

    Can someone tell me how to change the type of user account in the registry editor

    Thanks in advance... :-)

    Kind regards
    Rambeau

    You can not. You need to do this via the control panel / accounts of users or via the command prompt. In both cases, you need to be logged in as an administrator account.

  • How to run the Extendscript .bat file?

    I have a file with some instructions .bat and I want that it runs from Extendscript.

    How to run the Extendscript .bat file?

    I tried execute(); order and it seems that .bat ran but no result, but when I double click on the .bat file all worksout very well.

    How used runtime.exec () extend the script?

    Can I communicate with Java JDK thru ExtendScript and run commands such as runtime.exec ()?

    can someone please?

    You can do it like this:

    var batFile = new File("C:\\path\\to\\my\\batfile.bat");
    batFile.execute();
    

    Note that this will only work if your system is configured in such a way that by double-clicking the .bat file runs it in reality.

    You can also use

    system.callSystem()
    

    but note that this is only available in AE.

  • What is tdrc.tdrcfacade and how to run the installation wizard?

    What is tdrc.tdrcfacade and how to run the installation wizard?  My desktop creative cloud application does not open properly... it is just a blank window.

    Much obliged,

    Angiecrichards@gmail.com

    ! !

    Are Angie, you a blank white screen? What version of OS are you using?

    Here's what you can try:

    1. Blank white screen. Sign in | Creative cloud Packer
    2. New application Cloud Creative unusable: it is empty!
    3. Creative cloud Packager white screen after the Adobe ID Login
    4. Re: screen creative black cloud

    Waiting for your response.

Maybe you are looking for

  • Laptop HP G6

    I have problems with my laptop: No wifi; Cannot install a usb wifi adapter. SD slot does not work; Driver PCI Device 28 code; and stopping lasts too long. PCI Device Properies - Details: PCI\VEN_10EC & DEV_5229 & SUBSYS_1841103C & REV_01PCI\VEN_10EC

  • [Spectrum XT] Encountered issue SMART Check

    I just got this new ultrabook, for two weeks in and just yesterday, I started getting lockups and BSODS. I checked the observer of events 7 and began to notice the newspapers mentioning: The device, \Device\Ide\iaStor0, did not in the expiration time

  • HP LaserJet 1022: Reset fails to kill orange light after the paper jam. I try next?

    I followed the instructions to reset this (quite old) printer after he picked up several sheets at once and it reported a paper jam. He was not in fact any paper left inside, but I gave it a clean anyway.  By pressing the two buttons for reset, I get

  • Konica Minolta Di1611 drivers for windows 7

    Hello I have a good Konica Minolta Di1611 printer scanner copier purchased in 2003 only 86 000 best on the clock. I just changed my computer which has windows 7. Windows 7 does not support the copier as Konica Minolta have not upgraded the windows dr

  • I bought a Xbox 350 PC wireless gaming receiver and its does not work!

    OK, so I bought it on amazon and its third party I called s DGmaxx I went to my computer and Device Manager properties and the alll such good things. I tried to connect after that then turn on remote sync by clicking on the receiver and then the cont