Extend the pl/sql table function

declare
type aar_test is table of the varchar2 (100)
index of directory;
aar_main aar_test;
Start
aar_main.extend;
aar_main (aar_main. (Last): = 'expand the cell. "
end;


He's back a mistake... it's possible? If so how... plzzzzzzzz help me...

Hello..

Please go through this...!

EXTEND
*******
This procedure has three forms. EXTEND appends one null element to a collection.
EXTEND(n) appends n null elements to a collection.
EXTEND(n,i) appends n copies of the ith element to a collection.

EXTEND operates on the internal size of a collection.
If EXTEND encounters deleted elements, it includes them in its tally.

You cannot use EXTEND with associative arrays.

Concerning
KPR

* If this answer is correct, then mark it as correct answer.
* If this answer is useful, then mark it as a useful answer.

Tags: Database

Similar Questions

  • Insert rows in the PL/SQl table

    Hello
    I have a PL/SQl table that I filled through bulk collect and now I'm trying to loop through the table (actually quite a few nested loops)... Now in one of my curls, I might need to insert a new row by splitting the field in the existing row in the table. Can I insert the line in the pl/sql table in the loop without affecting the "FOR i IN tab.first... Tab.Last' loop?
    Also, what would be the index of such a line inserted into the table. Can I access it with tab.last + 1 (doesn't look like it can be done if I insert into various levels of loops).
    OR
    If I insert the lines insde loops nested, then I can access the new lines as soon as I close all the loops and open a new loop? The new lines will be at the last table.

    Any help will be appreciated...

    The expression v_arr. LAST gives the index of the last entry, so you can refer to this element as

    v_arr(v_arr.LAST)
    

    Then the attributes of this element will be

    v_arr(v_arr.LAST).attr
    

    for example

    DECLARE
        TYPE table_defs_tt IS TABLE OF user_tables%ROWTYPE INDEX BY PLS_INTEGER;
        v_mytables table_defs_tt;
    BEGIN
        SELECT * BULK COLLECT INTO v_mytables
        FROM   user_tables
        WHERE  ROWNUM <= 100;
    
        DBMS_OUTPUT.PUT_LINE(v_mytables(v_mytables.LAST).table_name);
    END;
    
  • How to remove duplicates from the PL - SQL table?

    Hi gurus,

    I have a PL - SQL table with the following structure
    Authors (SR_NO, Auth_Code, Change_Date, cost)

    This table is filled using a slider. However, this table can have a few lines in double (for column (Auth_Code)
    for example
    SR_NO      Auth_Code       Change_Date                       Cost
    1               A1             14-FEB-09 08.18.47 AM          11.00
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    4               A1             15-FEB-09 07.00.00 AM        789.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I need to get the above result set select the separate lines of Auth_Code including the Change_Date is maximum (and store in another PL - SQL table for treatment later or even the removal of this table will be also!)

    of the data A1 is duplicated and a maximum Change_Date above = 15 February 09 08.00.02 AM.
    Where my PL - SQL Table that results must have given below
    SR_NO      Auth_Code       Change_Date                       Cost
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I'm not very aware of the PL - SQL tables and there is no chance to change the existing cursor that fills the data in this table PL - SQL.
    I guess that I need to compare each record of PL - SQL table with others, but do not know how to do this.

    Could you please help?

    Hello

    Like this?:

    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    
    SQL>
    SQL> with data as(
      2  select 1 as SR_NO, 'A1' as Auth_Code, to_date('14-FEB-09 08.18.47', 'dd-mon-yy hh24:mi:ss') as change_date,    11.00 as cost from dual union all
      3  select 2 as SR_NO, 'A2' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,  2839.00 as cost from dual union all
      4  select 3 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 08.00.02', 'dd-mon-yy hh24:mi:ss') as change_date,  1299.00 as cost from dual union all
      5  select 4 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 07.00.00', 'dd-mon-yy hh24:mi:ss') as change_date,   789.00 as cost from dual union all
      6  select 5 as SR_NO, 'A3' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,   312.00 as cost from dual union all
      7  select 6 as SR_NO, 'A4' as Auth_Code, to_date('14-FEB-09 08.19.02', 'dd-mon-yy hh24:mi:ss') as change_date,   233.00 as cost from dual)
      8  select * from data d where change_date = (select max(change_date) from data d2 where d.auth_code = d2.auth_code);
    
         SR_NO AUTH_CODE CHANGE_DATE       COST
    ---------- --------- ----------- ----------
             2 A2        14/02/2009        2839
             3 A1        15/02/2009        1299
             5 A3        14/02/2009         312
             6 A4        14/02/2009         233
    
    SQL>
    

    Kind regards

  • Select DataSet from the pl/sql table

    Hi Experts,

    I need to create a metric of OEM 12 c extensions. I must create a pl/sql code that can return results to OEM.

    The following code works in OEM. But the problem is that I need to create a permanent table for this case.

    Could you please tell any other option available to do this without creating additional objects at the database level?

    Based on the requirement of the OEM, the end of the script, I have to do something like ' open: 1 to select in the <>' to return the results in a table.

    Thank you.

    ###########################################################################################

    DECLARE

    TYPE cur_type IS REF CURSOR;

    CURSOR c1 IS

    SELECT distinct (owner: '.) ' || queue_table) as queue_table FROM dba_queues;

    l_cur_string VARCHAR2 (200);

    C2 cur_type;

    v_queue VARCHAR2 (128);

    number of v_ready;

    BEGIN

    run immediately "remove sys.testing";

    FOR v_queue_table IN c1 LOOP

    l_cur_string: ='select q_name, count (*) from ' | v_queue_table.queue_table | ' where State = 0 or (State = 1 and sysdate > nvl (delay, enq_time)) q_name group ';

    OPEN c2 FOR l_cur_string;

    LOOP

    C2-FETCH INTO v_queue, v_ready;

    OUTPUT WHEN c2% NOTFOUND;

    run immediately ' insert into sys.testing values (: v_queue,: v_ready) "using v_queue, v_ready;"

    OPEN: 1 for select * from sys.testing;

    commit;

    END LOOP;

    CLOSE C2;

    END LOOP;

    END;

    ###################################################################################

    In addition, committing inside of cursor loops are false.  You should never engage at the end of a business logic operation, NEVER in cursor loops.

    Something along these lines (untested) is probably what you want:

    var refcursor rc;

    declare

    SQL varchar2 (32767).

    Start

    SQL: = q'[select

    table_name,

    TO_NUMBER)

    ExtractValue)

    XmlType)

    dbms_xmlgen. GetXml ("select count (*) c to ' |") table_name | ((' where State = 0 or (State = 1 and sysdate > nvl (delay, enq_time)) q_name group '))

    (("/ LINES/LINES/C ')) County

    from (select distinct owner |'.) ' || queue_table as table_name dba_queues)]';

    Open: rc for sql.

    end;

    /

    print rc;

  • Element in the pl/sql table

    Hi all

    I have an array of integers that contains thousands of values such as 100,200,300,400,5000.

    Now, I want to know whether the table contains the value of 377. What should be my corner.

    There is doesn't work here because it only works with the item number. Here, I have only the content.

    Concerning

    Rajat

    Types can be defined in SQL and PL/SQL. The collections based on the SQL types can be used in SQL statements.

    set serveroutput on
    declare
      lt_nums sys.odcinumberlist := sys.odcinumberlist(1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99);
      l_result number;
    begin
      select count(*) into l_result
      from table(lt_nums)
      where column_value = 55;
      dbms_output.put_line('Number of found occurences = ' || l_result);
    end;
    /
    

    anonymous block filled

    Number of found rows = 1

    Post edited by: Ashton stew - I see RP says the same thing (and more) while I was typing my response. Well...

  • Using the PL - SQL CAST function

    Hi friends,

    I write a stored procedure that attempts to convert a string returned by a function in a fixed-size varchar (3).


    ex:

    newChar varchar (3);


    newChar: = cast (fn_getValue (aInputValue) as varchar (3));

    This is the return type of the function ( fn_getValue) is varchar2 (4000), I should keep the return type as varchar2 because size should vary according to the entry.

    When I run the procedure gives:

    PLS-00103: encountered the symbol "(" quand attend une deles de valeurs suivantes:) "

    . ) @ %

    Please, help me to meet my needs.

    Thanks for your reply...

    It is a generic function and the 3 I've mentioned is just an example, it can change on different cases.

    I tried with select cast (fn_getValue as varchar (aInputValue) (3)) in the double newChar; his work...

    @John stegeman

  • 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.

  • Pass Pl/sql table in the USING clause in the EXECUTE IMMEDIATE statement

    Getting error when I try to pass the PL/SQL table in the USING clause in the EXECUTE IMMEDIATE statement:

    Declare
    result NUMBER;
    TYPE values_tab IS TABLE OF NUMBER INDEX OF directory;
    lv_tab values_tab;
    lv_exp varchar2 (300);
    lv_exec varchar2 (300);
    BEGIN
    lv_tab (1): = 5;
    lv_tab (2): = 48;
    lv_tab (3): = 7;
    lv_tab (4): = 6;
    lv_exp: = ': + b1: b2 + (: b3 *: b4)';
    lv_exec: = 'SELECT'. lv_exp | ' THE DOUBLE '.

    IMMEDIATE EXECUTION
    lv_exec
    IN
    result
    USING
    lv_tab;
    DBMS_OUTPUT. Put_line (result);

    END;
    /

    Error on line 1
    ORA-06550: line 20, column 12:
    PLS-00457: expressions must be SQL types
    ORA-06550: line 15, column 8:
    PL/SQL: Statement ignored


    I am trying to evaluate the expression ': + b1: b2 + (: b3 *: b4) "which is stored in the table. This table has different expressions (expressions about 300). I want to use the bind variable in the expression because each expression evaluated thousands of time may be more in some cases. If I use bind variable can he fill pool.

    Is there a way I can pass parameters with the HELP of (IN) dynamically instead of write "help lv_tab (1), lv_tab (2), lv_tab (3), lv_tab (4)? As number of change of the input parameters depend on the expression in the table.

    If it is possible please suggest any other ideas/approaches

    Help, please...

    Published by: satnam on June 11, 2009 11:50

    Well, you keep changing faster reqs that I can follow. In any case, assuming that N-th variable bind (left to right) corresponds to n-th collection item:

    Declare
        result NUMBER;
        lv_tab values_tab := values_tab();
        lv_exp varchar2(300);
        lv_exec varchar2(300);
        lv_i number := 0;
    BEGIN
        lv_tab.extend(4);
        lv_tab(1) := 5;
        lv_tab(2) := 48;
        lv_tab(3) := 7;
        lv_tab(4) := 6;
        lv_exp := ':5000135+:5403456+(:5900111*:5200456)';
        lv_exec := lv_exp;
        While regexp_like(lv_exec,':\d+') loop
          lv_i := lv_i + 1;
          lv_exec := REGEXP_REPLACE(lv_exec,':\d+',':b(' || lv_i || ')',1,1);
        end loop;
        lv_exec := 'BEGIN :a := ' || lv_exec || '; END;';
    DBMS_OUTPUT.PUT_LINE(lv_exec);
    EXECUTE IMMEDIATE lv_exec USING OUT result,IN lv_tab;
    DBMS_OUTPUT.PUT_LINE(result);
    END;
    /
    BEGIN :a := :b(1)+:b(2)+(:b(3)*:b(4)); END;
    95
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • How to configure the settings of sql stored function

    Hello

    I use jdeveloper 11.1.2.3.0

    I have the below sql stored function
    function get_data(p_id     in number,
                      p_date   in date,
                      p_msg    out varchar) return number is
     .......
    
    end get_data;
    I would like to know how exactlly I should call this function of my AppModuleImpl.
    I tried several ways to set the parameters, but I'm getting java.sql.SQLException: Error invalid column index.

    Could you give me the correct code for this case?

    Thank you very much!

    check the docs [url http://docs.oracle.com/cd/E16162_01/web.1112/e16182/bcadvgen.htm#insertedID6] calling stored procedures and functions

  • How to find the third element table pl/sql ina

    Hello friends,

    I have a pl/sql table of NUMERIC type, where am store all salaries of employees.

    I want to find the third bigger payday by browsing through the pl/sql table.

    Pls advice.

    Thank you/kumar
    DECLARE
        TYPE max_earnings_type IS TABLE OF NUMBER;
        TYPE max_earnings_sorted_type IS TABLE OF NUMBER
          INDEX BY BINARY_INTEGER;
        max_earnings_tab        max_earnings_type;
        max_earnings_tab_sorted max_earnings_sorted_type;
        m number;
    BEGIN
        SELECT  sal + comm
          BULK COLLECT
          INTO  max_earnings_tab
          FROM  emp;
        FOR v_i in 1..max_earnings_tab.count LOOP
          IF max_earnings_tab(v_i) IS NOT NULL
            THEN
              max_earnings_tab_sorted(max_earnings_tab(v_i)) := 1;
          END IF;
        END LOOP;
        m := max_earnings_tab_sorted.last;
        DBMS_OUTPUT.PUT_LINE('MAX value in PL/SQL table is ' || nvl(to_char(m),'NULL'));
        m := max_earnings_tab_sorted.prior(m);
        DBMS_OUTPUT.PUT_LINE('Second MAX value in PL/SQL table is ' || nvl(to_char(m),'NULL'));
        m := max_earnings_tab_sorted.prior(m);
        DBMS_OUTPUT.PUT_LINE('Third MAX value in PL/SQL table is ' || nvl(to_char(m),'NULL'));
    END;
    /
    MAX value in PL/SQL table is 2650
    Second MAX value in PL/SQL table is 1900
    Third MAX value in PL/SQL table is 1750
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • How to find the second largest in a pl/sql table

    Hello friends,

    I want to find the first and second maximum items in a pl/sql table.

    Here's the code...

    DECLARE
    Max_earnings_type TYPE TABLE IS NUMBER;
    max_earnings_tab max_earnings_type: = max_earnings_type();
    number of v_count: = 0;
    number of v_max_earnings;


    Can someone give me how to find the maximum first max and second in the type of the given table.

    appreciate your help.

    Thank you/kumar

    Published by: kumar73 on October 21, 2010 09:42

    kumar73 wrote:

    When I tried to implement your logic in my application, I get the following error...

    PL/SQL: digital or value error: NULL index key value table

    What happens if the PL/SQL table has NULL values. Question is how you want to handle NULL values. You want to ignore nulls as GROUP BY do? If you want to consider NULL values, you can say if you want to order the NULLS FIRST or NULLS LAST. I guess that logical GROUP BY:

    DECLARE
        TYPE max_earnings_type IS TABLE OF NUMBER;
        TYPE max_earnings_sorted_type IS TABLE OF NUMBER
          INDEX BY BINARY_INTEGER;
        max_earnings_tab        max_earnings_type;
        max_earnings_tab_sorted max_earnings_sorted_type;
    BEGIN
        SELECT  sal + comm
          BULK COLLECT
          INTO  max_earnings_tab
          FROM  emp;
        FOR v_i in 1..max_earnings_tab.count LOOP
          IF max_earnings_tab(v_i) IS NOT NULL
            THEN
              max_earnings_tab_sorted(max_earnings_tab(v_i)) := 1;
          END IF;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.last),'NULL'));
        DBMS_OUTPUT.PUT_LINE('Second MAX value in PL/SQL table is ' || nvl(to_char(max_earnings_tab_sorted.prior(max_earnings_tab_sorted.last)),'NULL'));
    END;
    /
    MAX value in PL/SQL table is 2650
    Second MAX value in PL/SQL table is 1900
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT  sal + comm
      2    FROM  emp;
    
      SAL+COMM
    ----------
    
          1900
          1750
    
          2650
    
          1500
    
      SAL+COMM
    ----------
    
    14 rows selected.
    
    SQL>
    

    SY.

  • 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.

  • parallel in pipeline table function

    Hi all

    To "allow the parallel pipeline" table function, what I need to turn a query parallel session first?

    I read a few white papers or web pages on map and reduce implemented with function table Oracle and see that, based on the table.

    Use the cursor in the loop to get a line, run out! This replaces SQL pl/sql.

    What is the cost that must be paid according to the table?

    Finally, how can I confirm that Oracle has put the table function in parallel?

    Best regards

    Leon

    user12064076 wrote:

    In my application, I wrote stored procedures that return a collection of user-not of the types of objects to Java.

    Flawed approach using memory expensive private server (PL/SQL PGA) caching SQL data and then push this data to the client - when the customer can use instead the more scalable and higher shared cache buffer memory instead.

    With the types of objects, we can remove most of the redundent data.

    This statement makes no sense that it is the same for SQL and sliders. And remove redundant data is preferable to the SQL itself - through partitioning engine pruning, predicates, only by selecting the columns there is place for the projection of SQL and so on.

    This OO design reduces the load on the network and makes it easy for Java to parse.

    Incorrect answer. It does not reduce network load - it can actually increase. Regarding Java 'parsing' - it's wrong from the beginning approach if the customer is required to analyze the data it receives from the server database. The analysis requires time CPU. Many average general processor muscle which will degrade the performance of analysis.

    You may be using the analysis out of context here? Find it me hard to believe that one could design an application and use a server database in this way. The analysis of means for example to receive XML data (text) and then he analysis in an object - like structure for use.

    Data of the database must be recovered by the customer in a binary structured format and not in a free format that requires the client to analyze in a structured format.

    But the problem is that we accumulate all data in memory first and push them to the client as a whole. If it's too huge, ORA-22813 occurs.
    This is why I intend to use the table of piplelined function.

    How that will solve the problem?

    As I followed your logic:
    (1) you do not use the cursor for some obscure (and probably completely unjustified) reason.
    (2) you may not return large collection PL/SQL variables without significantly dent PGA (process private memory) on the server and running into errors (this approach is conceptually incorrect anyway)
    (3) you are now using an array of pipeline that executes PL/SQL code to execute SQL code - and in turn must be executed by the client as a SQL using a slider

    So why put all the other moving parts (the pipeline code) between the two when the customer
    (a) must use SQL to access?
    (b) create a cursor?

    If, as you say, I returned a cursor, it would be very difficult for Java organize data.

    A table of pipeline must be able to be used through a cursor. All the DML statements from a client by Oracle are analyzed as cursors.

    Read the language PL/SQL Oracle® Database reference guide section on ' + chaining Pipelined Table Functions for Multiple Transformation + ".

    The format using a pipeline is (from the manual):

    SELECT * FROM TABLE(table_function_name(parameter_list))
    

    The "+ pipeline + ' is created by the SQL engine-, he need SQL to execute the PL/SQL code via the function TABLE() SQL.

    You said that the reason to use a pipeline transforms a structure of relational data stored in a structure of the object. You don't need a pipeline for it. Plain vanilla SQL can do the same thing, without the fixed costs of use PL/SQ, SQL data recovery and change within the pipeline between PL/SQL and SQL context engines.

    You simply call the constructor of the class of object in the projection of SQL and the cursor SQL returning the instantiated objects. For example

    create or replace type TEmployee is object(
     .. property definitions ...
    );
    
    create or replace type TEmployeeCollection is table of TEmployee;
    
    select
      TEmployee( col1, col2, .., coln ) as EMP_COLLECTION
    from emp
    where dept_id = :0
    and salary > :1
    and date_employed >= :2
    order by
      salary, date_employed
    

    No need for PL/SQL code. No need for a pipeline. The client will open the cursor and extraction of objects in a collection. The same approach that the customer would have used during extraction of a cursor on a table of pipeline function.

    Pipelines are best used as a process of transformation of data where only SQL cannot perform the transformation. I never in many years of design and writing applications used Oracle PL/SQL pipeline into production on a SQL table. Simply because the SQL itself is capable and powerful enough to do the job - and do it faster and better.

    I used pipeline is to transform the data from external sources into sets of SQL data. For example, a pipe on a web service. When the code PL/SQL of the constructions of the SOAP envelope, the HTTP call, analyzes the XML and returns the content in form of lines and columns - that allows to run a SQL SELECT on web-service-turned-into-a-SQL-table.

    If you'd told me that Leon - it seems to me that your approach is a typical approach to Java that has very little understanding of the concepts of database and Oracle databases. You can't deal with Oracle as a simple persistence layer. You can't treat SQL and PL/SQL as a simple i/o interface for the extraction of data from Oracle and grinding that in Java. Not if you think that your system to run Java and scaling.

    Rethink the Oracle layer, use properly - and your application will occur and will scale. Guaranteed.

    However, from my experience, many J2EE developers choose to treat the Oracle as a black box, not further that a kind of file system loaded to store structured data and try to do it in the Java layer. And this fail. And I saw him failing - of the jaw dropping kind epic failures (knocking all the national newspapers and media as a result and an impact on ordinary people who have to deal with the Government).

    And it's a shame... SQL and PL/SQL are superior to Java in this regard and are the layers much more able to cope and a power of data in the database. Example of the real world - largest table in our busiest database develops between 350 and 450 million lines per day and all our calculations of the data in this table is inside the database layer - and not in a layer of Java. Oracle performs and scales beautifully... when used correctly.

  • 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.

Maybe you are looking for

  • Cannot rename the hard drive partitions.

    Original title: cannot rename. I can't rename my portions of hard disk. When I rename it. It changes automatically in the local drive.

  • Installation interrupted and stuck at the recovery screen

    It's a new hard drive and during the installation process of vista that power was cut off, now at the start of the central unit, it goes directly to the recovery screen and will not continue. We have all discs from nec for vista and drivers and other

  • Factory reset while a single L7580

    I'm getting rid of my HP L7580 all in one and although I deleted my fax log, nbr name and fax number of the installation of the printer itself, when I print the Fax log just to be sure that nothing about it, my name appeared again.   How can I get ri

  • Take control of the buttons on the player of BB

    Hi all I have a problem, I want to play mp4 video using my application I'm doing Registry reg = Registry.getRegistry("com.arctouch.alarmnet.screens.MediaPlay"); Invocation invocation = new Invocation(videoName, null,BlackBerryContentHandler.ID_MEDIA_

  • Do not delete to reset Media Player

    My Media Player is corrupted, so I tried the command "%LOCALAPPDATA%\Microsoft\Media Player" and tried to delete all the files in the folder, but when I try to delete the folder "CurrentDatabase_372", it won't let me. It says 'open in peripheral wind