pl/sql table type issue (basic)

Hello..
I am new to pl/sql collections...

And I tried the following, but how do I view the output using the dbms_output
SQL> declare
  2   type emptype is table of emp%rowtype index by pls_integer;
  3   etab emptype;
  4  begin
  5   select * into etab(100) from emp where empno=7566;
  6   dbms_output.put_line(etab.sal);
  7  end;
  8  /
 dbms_output.put_line(etab.sal);
                           *
ERROR at line 6:
ORA-06550: line 6, column 28:
PLS-00302: component 'SAL' must be declared
ORA-06550: line 6, column 2:
PL/SQL: Statement ignored
Thank you

Published by: josh1612 on March 24, 2009 23:50

Try

 ...
 dbms_output.put_line(etab(100).sal);
...

Tags: Database

Similar Questions

  • Performance issue Bulk Insert PL/SQL table type

    Hi all

    I put in work of a batch to fill a table with a large number of data records(>3,000,000). To reduce the execution time, I used PL/SQL tables to temporarily store data that must be written to the destination table. Once all documents are piling up in the PL/SQL table I use a FORALL operator for bulk insert the records in the physical table.

    Currently, I follow two approaches to implement the process described above. (Please see the code segments below). I need to choose how to best wise performance between these two approaches. I really appreciate all the comments of experts about the runtime of the two approaches.

    (I don't see much difference in consumption of time in my test environment that has limited the data series. This process involves building a complex set of structures of large product once deployed in the production environment).


    Approach I:_
    DECLARE
    TYPE of test_type IS test_tab % ROWTYPE directory INDEX TABLE;
    test_type_ test_type.
    ins_idx_ NUMBER;
    BEGIN
    ins_idx_: = 1;
    NESTED LOOPS
    test_type_ (ins_idx_) .column1: = value1;
    test_type_ (ins_idx_) .column2: = value2;
    test_type_ (ins_idx_) .column3: = value3;
    ins_idx_: = ins_idx_ + 1;
    END LOOP;

    I_ FORALL in 1.test_type_. COUNTY
    INSERT INTO test_tab VALUES (i_) test_type_;
    END;
    /


    Approach II:_
    DECLARE
    Column1 IS a TABLE OF TYPE test_tab.column1%TYPE INDEX DIRECTORY.
    Column2 IS a TABLE OF TYPE test_tab.column2%TYPE INDEX DIRECTORY.
    Column3 IS a TABLE OF TYPE test_tab.column3%TYPE INDEX DIRECTORY.
    column1 column1_;
    column2_ Column2;
    column3_ Column3;
    ins_idx_ NUMBER;
    BEGIN
    ins_idx_: = 1;
    NESTED LOOPS
    column1_ (ins_idx_): = value1;
    column2_ (ins_idx_): = value2;
    column3_ (ins_idx_): = value3;
    ins_idx_: = ins_idx_ + 1;
    END LOOP;

    FORALL idx_ in 1.column1_. COUNTY
    INSERT
    IN n_part_cost_bucket_tab)
    Column1,
    Column2,
    Column3)
    VALUES)
    column1_ (idx_),
    column2_ (idx_),
    column3_ (idx_));
    END;
    /

    Best regards
    Lorenzo

    Published by: nipuna86 on January 3, 2013 22:23

    nipuna86 wrote:

    I put in work of a batch to fill a table with a large number of data records(>3,000,000). To reduce the execution time, I used PL/SQL tables to temporarily store data that must be written to the destination table. Once all documents are piling up in the PL/SQL table I use a FORALL operator for bulk insert the records in the physical table.

    Performance is more than just reducing the execution time.

    Just as smashing a car stops more than a car in the fastest possible time.

    If it was (breaking a car stopping all simply), then a brick with reinforced concrete wall construction, would have been the perfect way to stop all types of all sorts of speed motor vehicles.

    Only problem (well more than one actually) is that stop a vehicle in this way is bad for the car, the engine, the driver, passengers and any other content inside.

    And pushing 3 million records in a PL/SQL 'table' (btw, that is a WRONG terminology - there no PL/SQL table structure) in order to run a SQL cursor INSERT 3 million times, to reduce the execution times, is no different than using a brick wall to stop a car.

    Both approaches are pretty well imperfect. Both places an unreasonable demand on the memory of the PGA. Both are still row-by-row (aka slow-by-slow) treatment.

  • Retrieve data in pl/sql table type

    Hello
    I am facing problem in the following sql query,
    How should I display all records.
    declare
    tab type is the emp9% rowtype index directory table.
    e_tab tab.
    Start
    Select empno, ename, job, mgr, sal, comm, deptno bulk collect into emp9 e_tab;
    for x in e_tab.first... e_tab. Last
    loop
    dbms_output.put_line (e_tab (x));
    end loop;
    end;
    I get the argument type error or wron number of in the DBMS... statement.
    How should I fix it?

    Published by: 923315 on March 30, 2012 12:50

    Yes, he accepts a single parameter, but it can always be expression (as the concatenation: val1 | val2 | val3). In your case (.ename e_tab (x) |) ' ' || e_tab (x) .sal

  • Is it possible to use the record type or a PL/SQL table in the Select statement

    Hi all

    My requirement is that.
    I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
    I select the return values in the Select no statement in a PL/SQL block.
    Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?

    Please help me understand the solution.


    Kind regards

    830960 wrote:
    do we like it?

    In general, Yes, if the function is a function table, you can do something like:

    select  t.col1,
            t.col2,
            f.col1,
            f.col2,
            f.col3
      from  table_name t,
               table(some_table_function(param1,...paramN)) f
    /
    

    SY.

  • How to create a type of record and a pl/sql table of this record type in the database

    Hello
    I want to create a record type, and then I want to create a PL/SQL table in the oracle 9i database.
    I did block PL/SQL.
    But when I'm doing it in the database it throws me a few errors.
    Could you please tell me how can I do?

    Concerning

    user576726 wrote:
    Hello
    I want to create a record type, and then I want to create a PL/SQL table in the oracle 9i database.
    I did block PL/SQL.
    But when I'm doing it in the database it throws me a few errors.
    Could you please tell me how can I do?

    Concerning

    RECORD type is only supported in PL/SQL for SQL, you must use the OBJECT type.

  • PL/SQL object type table

    Hello

    Please tell me how to test code below.
    Here's the complete code: -.

    ------------------------------------------
    CREATE type dept_typ AS OBJECT (deptno number, dname varchar2 (20), varchar2 (20)) loc

    CREATE TYPE dept_tab AS TABLE OF dept_typ;
    ----------------------------------------------

    create or replace function fun_test
    return dept_tab
    IS
    list dept_tab: = dept_tab();
    number of j: = 0;
    cursor dept_cur IS
    Select deptno, dname, loc scott.dept;
    BEGIN
    BECAUSE me in dept_cur
    LOOP
    list. EXTEND (1);
    (J) list: = dept_typ (i.deptno, i.dname, i.loc);
    j: = j + 1;
    END LOOP;
    back list;
    END;

    Thank you
    Kamel
    SQL> create type name as object
       (fname varchar2 (20), lname varchar2 (20));
    /
    Type created.
    
    SQL> create type address as object
       (person name, city varchar2 (10));
    /
    Type created.
    
    SQL> create or replace function addr_fun (p_name name, p_city varchar2)
       return address
    is
    begin
       return address (name ('ABC', 'EFG'), 'XYZ');
    end addr_fun;
    /
    Function created.
    
    SQL> select addr_fun (null, null) addr_fun from dual
    /
    ADDR_FUN
    --------------------------------------------------
    ((ABC; EFG); XYZ)
    1 row selected.
    
  • How to create the constructor function for a pl/sql table?

    I created a PL/SQL type as table below:

    create or replace type typ_tbl_des_text is table of the typ_tof_des_text

    OK so far, but I would like to have a constructor function which would be subject to validations and raise_application_error when a validation condition is not met.

    How to do this?

    The typ_tof_des_text that I created with a constructor function, so that the record-level validation are performed in the constructor. And I think the postings between several records shall be made in a constructor for typ_tbl_des_tex, but cannot figure out how to create such a constructor.

    BEDE wrote:

    So, if I have understood correctly, to a plsql table type, I can't have a member procedure. Or can I? I mean, just as for a type of failure I can have one or more constructors and possibly several procedures of Member.

    For the standard tables in PL/SQL, you will need to create your own API (using procedures and functions) to handle beyond the basics provided by the language. No constructors and methods as it is no o - o.

    After thinking a little deeper, I reformulate what I said earlier and actually wants to have a member procedure called add_item, who would be first to check if an item with a key value exists and, if so, it would be up-to-date and so not only extend the plsql table.

    Two options.

    As we already mentioned, an associative array can be considered - note however that this structure of table has name-value pairs.

    Another method is to use a TWG (global temporary table). You define the structure of the once initial table. When a session uses the structure of the table, private copying is instantiated for this session. When the session ends, this copy is destroyed. The table is a temporary structure for this session only.

    It can include indexes and so on – which means you can use the constraints of primary keys, unique indexes, secondary indexes and so on.

    TWG scales are much better than collections or arrays that require a PGA (expensive private server) memory. In addition, SQL can be used natively against a GTT - unlike the arrays and collections.

  • I can pass a pl/sql table as a parameter for a database adapter

    Hello

    I'm moving mutiple files back to a pl/sql stored procedure using a BPEL database adapter. Does anyone know if it is possible to make pl/sql tables to bpel as a parameter?

    The version of the database that we use is 8.1.7 and so I do not think that we use XMl types for transmitting data.

    Yes you can not spend the function PL/SQL nested tables in JDBC. You can pass simple values such as VARCHAR2, NUMBER and Oracle SQL object types (VARRAY, nested TABLE, OBJECT).

    Types defined in PL/SQL are simply not supported by the JDBC driver (except the basic support for the index per table, but 1 level of depth). PL/SQL types are not very good to use, because then you can not use them in SQL in PL/SQL statements, SQL types do not have these limitations.

  • Error in initialization of multilevel nested table type

    Hello

    Database version: Oracle 11 g R2

    I am creating a complex process I need to create complex nested table types and use them in code.

    {code}

    CREATE or REPLACE TYPE ws_data_compare_rt

    AS AN OBJECT

    (

    external_web_service_id NUMBER (10),

    service_code VARCHAR2 (30),

    ws_bridging_id NUMBER (10),

    ws_attribute_name VARCHAR2 (64).

    ws_attribute_value VARCHAR2 (32767).

    in_source_attribute VARCHAR2 (30),

    in_source_value VARCHAR2 (32767).

    comparison_rule VARCHAR2 (100)

    );

    CREATE or REPLACE TYPE ws_data_compare_tt IS TABLE OF THE ws_data_compare_rt;

    CREATE or REPLACE TYPE ws_data_compare_master_rt

    AS AN OBJECT

    (

    key_attribute_1 VARCHAR2 (30),

    NUMBER of key_attribute1_value

    key_attribute_2 VARCHAR2 (30),

    NUMBER of key_attribute2_value

    m_ws_data_compare_tt ws_data_compare_tt

    );

    /

    CREATE or REPLACE TYPE ws_data_compare_master_tt IS TABLE OF THE ws_data_compare_master_rt;

    {code}

    The objects have been created successfully. However when I use it in my code, I need to initialize them, but I get an error for the variable of ws_data_compare_master_tt type initialization.

    {code}

    ...

    g_ws_data_compare_rt ws_data_compare_rt: = ws_data_compare_rt (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    g_ws_data_compare_tt ws_data_compare_tt: = ws_data_compare_tt();

    g_ws_data_compare_master_rt ws_data_compare_master_rt: = ws_data_compare_master_rt (NULL, NULL, NULL, NULL, g_ws_data_compare_tt);

    g_ws_data_compare_master_tt ws_data_compare_master_tt: = ws_data_compare_master_tt();

    ...

    {code}

    I'm unable to initialize the variable g_ws_data_compare_master_tt of type ws_data_compare_master_tt that I get the below error.

    For PACKAGE BODY UTL compile errors. PKG_WS_UTIL

    Error: PLS-00222: no function with name 'WS_DATA_COMPARE_MASTER_TT' does exist in this scope

    Line: 28

    Text: g_ws_data_compare_master_tt ws_data_compare_master_tt: = ws_data_compare_master_tt();

    Error: PL/SQL: ignored element

    Line: 28

    Text: g_ws_data_compare_master_tt ws_data_compare_master_tt: = ws_data_compare_master_tt();

    Can someone help me to find out what is the problem?

    Thanks in advance.

    Kind regards

    Natarajan

    Ah, I found the problem on my own. It was because of a bad statement similarly variable g_ws_data_compare_master_tt in a table in the specification of the package that was trouble. However I wonder the error returned Oracle was not fully exposed.

    Kind regards

    Natarajan

  • Calling PL/SQL table...

    I have a procedure called from a package that returns all the data, the package uses a PL/SQL table that I do not know HOW to call or values that I would need to run the XXINV_PWB_HIST_FCST_PUB. XXINV_PWB_ORG_HIST_TBL (structure) with in the package, can someone tell me how it's done?

    Call package is downstairs, the record structure is less than the package call.

    DECLARE

    P_ITEM_NUMBER VARCHAR2 (200);

    DATE OF P_CURRENT_DATE;

    X_PWB_ORG_HIST_TBL APPS. XXINV_PWB_HIST_FCST_PUB. XXINV_PWB_ORG_HIST_TBL;

    BEGIN

    P_ITEM_NUMBER: = NULL;

    P_CURRENT_DATE: = NULL;

    -Modify the code to initialize the variable

    -X_PWB_ORG_HIST_TBL: = NULL;

    XXINV_PWB_HIST_FCST_PUB. () GET_ORG_DETAILS

    P_ITEM_NUMBER = > 91,

    P_CURRENT_DATE = > 2 February 2014 ",

    X_PWB_ORG_HIST_TBL = > X_PWB_ORG_HIST_TBL (which values should I put in the section)

    );

    Legacy release:

    DBMS_OUTPUT. PUT_LINE ('X_PWB_ORG_HIST_TBL =' |) X_PWB_ORG_HIST_TBL);

    -: X_PWB_ORG_HIST_TBL: = X_PWB_ORG_HIST_TBL;

    END;

    TYPE XXINV_PWB_Hist_Tbl IS TABLE OF THE XXINV_PWB_Hist_Rec

    INDEX OF DIRECTORY;

    TYPE XXINV_PWB_Org_Hist_Rec IS RECORD

    (

    Org_Hist_Index_Id NUMBER: = ".

    Item_Number Varchar2 (30): = ".

    Number of Quantity_1: = ".

    Number of Quantity_2: = ".

    Number of Quantity_3: = ".

    Number of Quantity_4: = ".

    Number of Quantity_5: = ".

    Number of Quantity_6: = ".

    Number of Quantity_7: = ".

    Number of Quantity_Total: = ".

    Date of Date_History: = ".

    Month_Year Varchar2 (15): = ".

    Number of Quantity_8: = ");

    Sorry I'm not familiar with PL/SQL tables...

    Thank you

    Help

    I can't go through your entire code. From there, you no need to use this plsql don't table as an input parameter because you do not pass anything... You're just fill with your values hard-coded... Then you can try the below stated

    DECLARE

    -declare the plsql table

    X_PWB_ORG_HIST_TBL APPS. XXINV_PWB_HIST_FCST_PUB. XXINV_PWB_ORG_HIST_TBL;

    BEGIN

    XXINV_PWB_HIST_FCST_PUB. GET_ORG_DETAILS (91, TO_DATE('02-FEB-2014','DD-MON-YYYY'), X_PWB_ORG_HIST_TBL);

    -The legacy output:

    BECAUSE me in X_PWB_ORG_HIST_TBL. FIRST... X_PWB_ORG_HIST_TBL. LAST

    LOOP

    -Add all columns to dbms_output print and test values

    DBMS_OUTPUT. PUT_LINE ('X_PWB_ORG_HIST_TBL =' |) X_PWB_ORG_HIST_TBL (i). Org_Hist_Index_Id | «, » || X_PWB_ORG_HIST_TBL (i). Item_Number);

    END LOOP;

    END;

  • Not able to manage the value 'Table Type' in my procedure, humble need help here

    Hi all

    I am facing a problem with below pl/sql block. The time I run it it works fine, but when I run the procedure only from the exact values (hardcoded), it throws error as below.

    [Error] Execution (38: 1): ORA-06550: line 2, column 1:

    PLS-00306: wrong number or types of arguments in the call to 'CREATE_ABNORMAL_BY_TRADER '.

    ORA-06550: line 2, column 1:

    PL/SQL: Statement ignored

    What I understand problem is, I use a Type of table herewhich works very well with my Pl/Sql block, but do not work when I run the same procedure of the value hard-coded.

    Please guide me how to handle this situation.

    Pl/Sql block [works absolutely well]:

    Declare

    lv_eff_from_dt DATE;
    lv_eff_to_date DATE;
    v_severity_codes_wl param_tbl: = param_tbl();
    lv_algo_id_wl sagedbo.alerts.algo_id%TYPE;

    Begin

    lv_eff_from_dt: = sage_utility.get_transaction_date('EFF_FROM_DATE');  -' 05-Aug-2013. '
    lv_eff_to_date: = sage_utility.get_transaction_date('EFF_TO_DATE');       -' 04-sep-2013. '

    lv_algo_id_wl: = sage_utility.get_code_values('ALERT_MODELS','GRAY_LIST');  -GLABNORMAL

    v_severity_codes_wl: = sage_utility.get_multi_parameter_value(1,'SEVERITY_CODE_WL'); -4.5

    SONARDBO.sage_generate_alert.create_abnormal_by_trader (lv_algo_id_wl, v_severity_codes_wl, lv_eff_from_dt, lv_eff_to_date, 'US');

    End;

    Pl/Sql block [does not] (by the way the same values but hard)

    Begin

    SONARDBO.sage_generate_alert.create_abnormal_by_trader ('GLABNORMAL', '4', 5, 5 August 2013 ', ' 04-Sep-2013', 'US');

    End;

    Error PLS-00306: wrong number or types of arguments in the call to 'CREATE_ABNORMAL_BY_TRADER '.

    I'm sorry that my question is not so generic, you cannot run on your computer. How should just guide me with the concept, I treat the values in table hardcodedly? (For testing of use)

    Thank you very much

    If your passage of type table, then you will need to run as below

    Begin

    SONARDBO.sage_generate_alert.create_abnormal_by_trader ("GLABNORMAL", param_tbl (' 4 ', ' 5'), August 5, 2013 ', ' 04-Sep-2013', 'US');

    End

    Means that you must call with the table type ("' hard coded values"). Here is the simple test. Take a look at this

    SQL > CREATE or REPLACE the TYPE nt_tab IS TABLE OF VARCHAR2 (50);

    2.

    Type of creation.

    SQL > CREATE OR REPLACE PROCEDURE test_proc (p_nttab nt_tab)

    2 AS

    3 v_nttab nt_tab: = p_nttab;

    4 BEGIN

    5 FOR me in 1.v_nttab. COUNTY

    6 LOOP

    7 DBMS_OUTPUT. Put_line (v_nttab (i));

    8 END OF LOOP;

    9 END;

    10.

    Created procedure.

    -Perform the procedure with only one value of type table

    SQL > EXEC test_proc (nt_tab ('KING'));

    KING

    PL/SQL procedure successfully completed.

    -Run procedure with the multi-value table type

    SQL > EXEC test_proc (nt_tab ('KING', 'AAAA', 'BBBB'));

    KING

    ABDELKADER

    BENAMER

    PL/SQL procedure successfully completed.

    Post edited by: 000000

    Post edited by: 000000

  • How to execute a SQL statement that is stored within a SQL Table

    Hello

    If someone please help me with the following problem I would be eternally grateful

    I have a SQL statement that is stored inside a certain SQL table, I want to use this SQL statement inside my PL/SQL procedure.

    Thought a simple solution was to get the SQL statement in a table, and then run it, but how could I do so exactly with PL/SQL? I only started to play with PL/SQL in the last days.

    Thanks in advance!

    This is what it looks like more or less:

    Display result for:

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

    SELECT TRIM (OBJ_VALU_TXT)

    OF OBJ_VALU_DOC

    WHERE TYPE_OBJET = 'FLD '.

    AND OBJECT_CODE = 15443

    AND OBJ_VALU_CD = 'CAB '.

    ORDER BYDOC_SEQ_NO

    00001

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

    SELECT

    VALUE (MAX (RECEIPT_NO) + 1,: OUT-COMP-FACTOR)

    THE FRONT DESK

    WHERE (RECEIPT_NO BETWEEN

    (: OUT-COMP-FACTOR AND: OUT TO A NUMBER) OR

    (RECEIPT_NO >: OUT-COMP-FACTOR AND)

    (: OUT-TO-NUMBER = 0)

    Here's a demo of your condition.

    create table t (col1 varchar2 (200));

    table created

    insert into values t ('select * from double ');

    1 row inserted

    declare
    v_col varchar2 (200);
    v_val varchar2 (200);
    Start

    Select col1 in t v_col;

    run immediately v_col in v_val;
    dbms_output.put_line (v_val);
    end;

    -----
    X

    Use in the clause, you can use as many variables as needed. But the basic approach remains the same.

    But storage in DB SQL is not an efficient design.

    Ishan

  • PL/SQL tables

    Hello guys,.
    I have a few questions about the PL/SQL tables

    (1) if I don't specify the 'INDEX BY' clause, they are indexed by PLS_INTEGER default, right?

    (2) consider this package specification
    CREATE OR REPLACE PACKAGE Testxyz AS
    
    TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
    
    PROCEDURE TestNumber(ptab_Numbers IN tab_Numbers := NULL);
    
    
    END Testxyz;
    So I created a table (I hope it's standard indexed by type of data pls_integer) and I am in him passing as parameter to a procedure. Because I want this parameter be optional I assign null inside.

    Now, I change the table definition for:
    CREATE OR REPLACE PACKAGE Testxyz AS
    
    TYPE tab_Numbers IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
    
    PROCEDURE TestNumber(ptab_Numbers IN tab_Numbers := NULL);
    
    
    END Testxyz;
    Try to compile it and you get:
    Error (5.53): PLS-00382: expression is of the wrong type

    Why?

    (3) because I need this optional parameter, I use the first statement:
    CREATE OR REPLACE PACKAGE Testxyz AS
    
    TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
    
    PROCEDURE TestNumber(ptab_Numbers IN tab_Numbers := NULL);
    
    
    END Testxyz;
    Now I create an anonymous block, and you want to set something in the table
    DECLARE
       vtab_Numbers TESTXYZ.tab_Numbers;
    BEGIN
    
       vtab_Numbers(1) := 5;
    
    
    END;
    /
    When you try to run it, I got:
    06531 00000 - 'refers to an uninitialized collection.

    Can someone help me understand this problem?
    Is it possible to have input of type PL/SQL table setting and have a standard null, are assigned?

    Thanks, Dan

    (1) if I don't specify the 'INDEX BY' clause, they are indexed by PLS_INTEGER default, right?

    N ° or somehow.

    More critical, and using official terms of [url http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#CHDBHJEI] documentation so that we don't get into unnecessary arguments about the correct terms for these features, it's the difference between types of ASSOCIATIVE TABLE and the IMBRIQUEE TABLE collection.

    If you omit the "INDEX BY" clause, it is a type of TABLE IMBRIQUEE collection. A type of TABLE IMBRIQUEE is always indexed by PLS_INTEGER.

    When you include the ' INDEX OF ', this is an ASSOCIATIVE ARRAY.

    (2) consider this package specification
    Try to compile it and you get:
    Error (5.53): PLS-00382: expression is of the wrong type

    Why?

    Because you cannot assign NULL to an ASSOCIATIVE ARRAY.

    In the same way, you cannot do this:

    SQL> DECLARE
      2   TYPE tab_Numbers IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
      3   v1 tab_Numbers;
      4  BEGIN
      5   v1 := NULL;
      6  END;
      7  /
     v1 := NULL;
           *
    ERROR at line 5:
    ORA-06550: line 5, column 8:
    PLS-00382: expression is of wrong type
    ORA-06550: line 5, column 2:
    PL/SQL: Statement ignored
    
    SQL> 
    

    If you want two entry points to TestNumber with an ASSOCIATIVE ARRAY or NULL then overload the procedure.

    If you want to call a procedure with a TABLE IMBRIQUE collection type you can the default empty:

    SQL> CREATE OR REPLACE PACKAGE Testxyz
      2  AS
      3   TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
      4   PROCEDURE TestNumber(ptab_Numbers IN tab_Numbers DEFAULT tab_Numbers());
      5   PROCEDURE TestNumber;
      6  END Testxyz;
      7  /
    
    Package created.
    
    SQL> 
    

    (3) because I need this optional parameter, I use the first statement
    When you try to run it, I got:
    06531 00000 - 'refers to an uninitialized collection.

    Because you have not initialized it.

    Different collection types require different semantics.

    SQL> DECLARE
      2   TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
      3   v1 tab_Numbers;
      4  BEGIN
      5   v1(1) := 5;
      6  END;
      7  /
    DECLARE
    *
    ERROR at line 1:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 5
    
    SQL> DECLARE
      2   TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
      3   v1 tab_Numbers := tab_Numbers();
      4  BEGIN
      5   v1(1) := 5;
      6  END;
      7  /
    DECLARE
    *
    ERROR at line 1:
    ORA-06533: Subscript beyond count
    ORA-06512: at line 5
    
    SQL> DECLARE
      2   TYPE tab_Numbers IS TABLE OF PLS_INTEGER;
      3   v1 tab_Numbers := tab_Numbers();
      4  BEGIN
      5   v1.extend();
      6   v1(1) := 5;
      7  END;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • Help with PL/SQL table

    Hi all

    Newbie when it comes to PL/SQL tables...

    Can someone explain to me why it works and how exactly I can do the following without triggering an error?

    I have a function that accepts a PL/SQL table like in parameter.

    The PL/SQL table is defined as...
    Type TTimeTable is table of xxtzg_otl_iface_stg%rowtype index by binary_integer;
    the xxtzg_otl_iface_stg table has many columns including error_message and error_flag. If I find an error, I want to update the error_message and error_flag function. If I can get it works I will then modify the function to return to the table of PL/SQL instead of BOOLEAN
    FUNCTION validate_timecard (pTimeTable IN TTimeTable
                                                 ) RETURN BOOLEAN IS
    
      lc_module            CONSTANT VARCHAR2(25)        := 'validate_timecard';
      lEmployeeCount    PLS_INTEGER;
      lEmployeeError     VARCHAR2(1000);
      lErrorCount          PLS_INTEGER :=0;
      
      BEGIN
    
         FOR i IN 1 .. NVL(pTimeTable.COUNT,0) LOOP                                   
                                             
         xxtzg_concurrent_utils_pkg.write_log(  p_package =>  gc_package
                                                                , p_module  =>  lc_module
                                                                , p_text    =>  'Processing timecard for employee_number: '||pTimeTable(1).employee_number
                                                               );               
       
         -- Call validations before submitting the timecard to the API
         --validate employee
    
            begin
               select count(*)
                 into lEmployeeCount
                 from per_all_people_f
                where employee_number = pTimeTable(1).employee_number;
                
                if lEmployeeCount = 0 then
                
                -- Set the errors
    
                -- This assignment below does not work, I get an error message saying...
                --[Error] PLS-00363 (137: 27): PLS-00363: expression 'PTIMETABLE.ERROR_MESSAGE' cannot be used as an assignment target
    
                PTimeTable(i).error_message :=  'Employee Number '||pTimeTable(1).employee_number||' is not a valid employee';
                PTimeTable(i).error_flag := 'Y';
    
                end if;
                
            end;    
            
         END LOOP; 
         
         IF lErrorCount = 0 THEN 
         RETURN TRUE;
         ELSE
         RETURN FALSE;
         END IF;
                                               
      END;

    blue72TA wrote:

    FUNCTION validate_timecard (pTimeTable IN TTimeTable
    ) RETURN BOOLEAN IS
    ...
    
    -- This assignment below does not work, I get an error message saying...
    --[Error] PLS-00363 (137: 27): PLS-00363: expression 'PTIMETABLE.ERROR_MESSAGE' cannot be used as an assignment target
    
    PTimeTable(i).error_message :=  'Employee Number '||pTimeTable(1).employee_number||' is not a valid employee';
    PTimeTable(i).error_flag := 'Y';
    

    Your table is declared as IN only (the default if you do not explicitly set it), so you are not allowed to change its attributes in all respects, IN = read-only.

    If you want to be able to modify the values of a parameter, it must be declared as OUT parameters.

  • doubt in PL/SQL table

    If I said PL/SQL table and populated with 10 values.

    If I want to find a perticular values are in the list populated how can I find.say I have values from 1 to 10.
    and I want to find if 9 is in the list.
    I tried with loop. Is there another way. I use 10g.

    declare
    tr_nm number_array;
    i the number;
    Start
    I'm in 1.10
    loop
    tr_nm.extend;
    tr_nm (i): = i;
    end loop;
    for j from 1... tr_nm. Count
    loop
    If tr_nm (j) = 9 then
    i: = i + 1;
    end if;
    end loop;
    If i > 0 then
    null;
    end if;
    end;

    Please try this code
    Note: this code runs from 10 g.

    DECLARE
    type num_type is table of NUMBER;
    v_num_arr num_type;
    v_num number;
    v_var number :=9;
    BEGIN
    select level
    bulk collect into v_num_arr
    from dual connect by level <=10;
    
    dbms_output.put_line('Count - '||v_num_arr.count);
    
    if v_var member of v_num_arr then
     dbms_output.put_line('Found ');
    end if;
    
    END;
    

Maybe you are looking for

  • Qosmio X 70 overheating while game

    So that the computer Gaming crash dumps because that too hot. Computer is 2 days old if it isn't dirty grids.The settings of the software I can implement to help out?

  • On Satellite L750 battery problem

    Hello I just bought a laptop Toshiba Satellite L750. The first turn on the indicator of battery said "plugged in, not support." So after reading the forums, I found that I had to update the BIOS I did and now charges the battery. BUT I get about 1 1/

  • Verizon blocks access to sites

    I don't know what to do. I tried to get on one of the sites that I have used, and the screen becomes reddish and I get a message that Verizon has blocked access to the site and told me to contact my administrator. I thought I was the administrator. I

  • A PC on the network does not connect to internet

    This has proved to be very difficult.  A PC on my network has been to connect to the internet.  I thought it was because I installed a new router, especially when I moved the PC to connect directly to my cable modem - when he was working.  But I also

  • Best way to use Windows Update - Primo

    Hello world I just did a complete reset of my computer Windows 8.  I want to upgrade to 8.1 Windows since everything is wiped clean.  But first, I have apparently 165 important Windows updates installed. The last time I tried to do a reset before Win