SELECT INTO element table PL/SQL

In the PL/SQL code, I try to get the number of records that have a certain column with the values stored in a SQL table that contains the values of good research.

Here is my attempt:

My_procedure PROCEDURE

...

CURSOR del_method_crsr IS

SELECT delivery_method - delivery_method is VARCHAR2 column

OF delivery_method_lookup;

...

Del_method_cnts_table_type TYPE TABLE IS NUMBER

INDEX BY VARCHAR2 (32);

del_method_counts del_method_cnts_table_type;

del_method_char VARCHAR2 (32);

LONG cat_count;

...

BEGIN

...

FOR del_method IN del_method_crsr

LOOP

del_method_char: = CAST (del_method AS VARCHAR2);     -* Error occurs on this line *.

SELECT COUNT (*)

IN cat_count

DE (...) ;

del_method (del_method) _counts: = cat_count

END LOOP;

...

END;

When I try to compile I get error "PLS-00382: expression is of the wrong type.

I tried several methods to overcome this problem, this CAST attempt is just the last, but all attempts to cause the same error.

I'm assuming that the problem is that del_method is not of type VARCHAR2 (is this something like a pointer?) so I'll try to convert the VARCHAR2 so that it can be used for the key of the table.

My original attempt for the select statement in the cursor for loop was of the form:

SELECT COUNT (*)

IN del_method_counts (del_method)

DE (...) ;

My hypothesis is correct, or is there another problem, that I'm not aware?

How to make this work?

Thank you.

Why are you trying to mount loop recording to a scalar?

FOR del_method IN del_method_crsr

In this statement, "del_method" is the NAME of the folder returned by the cursor.

TO abcde IN myCURSOR

In this statement "abcde" is the NAME of the folder returned by the cursor. This is an ALIAS that you use to refer to the WHOLE LINE returns the cursor.

To reference the columns in this row using dot notation:

TO abcde IN myCURSOR

My_name: = abcde.NAME;

my_salary = abcde. SAL;

. . .

See example 6-19 in the doc

https://docs.Oracle.com/CD/E18283_01/AppDev.112/e17126/static.htm#BABGJBEA

Tags: Database

Similar Questions

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

  • Select the element with PL/SQL

    Hi all

    In the thread: can you disable an item with some javascript and activate with pl/sql, Salvatore suggested a solution for the activation of an element after him be handicapped at the start as follows:
    Howard:
    
    It is possible albeit a little contorted.
    You could define a hidden page-item named P1_HIDE_THIS say.
    In the page-item's HTML Form Element Attributes specify &P1_HIDE_THIS.
    
    You can then set P1_HIDE_THIS using pl/sql or sql to ' disabled ' or '' . The setting of P1_HIDE_THIS will of course have to happen before the item is rendered.
    
    
    Varad
    Anyone outthere knowing the above solution especially this part:
    You can then set P1_HIDE_THIS using pl/sql or sql to ' disabled ' or '' .
    Please explain it to me in detail (with examples). Any help is very appreciated!

    Concerning
    Kamo

    Published by: Kamo on 2009-03-10 23:03

    Hi Kamo

    Any value of the element that is already stored in the session can be used on a page using & nom_element. Notation. What city suggests is that you create a hidden page called P1_HIDE_THIS element and set it to the value either "Disabled" or ". You can then use & P1_HIDE_THIS. wherever you want the value to appear. In your case, you put this into the attributes of elements of HTML form to the page elements you want to turn, it becomes part of the attributes of the INPUT tag when the item is rendered on the page - if P1_HIDE_THIS is "and then nothing happens, but if it is"disabled", then the item becomes invalid. How do you set the value of P1_HIDE_THIS depends on how you determine when goods are intended to be disabled. This must be done until the page is loaded (the front header point of process or calculation would) so that the value is available when the elements are rendered. For example, suppose that you want to disable the items when the current user is 'ABC ':

    IF UPPER(:APP_USER) = 'ABC' THEN
     :P1_HIDE_THIS := ' disabled ';
    ELSE
     :P1_HIDE_THIS := '';
    END IF;
    

    Add as a process that runs before Header on the page.

    A very simple example to do this kind of thing: [http://apex.oracle.com/pls/otn/f?p=2371:6]

    Andy

  • SQL Loader loading data into two Tables using a single CSV file

    Dear all,

    I have a requirement where in I need to load the data into 2 tables using a simple csv file.

    So I wrote the following control file. But it loads only the first table and also there nothing in the debug log file.

    Please suggest how to achieve this.

    Examples of data

    Source_system_code,Record_type,Source_System_Vendor_number,$vendor_name,Vendor_site_code,Address_line1,Address_line2,Address_line3

    Victor, New, Ven001, Vinay, Vin001, abc, def, xyz

    Control file script

    ================

    OPTIONS (errors = 0, skip = 1)
    load data
    replace
    in the table1 table:
    fields ended by ',' optionally surrounded "" "
    (
    Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"
    Record_type tank "ltrim (rtrim (:Record_type)),"
    Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"
    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"
    )
    in the Table2 table
    1 = 1
    fields ended by ',' optionally surrounded "" "
    (
    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"
    Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"
    Address_line1 tank "ltrim (rtrim (:Address_line1)),"
    Address_line2 tank "ltrim (rtrim (:Address_line2)),"
    Address_line3 tank "ltrim (rtrim (:Address_line3)).
    )

    the problem here is loading into a table, only the first. (Table 1)

    Please guide me.

    Thank you

    Kumar

    When you do not provide a starting position for the first field in table2, it starts with the following after a last referenced in table1 field, then it starts with vendor_site_code, instead of $vendor_name.  So what you need to do instead, is specify position (1) to the first field in table2 and use the fields to fill.  In addition, he dislikes when 1 = 1, and he didn't need anyway.  See the example including the corrected below control file.

    Scott@orcl12c > test.dat TYPE of HOST

    Source_system_code, Record_type, Source_System_Vendor_number, $vendor_name, Vendor_site_code, Address_line1, Address_line2, Address_line3

    Victor, New, Ven001, Vinay, Vin001, abc, def, xyz

    Scott@orcl12c > test.ctl TYPE of HOST

    OPTIONS (errors = 0, skip = 1)

    load data

    replace

    in the table1 table:

    fields ended by ',' optionally surrounded "" "

    (

    Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"

    Record_type tank "ltrim (rtrim (:Record_type)),"

    Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"

    $vendor_name tank "ltrim (rtrim (:Vendor_name)).

    )

    in the Table2 table

    fields ended by ',' optionally surrounded "" "

    (

    source_system_code FILL (1) POSITION.

    record_type FILLING,

    source_system_vendor_number FILLING,

    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"

    Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"

    Address_line1 tank "ltrim (rtrim (:Address_line1)),"

    Address_line2 tank "ltrim (rtrim (:Address_line2)),"

    Address_line3 tank "ltrim (rtrim (:Address_line3)).

    )

    Scott@orcl12c > CREATE TABLE table1:

    2 (Source_system_code VARCHAR2 (13),)

    3 Record_type VARCHAR2 (11),

    4 Source_System_Vendor_number VARCHAR2 (27),

    5 $vendor_name VARCHAR2 (11))

    6.

    Table created.

    Scott@orcl12c > CREATE TABLE table2

    2 ($vendor_name VARCHAR2 (11),)

    3 Vendor_site_code VARCHAR2 (16).

    4 Address_line1 VARCHAR2 (13),

    5 Address_line2 VARCHAR2 (13),

    Address_line3 6 VARCHAR2 (13))

    7.

    Table created.

    Scott@orcl12c > HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = test.dat LOG = test.log

    SQL * Loader: release 12.1.0.1.0 - Production on Thu Mar 26 01:43:30 2015

    Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

    Path used: classics

    Commit the point reached - the number of logical records 1

    TABLE1 table:

    1 row loaded successfully.

    Table TABLE2:

    1 row loaded successfully.

    Check the log file:

    test.log

    For more information on the charge.

    Scott@orcl12c > SELECT * FROM table1

    2.

    RECORD_TYPE SOURCE_SYSTEM_VENDOR_NUMBER $VENDOR_NAME SOURCE_SYSTEM

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

    Victor Ven001 new Vinay

    1 selected line.

    Scott@orcl12c > SELECT * FROM table2

    2.

    $VENDOR_NAME VENDOR_SITE_CODE ADDRESS_LINE1 ADDRESS_LINE2 ADDRESS_LINE3

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

    Vinay Vin001 abc def xyz

    1 selected line.

    Scott@orcl12c >

  • Select Into statement in the function db - query issued schema table

    problem with "select into" in the function db to point 10.2


    There are two schemas. "mdbdev" is the master database, and 'devusr' is granted SELECT access table to run queries in the mdbdev schema.


    with devusr, in SQL, I am able to run the following query

    Select wm_concat (strConcatedCountryList)
    from (select country_name as mdbdev.country_master mdbcm strConcatedCountryList
    where mdbcm.country_ship_status = < param? >
    order of country_name)



    but when I use the same procedure/function with 'select into' motion, failed to compile with error * "table or view does not exist."


    FUNCTION GETCOUNTRYLISTTOSHIP (SHIP_STATUS NUMBER)
    RETURN VARCHAR2
    IS
    var2CountryList VARCHAR2 (1000);
    BEGIN
    Select wm_concat INTO var2CountryList (strConcatedCountryList)
    from (select country_name as mdbdev.country_master mdbcm strConcatedCountryList
    where mdbcm.country_ship_status = value < SHIP_STATUS >
    order of country_name);
    Return var2CountryList;
    END;


    Please advise/help/suggestion :)

    You don't have to ask for the DBA, you can run a query to find out:

    select *
    from  all_tab_privs_recd
    where owner = 'MDBDEV'
    and table_name = 'COUNTRY_MASTER'
    

    What give you?

  • Need a sql script loader to load data into a table

    Hello

    IM new to Oracle... Learn some basic things... and now I want the steps to do to load the data from a table dump file...

    and the script for sql loader

    Thanks in advance

    Hello

    You can do all these steps for loading data...

    Step 1:

    Create a table in Toad to load your data...

    Step 2:

    Creating a data file... Create your data file with column headers...

    Step 3:

    Creating a control file... Create your control file to load the data from the table data file (there is a structure of control file, you can search through the net)

    Step 4:

    Move the data file and the control file in the path of the server...

    Step 5:

    Load the data into the staging table using sql loader.

    sqlldr control = data =

    connect as: username/password@instance.

  • insert into multiple tables by using select in stored procedure

    I use oracle 10g R2. I want to insert records in two tables by using a select query (insert into tablename select...) in a stored procedure. How can I insert records into a table two at the same time using a select statement?

    My second question is also related to the first... can I use mechanism clustering here because the two tables are based on the same structure and data? One contains data from 24 hours and there are records of 10 days.

    Thank you.

    If you find the answer of Aman as useful/correct, please mark her answer respectively and close the debate. I think his answer is correct as always / a lot of time.

    Concerning
    Girish Sharma

  • APEX 5: FILE item type to BROWSE not load file into the table apex_application_temp_files

    Hello

    I am trying to load the BLOB (CSV file) into apex_application_temp_files table using the file_browse item type. I have created an example page and the added element of type file_browse, added a dynamic action, which send item to browse.

    Also added a button load that submits the page. But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    I purge file to "end of Session. Enclosed screen shot as well.Capture.PNG

    Thank you

    Ankit

    Hi Pierre,.

    has added a dynamic action, submitting travel item.

    How can you submit just the element go? How your dynamic action look like?

    But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    It is by design, because the sight of apex_application_temp_files limited to your current session. In your case at the session of constructor and not your application.

    Add a process to the page that contains the item "Browse file" when you use

    select *
      from apex_application_temp_files
     where name = :page item name;
    

    to access your downloaded BLOB.

    Concerning

    Patrick

  • Create a button for inserting into a table

    What I can't do, because I've never needed, is to create, in a page (where I have an interactive report), a button is clicked that once performs a simple sql (for example, an insert into a table using the values of page element).

    How can I do?

    Thank you

    Here are some of the steps:

    (1) create the button.

    (2) then right click on the name of the button and select Create Dynamic Action

    (3) give it to DA a name, click Next

    (4) on the 'when' step, event should already be "Click" and the name of the button must be filled

    (5) for the Condition, you would have a condition when you want that the display of the button.  Say, if your page elements have a certain range of values, and then display this button.  No condition means that the button is always displayed.

    (6) for the 'real Action' stage, action, select "run the Code in PL/SQL.

    [There are other ways to do this, but it's simple for me.]

    (7) in the Code PL/SQL block, enter says:

    Begin

    INSERT INTO EMP (EMPNO, ENAME, HIREDATE)

    VALUES (: P6_EMPNO, 'MARK1970',: P6_HIREDATE);

    COMMIT;

    END;   -You'd probably all the variables page element

    (8) here the part I'm not sure 100%.

    For items to submit "Page, name used in YOUR QUERY - in my example page elements, these are P6_EMPNO, P6_HIREDATE (don't note any use of & or: or here.)

    Hmm.  Start by putting nothing in "Page of elements to return.   If that fails, then try the same elements of page P6_EMPNO, it P6_HIREDATE as well.

    [I'm too lazy to go running at present].

    (9) I think that's it.

    Howard

  • Impossible to insert xml data into the table

    HII All,
    I'm unable to parse the following xml file and insert them into the table.


    Version of DB
    ======
    SQL> SELECT *
      2  FROM V$VERSION;
    
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    My DB Table
    Create table rgh_xml_storage
    (
    user_id       varchar2(4000),
    to_type          varchar2(4000),
    mail_id          varchar2(4000),
    subject         varchar2(4000),
    sentDateTime    varchar2(4000)
    )
    Published by: RUSSO April 7, 2011 04:19

    Hello

    Please provide all pertinent details!

    Please correct my insert if statement it must be.

    You have a few bad XPath.
    Here's a way to unnest correctly repeated elements:

    SQL> select x1.user_id,
      2         x1.subject,
      3         x1.sentDateTime,
      4         x2.to_type,
      5         x2.mail_id
      6         --x1.messageBody
      7  from xmltable(
      8    '/emailMessage'
      9    passing xmltype(bfilename('TEST_DIR','email.xml'), nls_charset_id('CHAR_CS'))
     10    columns user_id      varchar2(4000)  path 'headerInformation/sender/user/@userID',
     11            subject      varchar2(4000)  path 'headerInformation/subject',
     12            sentDateTime varchar2(4000)  path 'headerInformation/sentDateTime',
     13            messageBody  clob            path 'messageBody',
     14            my_xml       xmltype         path 'headerInformation/recipients'
     15   ) x1,
     16   xmltable(
     17    '/recipients/recipient'
     18    passing x1.my_xml
     19    columns to_type      varchar2(4000)  path '@type',
     20            mail_id      varchar2(4000)  path 'user/@emailAddress'
     21   ) x2
     22  ;
    
    USER_ID              SUBJECT                                          SENTDATETIME                   TO_TYPE   MAIL_ID
    -------------------- ------------------------------------------------ ------------------------------ --------- ------------------------------------------
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   to        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    
    13 rows selected
     
    
  • Open sys_refcursor to select from the table variable?

    Hello

    I have a challenge for you! :-)

    I have a procedure that has a lot of logic to determine which data should be loaded into a table variable. Because of various constraints of the application, I can't create a global temporary table. Instead, I would like to create a table variable and fill with stuff that I go through the procedure.

    The final outcome of the procedure is that I must be able to pass the results as a sys_refcursor. It is a requirement that is beyond my control as well.

    Is there a way to do this kind of work of the procedure?

    Create Or Replace procedure Xtst
    (
    Mu_Cur in the Sys_Refcursor
    )
    Is
    Type Xdmlrectype is Record (Col1 Varchar2 (66));
    Type Xdmltype is Table of Xdmlrectype;
    RTN Xdmltype;
    Begin
    Internal_Id Select Bulk collect into Rtn of Zc_State;
    Open mu_cur to select table col1 (rtn);
    end;
    /
    ---
    11/42 PLS-00642: types of local collections not allowed in SQL queries
    11/36 PL/SQL: ORA-22905: cannot access the rows of a table not nested element
    11/19 PL/SQL: statement ignored
    Display errors;

    Not something I would personally like to implement.

    But for educational purposes only of course...

    create table this_will_be_gross
    (
       column1 number,
       column2 varchar2(30)
    
    );
    
    insert into this_will_be_gross values (1, 'begin the ugliness');
    insert into this_will_be_gross values (2, 'end the ugliness');
    
    variable x refcursor;
    
    ME_XE?
    declare
       Rtn sys.ODCIVARCHAR2LIST;
    BEGIN
       SELECT
          column1 || '-' || column2 Bulk Collect
       INTO
          Rtn
       FROM
          this_will_be_gross;
    
       OPEN :x FOR
       SELECT
          regexp_substr (column_value, '[^-]+', 1, 1) as column1,
          regexp_substr (column_value, '[^-]+', 1, 2) as column2
       FROM TABLE(CAST(rtn AS sys.ODCIVARCHAR2LIST));
    end;
     17  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.09
    ME_XE?
    ME_XE?print :x
    
    COLUMN1                        COLUMN2
    ------------------------------ ------------------------------
    1                              begin the ugliness
    2                              end the ugliness
    
    2 rows selected.
    
    Elapsed: 00:00:00.11
    

    In the above example I have "know" that a hyphen was a safe character to use to break my data items (as could not find anywhere in the data itself).

    I strongly encourage you don't not to implement something like this. I know it's tempting when you work in harsh environments where it may take a serious battle to get structures such as temporary tables or the SQL Types created, but it is really the right way to do it.

  • Load data from one table into another table of 2 different schemes

    Hello

    We have a requirement to insert data into a table in a schema of a table that is in other schemas in ODI.

    We are able to do so by creating interfaces and mappings. But we now expect to do using SQL instead of ODI interfaces.

    Is it possible to do this using the SQL statements we have source and target data sources defined in ODI.

    should be like "Insert into src.table select * from tar.table'"

    Thank you...

    Hello

    If you try to load a db to another db using sql (sql free hand) instead of interfaces instructions.

    It is possible using procedures odi too.

    1. Select the project (designer navigator) odi mode

    2. create the new procedure. Then add the command.

    in this command on the source command on the tabs of the target.

    Enter the sql statements. See the screenshots below...

    I think this will help for you,

    Thank you best regards &,.

    A.Kavya

  • XML data in the table using sql/plsql

    Hi experts,

    Could you please help with the following requirement. I have the tags xml (.xml on a server file) below. I need to access this file and read the XML and insert into the db table using sql and plsql. Is it possible with the cdata below? And there is a nested this table.

    Could someone please guide me if you have a sample code file and xml.

    <? XML version = "1.0" encoding = "UTF-8"? >

    < generation_date > <! [CDATA [17/11/2015]] > < / generation_date >

    < generated_by > <! [CDATA [Admin Admin]] > < / generated_by >

    < year > <! [CDATA [2015]] > < / year >

    < month > <! [CDATA [01]] > < / month >

    < author >

    < author > <! [CDATA [user author]] > < / author > < author_initial > <! [CDATA [user]] > < / author_firstname > < author_country > <! [CDATA [author]] > < / author_lastname >

    < author_email > <! [CDATA [[email protected]]] > < / author_email >

    < author_data_01 > <! [CDATA []] > < / author_data_01 >

    < author_data_02 > <! [CDATA []] > < / author_data_02 >

    < items >

    < article_item >

    < article_id > <! [CDATA [123456]] > < / article_id >

    < publication > <! [CDATA [Al Bayan]] > < / publication >

    < section > <! [CDATA [Local]] > < / section >

    < issue_date > <! [CDATA [11/11/2015]] > < / issue_date >

    < page > <! [CDATA [2]] > < / print this page >

    < article_title > <! [CDATA [title.]] > < / article_title > < number_of_words > <! [CDATA [165]] > < / number_of_words >

    < original_price > <! [CDATA [200]] > < / original_price >

    < original_price_currency > <! [CDATA [DEA]] > < / original_price_currency >

    < price > <! [CDATA [250]] > < / price >

    < price_currency > <! [CDATA [DEA]] > < / price_currency >

    < / article_item >

    < / articles >

    < total_amount > <! [CDATA [250]] > < / total_amount >

    < total_amount_currency > <! [CDATA [DEA]] > < / total_amount_currency >

    < / author >

    < / xml >

    Thanks in advance,

    Suman

    XMLTABLE using...

    SQL > ed
    A written file afiedt.buf

    1 with t (xml) as (select xmltype ('))
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [[12 [email protected]]] >
    13
    14
    15
    16
    17
    18
    19


    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33 ") of the double)"
    34-

    35 end of sample data
    36-
    37 - assumptions:
    (38 - a) XML may have several tags
    (39 - b) each may contain more
    40-
    41 select x.gen_by, x.gen_date, x.mn, x.yr
    42, y.author, y.auth_fn, y.auth_ln, y.auth_cnt, y.auth_em, y.auth_d1, y.auth_d2

    43, z.id, z.pub, z.sec, z.iss_dt, z.pg, z.art_ttl, z.num_wrds, z.oprice, z.ocurr, z.price, z.curr
    44 t
    45, xmltable ('/ authxml')
    from $ 46 t.xml
    path of 47 columns gen_date varchar2 (10) '. / generation_date'
    48, path of varchar2 (15) of gen_by '. / generated_by'
    49, path of varchar2 (4) year '. "/ year"
    50 varchar2 (2) mn road '. "/ month"
    51, path of xmltype authors '.'
    52                 ) x
    53, xmltable ('/ authxml/authors ')
    from $ 54 x.authors
    author of 55 path of varchar2 columns (15) '. / author'
    56, path of varchar2 (10) of auth_fn '. / author_firstname'
    57, path of varchar2 (10) of auth_ln '. / author_lastname'
    58 road of VARCHAR2 (3) auth_cnt '. / author_country'
    59 road of varchar2 (20) of auth_em '. / author_email'
    60 road of varchar2 (5) of auth_d1 '. / author_data_01'
    61, path of varchar2 (5) of auth_d2 '. / author_data_02'
    62, path of xmltype articles '. / Articles'
    63                 ) y
    64, xmltable ('/ Articles/article_item ')
    from $ 65 y.articles
    path id 66 number columns '. / article_id'
    67, path of varchar2 (10) pub '. ' / publication.
    68 road of varchar2 (10) dry '. / section'
    69, path of varchar2 (10) of iss_dt '. / issue_date'
    70 road of VARCHAR2 (3) pg '. "/ print this page"
    71, path of varchar2 (20) of art_ttl '. / article_title'
    72, path of varchar2 (5) of num_wrds '. / number_of_words'
    73, path of varchar2 (5) of oprice '. / original_price'
    74 road to VARCHAR2 (3) ocurr '. / original_price_currency'
    75, path of varchar2 (5) price '. "/ price"
    76, path of VARCHAR2 (3) curr '. / price_currency'
    77*                ) z
    SQL > /.

    GEN_DATE GEN_BY YEAR MN AUTHOR AUTH_FN AUTH_LN AUT AUTH_EM AUTH_ AUTH_ ID PUB DRY ISS_DT PG ART_TTL NUM_W OPRIC HEARTS PRICE OCU
    ---------- --------------- ---- -- --------------- ---------- ---------- --- -------------------- ----- ----- ---------- ---------- ---------- ---------- --- -------------------- ----- ----- --- ----- ---
    17/11/2015 Admin Admin 2015 01 user author user author [email protected] 123456 UAE Al Bayan Local 11/11/2015 2 is the title.   165 200 AED AED 250

    Of course, you'll want to change the types of data, etc. as needed.

    I assumed that the XML can contain several "" sections and that each section can contain several entries.

    Thus the XMLTABLE aliasing as 'x' gives information of XML, and supplies the data associated with the XMLTABLE with alias 'y' which gets the multiple authors, which itself section of the XMLTABLE with alias 'z' for each of the article_item.

    CDATA stuff are handled automatically by SQLX (XML functionality integrated into Oracle's SQL)

  • Accelerate the selection * of a table

    Hi all

    OS: RHEL

    DB: 11 gR 2

    Is it possible that we can accelerate the selection * of a table?

    Kind regards

    $phinx19 wrote:

    Hi all

    OS: RHEL

    DB: 11 gR 2

    Is it possible that we can accelerate the selection * of a table?

    Kind regards

    # If it is everything you write, you get a full table scan independently of all the indexes that exist on this table:

    SQL > create table (yazflutt)

    snorm number 2.

    3 gleezle varchar2 (40),

    date of Halloween 4,

    Number 5 art);

    Table created.

    SQL >

    SQL > start

    2 for i in 1.10000 loop

    3. insert into yazflutt

    4 values (i, 'pourles yinko' |) I |'! (', sysdate - I, i);

    5 end of loop;

    6

    7 validation;

    8 end;

    9.

    PL/SQL procedure successfully completed.

    SQL >

    SQL > set autotrace on

    SQL >

    SQL > select * from yazflutt;

    SNORM GLEEZLE HALLOWEEN ART

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

    yinko 567 567 pourles!                        15 APRIL 14 567

    yinko 568 568 pourles!                        14 APRIL 14 568

    ...

    9982 yinko 9982 pourles!                       5 JULY 88 9982

    9983 pourles yinko 9983!                       4 JULY 88 9983

    9984 yinko 9984 pourles!                       3 JULY 88 9984

    9985 pourles yinko 9985!                       2 JULY 88 9985

    9986 yinko 9986 pourles!                       1 JULY 88 9986

    9987 yinko 9987 pourles!                       30 JUNE 88 9987

    9988 yinko 9988 pourles!                       29 JUNE 88 9988

    SNORM GLEEZLE HALLOWEEN ART

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

    9989 yinko 9989 pourles!                       9989 JUNE 28, 88

    yinko 9990 9990 pourles!                       JUNE 27 88 9990

    9991 yinko 9991 pourles!                       9991 26 JUNE 88

    9992 yinko 9992 pourles!                       25 JUNE 88 9992

    9993 yinko 9993 pourles!                       9993 JUNE 24, 88

    9994 yinko 9994 pourles!                       23 JUNE 88 9994

    9995 pourles yinko 9995!                       9995 22 JUNE 88

    yinko 9996 9996 pourles!                       JUNE 21 88 9996

    9997 yinko 9997 pourles!                       20 JUNE 88 9997

    9998 pourles yinko 9998!                       9998 19 JUNE 88

    yinko 9999 9999 pourles!                       18 JUNE 88 9999

    SNORM GLEEZLE HALLOWEEN ART

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

    10000 pourles 10000 yinko!                      JUNE 17, 88 10000

    10000 selected lines.

    Execution plan

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

    Hash value of plan: 2573332187

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |          | 10000 |   556K |    10 (10) | 00:00:01 |

    |   1.  TABLE ACCESS FULL | YAZFLUTT | 10000 |   556K |    10 (10) | 00:00:01 |

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

    Note

    -----

    -the dynamic statistics used: dynamic sampling (level = 2)

    Statistics

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

    9 recursive calls

    0 db block Gets

    795 consistent gets

    0 physical reads

    0 redo size

    488545 bytes sent via SQL * Net to client

    7877 bytes received via SQL * Net from client

    668 SQL * Net back and forth to and from the client

    0 sorts (memory)

    0 sorts (disk)

    10000 rows processed

    SQL >

    SQL > set autotrace off

    SQL >

    SQL > create index yazflutt_idx1 on yazflutt (snorm);

    The index is created.

    SQL >

    SQL > create index yazflutt_idx2 on yazflutt (gleezle);

    The index is created.

    SQL >

    SQL > create index yazflutt_idx3 on yazflutt (hopple);

    The index is created.

    SQL >

    SQL > create index yazflutt_idx4 on yazflutt (art);

    The index is created.

    SQL >

    SQL > exec dbms_stats.gather_table_stats (user, 'YAZFLUTT',-online true waterfall, estimate_percent-online null)

    PL/SQL procedure successfully completed.

    SQL >

    SQL > set autotrace on

    SQL >

    SQL > select * from yazflutt;

    SNORM GLEEZLE HALLOWEEN ART

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

    yinko 567 567 pourles!                        15 APRIL 14 567

    yinko 568 568 pourles!                        14 APRIL 14 568

    yinko 569 569 pourles!                        APRIL 13, 14 569

    ...

    9983 pourles yinko 9983!                       4 JULY 88 9983

    9984 yinko 9984 pourles!                       3 JULY 88 9984

    9985 pourles yinko 9985!                       2 JULY 88 9985

    9986 yinko 9986 pourles!                       1 JULY 88 9986

    9987 yinko 9987 pourles!                       30 JUNE 88 9987

    9988 yinko 9988 pourles!                       29 JUNE 88 9988

    SNORM GLEEZLE HALLOWEEN ART

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

    9989 yinko 9989 pourles!                       9989 JUNE 28, 88

    yinko 9990 9990 pourles!                       JUNE 27 88 9990

    9991 yinko 9991 pourles!                       9991 26 JUNE 88

    9992 yinko 9992 pourles!                       25 JUNE 88 9992

    9993 yinko 9993 pourles!                       9993 JUNE 24, 88

    9994 yinko 9994 pourles!                       23 JUNE 88 9994

    9995 pourles yinko 9995!                       9995 22 JUNE 88

    yinko 9996 9996 pourles!                       JUNE 21 88 9996

    9997 yinko 9997 pourles!                       20 JUNE 88 9997

    9998 pourles yinko 9998!                       9998 19 JUNE 88

    yinko 9999 9999 pourles!                       18 JUNE 88 9999

    SNORM GLEEZLE HALLOWEEN ART

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

    10000 pourles 10000 yinko!                      JUNE 17, 88 10000

    10000 selected lines.

    Execution plan

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

    Hash value of plan: 2573332187

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

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |          | 10000 |   341K |    10 (10) | 00:00:01 |

    |   1.  TABLE ACCESS FULL | YAZFLUTT | 10000 |   341K |    10 (10) | 00:00:01 |

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

    Statistics

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

    1 recursive calls

    0 db block Gets

    725 consistent gets

    0 physical reads

    0 redo size

    488545 bytes sent via SQL * Net to client

    7877 bytes received via SQL * Net from client

    668 SQL * Net back and forth to and from the client

    0 sorts (memory)

    0 sorts (disk)

    10000 rows processed

    SQL >

    SQL > set autotrace off

    SQL >

    Whatever the index in place a ' select * ' makes a full table scan, period.  Unless you can optimize your storage space, memory, or even use version 11.2 laters results cache and there is not a lot you can do.

    David Fitzjarrell

  • Parse XML and insert into the table Oracel

    Hi all

    I have an XML document, I need to analyze and take the respective tag data and inserting it into another table.

    This is the XML code that I have.

    " < convertTo xsi: schemaLocation =" https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo >


    Here is the code I use to analyze the values

    DECLARE

    XMLType x: = XMLType)

    ' ' < convertTo xsi: schemaLocation = " https://xecdapi.XE.com/schema/v1/convertTo.xsd "> "

    < terms > http://www.XE.com/privacy.php < / terms >

    < privacy > http://www.XE.com/legal/DFS.php < / privacy >

    < to > < /pour > USD

    < amount > 1.0 < / amount >

    < timestamp > 2015-10-25T 23: 00:00Z < / timestamp >

    < from >

    rate <>

    < currency > EUR < / currency >

    < e > 0.9075541422 < / mid >

    < / rates >

    rate <>

    INR < currency > < / currency >

    < e > 65.0313451105 < / mid >

    < / rates >

    rate <>

    < currency > CAD < / currency >

    < e > 1.3167560135 < / mid >

    < / rates >

    rate <>

    < currency > GBP < / currency >

    < e > 0.6528693249 < / mid >

    < / rates >

    < / from >

    < / convertTo > '

    );

    BEGIN

    FOR r IN

    (

    SELECT

    Name of the AS ExtractValue (Value (p),'/ rate/currency/text () ')

    -, ExtractValue (value (p), '/ Row/Address/State/Text ()') State

    -, ExtractValue (value (p), '/ Row/Address/City/Text ()') city

    Of

    TABLE (XMLSequence (Extract(x,'convertTo/from/rate'))) p

    )

    LOOP

    -do what you want with r.name, r.state, r.city

    dbms_output.put_line ('Name' | r.Name);

    END LOOP;

    END;

    I get the error message below

    Error report:

    ORA-31011: XML parsing failed

    ORA-19202: an error has occurred in the processing of XML

    LPX-00234: the 'xsi' namespace prefix is not declared

    Error on line 1

    ORA-06512: at "SYS." XMLTYPE", line 310

    ORA-06512: at line 2

    31011 00000 - "XML parsing failed"

    * Cause: XML parser returned an error trying to parse the document.

    * Action: Check whether the document to parse is valid.

    Any help on how to fix this would be really useful.

    Appreciate your time and your help.

    Thank you

    Olivier

    Have you even tried to do what we have suggested?

    SQL > ed
    A written file afiedt.buf

    1 with t as (select xmltype ('))
    "" 2 http://xecdapi.xe.com "xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance"" xsi: schemaLocation = "https://xecdapi.xe.com/schema/v1/convertTo.xsd" > ""
    3 http://www.xe.com/privacy.php
    4 http://www.xe.com/legal/dfs.php
    5 USD
    6    1.0
    7 2015-10 - 25 T 23: 00:00Z
    8
    9
    10 EUROS
    11 0.9075541422
    12

    13

    14
    ") in XML of the double)"
    15-
    16 end of test data
    17-
    18 select x.*
    19 t
    20, xmltable (xmlnamespaces ("http://www.w3.org/2001/XMLSchema-instance" as "xsi", default 'http://xecdapi.xe.com'),)
    21 ' / convertTo/of/rate.
    22 passage t.xml
    path of VARCHAR2 (3) currency 23 columns '. / currency '
    24, half-way number '. / mid'
    25*                ) x
    SQL > /.
    HEART MI
    --- ----------
    EUR.907554142

    1 selected line.

Maybe you are looking for

  • Pseudo Apple Store help

    I used an app that asked for my username to the Apple Store, but I couldn't find it. I looked but still couldn't find it.  someone tell me if I can find it through my phone or if I have to use a computer. If I can on my phone please explain as much a

  • Windows code error 43 GTX 560 M on Qosmio X 770/00 X

    Guys, laptop is running using standard vga (i.e. the GTX 560 M disabled). I checked using GPU - Z and the version of the BIOS and other information is missing/white. Previously, it is filled with data (e.g. BIOS Version: 70.26.36.00.0A, etc...). This

  • How can I get permission to administrator on my Vista software

    I went to the help files and can find no leads to follow to find info. on this subject. Where is he? Bryce

  • The Philips SPA5210 bar: this device cannot start. (Code 10)

    Hi all I have a brand new Philips Soundbar which does not work.  Running Windows 7 Professional 64 bit and try to use the audio driver generic usb (which is what suggests Philips).  I get the dreaded "this device cannot start. (Code 10) "error. This

  • Microsoft LifeChat LX - 300 broken left sleeve

    I recently got my Microsoft LifeChat LX-3000 and while I was watching a video the left tubing just stopped making sounds. I thought that it was the video and I tried many videos only to get the same result. Any help would be appreciated. I don't thin