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

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 from an oracle table

    Hello

    I downloaded a piece of data in xml format in oracle and successful upload but trying to retrieve the data it reterieve 0 records. Oracle version is given below:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    create table temp_loading_lob(
                                            xml_id varchar2(3),
                                            q_clob CLOB
                                             )
    nologging
    
    
    create table temp_loading_xml
    nologging as
    select xml_id,xmltype( q_clob) q_xml
    from temp_loading_lob;
      
    XMl Data
    
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <Root xmlns="http://www.w3.org/2000/10/XMLSchema">
         <Accounts ApplicationVersion="7.2.1.6 (10-02-2012)" Database="Q" DateExported="20120813">
              <Account AccountID="QF8AA000">
                   <AccountName>124 On Brunswick Bed &amp; Breakfast</AccountName>
                   <Addresses>
                        <Address AddressID="aQF8AA000YMY">
                             <Description>Physical</Description>
                             <Address1>124 Brunswick Drive</Address1>
                             <Address2>Brunswick Park - RD 4</Address2>
                             <Address3></Address3>
                             <Suburb></Suburb>
                             <City>Rotorua</City>
                             <Postcode></Postcode>
                        </Address>
                        <Address AddressID="aQF8AA000WXX">
                             <Description>Postal</Description>
                             <Address1>PO Box 7365</Address1>
                             <Address2></Address2>
                             <Address3></Address3>
                             <Suburb>Te Ngae</Suburb>
                             <City>Rotorua</City>
                             <Postcode>3042</Postcode>
                        </Address>
                   </Addresses>
    </Accounts>
    </Account>
    </Root>
    
    Query used to reterive data 
    
    select po.*
    from temp_loading_xml p,
         XMLTable('/Accounts/Account'
                   PASSING p.q_xml
                   COLUMNS
                      AccountID varchar2(20) PATH '@AccountID'
                      ,AccountName varchar2(20) PATH 'AccountName'                  
                                  )po
    I am trying to catch my mistake but impossible to repair. Any help will be ge greatly appretiated. How can I close my thread?

    Best regards
    Zaid

    Mark the thread as 'Response' (as you already have) and choose 'Useful' or 'Correct' (or no) for the positions in question.

  • 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);
    ...
    
  • Retrieve data from PL/SQL block and generate the UNIX data file

    Hi all

    I comply the following Unix Shell Script code block. The following code was generated the file count_curdate.txt with all need info. The query gives the number of records, the partition_dt group

    ABC ='sqlplus-s < < of folklore > count_curdate.txt
    uname/paswd@ConnectString
    SET THE OFF POSITION;
    SELECT COUNT (*) | «, » || partition_dt of the XYZ group by partition_dt;
    "exit";
    END '

    But now I need to change the above code to use dbms_application_info.set_module in it. Could someone let me know how to generate the file using PL/SQL in Shell Script block. I have tried following written code, but it generates count_curdate.txt file with 0 bytes.

    ABC ='sqlplus-s < < of folklore > count_curdate.txt
    uname/paswd@ConnectString
    Set serveroutput on;
    SET THE OFF POSITION;
    Set feedback off;
    BEGIN
    DBMS_APPLICATION_INFO.set_module (' shm.ksh ',' get account per day ");
    FOR again IN (SELECT COUNT (*):) «, » || partition_dt as 'DCount"of the XYZ of partition_dt group);
    LOOP
    DBMS_OUTPUT. Put_line (reccur. DCount);
    END LOOP;
    end;
    /
    "exit";
    END '

    Hello, your PL/SQL is not successfully completed, i.e.,.

    This:

    ABC=`sqlplus -s < count_curdate.txt
    uname/paswd@connectstring
    set serveroutput on;
    SET HEADING OFF;
    set feedback off;
    BEGIN
    dbms_application_info.set_module ('shm.ksh','get count by day');
    FOR reccur IN (SELECT COUNT(*)||','||partition_dt as "dcount" from XYZ group by partition_dt);
    LOOP
    DBMS_OUTPUT.PUT_LINE(reccur.dcount);
    END LOOP;
    end;
    /
    exit;
    END`
    

    Should be this:

    ABC=`sqlplus -s < count_curdate.txt
    uname/paswd@connectstring
    set serveroutput on;
    SET HEADING OFF;
    set feedback off;
    BEGIN
    dbms_application_info.set_module ('shm.ksh','get count by day');
    FOR reccur IN (SELECT COUNT(*)||','||partition_dt as "dcount" from XYZ group by partition_dt);
    LOOP
    DBMS_OUTPUT.PUT_LINE(reccur.dcount);
    END LOOP;
    end;
    /
    exit;
    EOF`
    
  • SOA calling a MS SQL table to insert data.

    Hello
    I configured a XA driver to insert data into the MS SQL Server table. When I execute the stream with a SOAP user interface. I was able to insert the data from MS SQL table. But in the end, the transaction is rolled back.


    I would ask you
    < soapenv:Envelope xmlns:soapenv = 'http://schemas.xmlsoap.org/soap/envelope/' xmlns:mvn = "http://xmlns.oracle.com/MVNEIDM/MVNESelfRegistration/MVNESelfRegistration" >
    < soapenv:Header / >
    < soapenv:Body >
    < mvn:MVNESelfRegistrationRequest >
    < mvn:subscriberId > 12345 < / mvn:subscriberId >
    < mvn:Keyword > 456 < / mvn:Keyword >
    < mvn:completionDt > 2013-02-06 T 16: 24:06.952 < / mvn:completionDt >
    < mvn:expirationdt > 2013-02-06 T 16: 24:06.952 < / mvn:expirationdt >
    < / mvn:MVNESelfRegistrationRequest >
    < / soapenv:Body >
    < / soapenv:Envelope >


    Erros on SOAP UI are:

    < env:Envelope = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:env >
    < env:Header / >
    < env:Body >
    < env:Fault >
    env:Server < faultcode > < / faultcode >
    incorrect object name < faultstring > [FMWGEN] [SQLServer JDBC Driver] [SQL Server] ' dbo. SelfRegistration'. < / faultstring >
    < faultactor / >
    < detail >
    < exception / >
    < / details >
    < / env:Fault >
    < / env:Body >
    < / env:Envelope >

    The managed server log the error is


    Form weblogic server: -.
    Error committing transaction:; nested exception is: Exception [EclipseLink-4002] (Eclipse - 2.1.3.v20110304 persistence Services - r9073): org.eclipse.persistence.exceptions.DatabaseException internal Exception: weblogic.jdbc.sqlserverbase.ddc: invalid object name [FMWGEN] [SQLServer JDBC Driver] [SQL Server] ' dbo. SelfRegistration'. Error code: 208


    The process ends with an error, but why he is rolling abck the transaction at the end. The table of the object was existing in the database and I traced the table to insert the data from the input variable reception to invoke the input variable. BPEL Instance he executed until the end, but in the end, the transaction is rolled back.

    Thank you
    Newcomer Raja

    Invalid object name ' dbo. SelfRegistration'

    I'm assuming you can see a SelfRegistration table in your database... So, I guess that BOD is not the name of the diagram on the right...

  • sort a pl/sql table

    Hi experts,
    Could you please tell me how can I put all the ename column table emp in a work table pl/sql and display of the enmae in a sorted order.

    Concerning
    Rajat

    Published by: Rene on July 15, 2010 09:47

    Rajat says:
    Thanks, but I don't want to store the value in a table.

    Why not? The best place for data is in a SQL table - where is can be indexed, ordered, filtered, put together and so on.

    It is also not such a thing as a «+ table PL +» This data structures is nothing like a table. It is a collection or a table - which is the correct terminology and terminology for the same data structures in languages ranging from Pascal to Java for Delphi and C/C++.

    Calling it a + "PL table +" creates the false idea that the data structure is SQL table as... which could not be further from the truth. They have almost nothing in common. There is a huge difference between a table and a collection from a table SQL.

    I want to
    table ALIGNMENT (TYPE list IS TABLE OF r_empobj ;) is assigned (type r_empobj IS RECORD (empid number, ename varchar2 (100));)

    These data resides inside the PL language like PL data structures It is not a structure of SQL data.

    The SQL language and the language PL are different languages with different runtimes. PL/SQL integrates and "connects" them--blurs the border between these two languages. But they are still clearly distinct and different languages.

    If you have three choices:

  • write a quick-sort /-bubble sort to sort the data PL. structure plastic
  • Copy the entire structure of data of PL SQL data structure, use the SQL engine for sorting and then copy the entire structure of SQL data in PL.
  • do not use a collection/table of PL structure, but use a SQL table instead.

  • PL/SQL table for the TWG vs

    Hi, I want to know why we use of TWG when we can store temporary data in PL/SQL table

    Adding to the list of knapen,.

    (5) the contents of a TWG will obey the semantics of rollback, and rollback to savepoint. An associative array is not.

  • to retrieve data from xml data type

    Hello...
    I have a doubt in the oracle database... Here's how to retrieve data from xml data type?

    Like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select xmltype('
      2  
    3 4 toMonth5 5 ctTestPan1 6 costType2 7 toYear2012 8 fromMonth12 9 fromYear2011 10 11
    ') as xml from dual) 12 -- 13 -- end of sample XMLDATA, use below query on your own table etc. as required 14 -- 15 select x.* 16 from t 17 ,xmltable('/DETAILS/FIELDS_VALUES/FIELD' 18 passing t.xml 19 columns name varchar2(30) path './NAME' 20 ,val varchar2(10) path './VALUE' 21* ) x SQL> / NAME VAL ------------------------------ ---------- toMonth 5 ctTestPan 1 costType 2 toYear 2012 fromMonth 12 fromYear 2011 6 rows selected.
  • retrieving data from columns of user defined type

    Abstract types, I learned the other day. So I created an abstract type and a table.

    Create the student_ty as an object type
    (name varchar2 (20), number of roll);

    create table result)
    Student student_ty,
    (total);



    I also inserted data. But I'm having some trouble with the rretrieval of data. Suppose I want to choose only the roller and the name of the student as described in the type of studen. So I used the follwing query: -.

    Select result student.name;

    But it's not working. But when I use something like this: -.
    Select r.total, r.student.name in result r;


    This works perfectly. My question is that it is a rule that oracle needed to use an alias, whenever retrieve values for a user defined type data?. Help, please.
    Thanks in advance.

    Yes, you can use an alias when the type of object in a table like this.

    select r.student.name, r.student.roll, r.total
      from result r
    
  • SQL Query to retrieve data in XML format with several levels

    Hello

    I'm looking to help generate XML from Oracle database. The request must contain many levels of sub...

    For example.
    Create table inventory
    (Group varchar2 (10))
    category varchar2 (10),
    ProductName varchar2 (10),
    Detail varchar2 (10));

    The output should be also present below. The data must be multiple values for each item.

    < inventory >
    < name of group 'auto' = >
    < category name 'cars' = >
    < name productname = 'Seat' >
    < details > red color < / details >
    < details > 5 seats < / details >
    < / productname >
    < / category >
    < / Group >
    < / inventory >

    Please share your ideas by retrieving data in the XML structure using SQL or PL/SQL for oracle 10 g.

    Thank you and best regards,
    Siva.

    This?

    SQL> create table t as
    with t as (
     select 'automobiles' "GROUP", 'cars' category, 'seat' productname, 'color red' details from dual union all
     select 'automobiles', 'cars', 'seat', '5 seats' from dual union all
     select 'automobiles', 'cars', 'make', 'ford' from dual union all
     select 'automobiles', 'cars', 'make', 'Toyota' from dual union all
     select 'automobiles', 'Bus', 'Model', 'volvo' from dual union all
     select 'automobiles', 'flight', 'Airbus', '400 passenger' from dual union all
     select 'automobiles', 'flight', 'Airbus', '500 mph' from dual union all
     select 'HealthCare', 'Nutrition', 'centrum', 'Organic' from dual union all
     select 'HealthCare', 'Nutrition', 'centrum', 'Chemical' from dual union all
     select 'Computers', 'Software', 'Database', 'Oracle' from dual union all
     select 'Computers', 'Software', 'Database', 'sqlserver' from dual
    )
    select * from t
    /
    Createtable successfully completed.
    
    SQL> select xmlserialize (content x.column_value indent) xml
      from xmltable('element Inventory
                     {for $g in distinct-values(ora:view("t")/ROW/GROUP)
                       return element group
                          {attribute name {$g},
                            for $c in distinct-values(ora:view("t")/ROW[GROUP=$g]/CATEGORY)
                              return element category {attribute name {$c},
                                for $p in distinct-values(ora:view("t")/ROW[GROUP=$g and CATEGORY=$c]/PRODUCTNAME)
                                  return element productname {attribute name {$p},
                                    for $d in distinct-values(ora:view("t")/ROW[GROUP=$g and CATEGORY=$c and PRODUCTNAME=$p]/DETAILS)
                                      return element details {$d}
                                                             }
                                                      }
                          }
                     }') x
    /
    XML
    --------------------------------------------------------------------------------
    
      
        
          
            
    Oracle
    sqlserver
    Chemical
    Organic
    volvo
    Toyota
    ford
    5 seats
    color red
    400 passenger
    500 mph
    1 row selected.
  • 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.
    
  • Reading the data from the XML file to the SQL Tables.

    I have XML of this type

    < empdept >
    < employees_marks >
    < emp_id > 1 < / emp_id >
    BUS from < DIVISION_ID > < / DIVISION_ID >
    PRE < JOB_ID > < / JOB_ID >
    SMITH of < first-name > < / name >
    JAMES < LAST_NAME > < / LAST_NAME >
    < > 10000 salary < / salary >
    < / employees_marks >

    < dept >
    < dept_details >
    < deptid > 10 < / deptid >
    < deptname > mechanical < / deptname >
    < / dept_details >
    < dept_details >
    < deptid > 20 < / deptid >
    < deptname > civilian < / deptname >
    < / dept_details >
    < dept_details >
    < deptid > 30 < / deptid >
    < deptname > ICE < / deptname >
    < / dept_details >
    < / dept >
    ((< / empdept > '));

    With the above format am able to recover data successfully to relational tables.


    < employees_marks emp_id = 1 DIVISION_ID = BUS JOB_ID = salary PRE = 10000 / >


    < dept_details deptid = 10 deptname = "Mechanical" / >
    < dept_details deptid = 20 deptname = "ECE" / >
    < dept_details deptid = 30 deptname = "EEE" / >

    that is, I have data as attributes rather than elements, if can I know the way how can I reach the requirement.

    How to recover data when it is present as attributes rather than elements.

    Thank you
    Sunil. N
    with temp as (
      select xmltype('') tempxml from dual
    )
     SELECT extractvalue(tempxml,'/employees_marks/@emp_id') empid,
      extractvalue(tempxml,'/employees_marks/@DIVISION_ID') divid ,
      extractvalue(tempxml,'/employees_marks/@JOB_ID') jobid      ,
      extractvalue(tempxml,'/employees_marks/@salary') sal
       FROM temp
    

    Do you need this?

    Ravi Kumar

Maybe you are looking for

  • error has occurred please try again later when using youtube

    I reinstalled the flash plugin several times and this solves the problem for a short while, then it returns. I don't know what I can do to solve this problem. Its very annoying. I see there is something cookies with this questions but don't know how

  • NB200-10Z - No. SD card with the new BIOS boot option

    First with the version of the BIOS 1.60 could start with SD cardsInstead since I updated the BIOS to version 1.70 is therefore more option. Why?

  • Contact groups 'multiply '...

    Hello! My groups of contacts 'multiply', on the day the day... I created one for each group was originally... Windows 10, Skype 7.21.85.100 MOD Edit: Edited post to remove the information personal & consistent with the Skype community guidelines

  • Removal of the update files.

    I am Yogesh. Right now I use Windows XP genuine, after update my copy of windows, my hard disk space has become very weak. So, how am I going to remove that updates the files to recover my hard space?Please remember and answer me quickly.

  • Progress bar border

    Hello int i = 0; VerticalFieldManagervfmMain; Timer; public GaugeField progressBar = null; progressBar = new GaugeField (null, 0, 100, 0, GaugeField.NO_TEXT |) GaugeField.FIELD_HCENTER) {}Protected Sub layout (int width, int height) {}setExtent (300,