EXTRACTVALUE returns more than one row error

Hi gurus

I have XML file, now I would like to write an SQL to convert tabular. Whne I try to use

EXTRACTVALUE
(XML_MESSAGE,
' / ATMWithDrawTrans/Trans/Tran/TranDate.

I'm ExtractValue returns multiple rows. Could you please help me find a query that retrieves these sub table form.

< ATMWithDrawTrans >
< Trans >
< Tran >
< TranDate > 2001 - 09 - 10 < / TranDate >
< amount > 105 < / amount >
< / Tran >
< Tran >
< TranDate > 2002 - 03 - 10 < / TranDate >
< amount > 105 < / amount >
< / Tran >
< Tran >
< TranDate > 2002 - 09 - 10 < / TranDate >
< amount > 104 < / amount >
< / Tran >
< Tran >
< TranDate > 2003 - 03 - 10 < / TranDate >
< amount > 104 < / amount >
< / Tran >
< Tran >
< TranDate > 2003 - 09 - 10 < / TranDate >
< amount > 103 < / amount >
< / Tran >
< / Trans >
< / ATMWithDrawTrans >

TIA

Published by: 870046 on July 25, 2011 08:50

XMLTable will do what you want.

For example, assuming XML_MESSAGE is a database of XMLType column:

select x.*
from your_table t
   , xmltable('/ATMWithDrawTrans/Trans/Tran'
       passing t.xml_message
       columns tran_date date   path 'TranDate'
             , amount    number path 'amount'
     ) x
;

If your version does not support, see XMLSequence in the documentation.

Tags: Database

Similar Questions

  • Single - row subquery returns more than one line.

    Hi Experts

    I am faced with error

    ORA-01427: single - row subquery returns more than one line.

    MyQuery is:

    select
       TO_CHAR(T.MR_REG_DATE,'DD')                     "DATE"
       ,CASE  
         WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||'  - ('||'0 - 1 Month)'
         WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||'  - ('||'2 - 12 Months)'
         WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||'  - ('||'1 - 5 Years)'
         WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||'  - ('||'5 - 10 Years)'
         WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||'  - ('||'> 10 Years)'
        END age
      ,count(T.Mr_Code) No_of_Patient
      ,(  SELECT count(x.mr_code) mr_code
             FROM HMIS_MRINFO X
             where X.mr_reg_date between &FRM_DATE AND &TO_DATE
               and X.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y
                                      WHERE Y.mr_reg_date between &FRM_DATE AND &TO_DATE
                                    )
            GROUP BY CASE  
                       WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) between 0 and 1 THEN ' 01'||'  - ('||'0 - 1 Month)'
                       WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||'  - ('||'2 - 12 Months)'
                       WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||'  - ('||'1 - 5 Years)'
                       WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||'  - ('||'5 - 10 Years)'
                       WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) > 120 then ' 05'||'  - ('||'> 10 Years)'
                      END 
      ) Missing_MR
    from hmis_mrinfo T,hmis_pat_add_dis_detail M
    where T.mr_code = M.mr_code(+)
      and T.mr_reg_date between &FRM_DATE AND &TO_DATE
      &AGE_GRP
    GROUP BY T.MR_REG_DATE
             ,CASE  
               WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||'  - ('||'0 - 1 Month)'
               WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||'  - ('||'2 - 12 Months)'
               WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||'  - ('||'1 - 5 Years)'
               WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||'  - ('||'5 - 10 Years)'
               WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||'  - ('||'> 10 Years)'
              END 
    ORDER BY T.MR_REG_DATE;
    

    Please give some advice / solution.

    I think this might do it for you

    Select

    TO_CHAR (T.MR_REG_DATE, 'DD') "DATE."

    CASE

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'.  - ('||' 0-1 month)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'.  - ('||' 2-12 months)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'.  - ('||' 1-5 years)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'.  - ('||' 5-10 years)'

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'.  ' - ('| ' > 10 years).

    Age of the END

    count (T.Mr_Code) No_of_Patient

    , count (case when t.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y))

    WHERE Y.mr_reg_date between & FRM_DATE AND & TO_DATE)

    then t.mr_code

    (end) Missing_MR

    of hmis_mrinfo T, hmis_pat_add_dis_detail M

    where T.mr_code = M.mr_code (+)

    and between T.mr_reg_date & FRM_DATE AND & TO_DATE

    & AGE_GRP

    T.MR_REG_DATE GROUP

    CASE

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'.  - ('||' 0-1 month)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'.  - ('||' 2-12 months)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'.  - ('||' 1-5 years)"

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'.  - ('||' 5-10 years)'

    WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'.  ' - ('| ' > 10 years).

    END

    ORDER BY T.MR_REG_DATE;

  • A row of Sub query returns more than 1 row!

    I'm trying to update the values in one table from another table and get the error: void line query returns More Than 1 row.

    I want to PRV_NAME B chart updated in the table A PRV_NAME where A.PRVID = B.PRVID where B.PRV_TYPE = M"

    The two paintings were all unique PRVID, however, table B has PRVID that have the same name. So the data in table B can look like this:

    PRVID PRV_NAME
    1234 PHOENIX MED
    1235 MED BAG
    1236 MED BAG
    1237 OVERLAND
    etc...

    So, as you can see are the unique PRVID, but not the PRV_NAME. Is this the reason why I get this error?

    I do not build the tables and have no control over what is put in them. If this is the reason for the error, is there a way to fix this?

    For reference, here's the request. Maybe there's something wrong with that?


    Update msb_prv_source ps
    Set ps.prv_name =

    (select prv00.prv00_prv_name
    of prv00_prv prv00
    Join msb_prv_source ps
    On prv00.prv00_prv_id = ps.prvid
    where prv00.prv00_prv_type = am')

    Published by: user12296489 on April 19, 2013 10:46
    /* Formatted on 4/19/2013 2:00:43 PM (QP5 v5.185.11230.41888) */
    MERGE INTO msb_prv_source a
         USING (SELECT *
                  FROM prv00_prv
                 WHERE prv00_prv_type = 'M') b
            ON (a.prv00_prv_id = b.prvi)
    WHEN MATCHED
    THEN
       UPDATE SET a.prv_name = prv00_prv_name
    
  • Einreihig subquery returns more than one query

    Hello

    I get the following error: einreihig subquery returns more than one request. I don't know how I should debug this application. As far as I know, subqueries can return only 1 row...: S

    I've only Oracle SQL Developer to run/test of my queries. I can run the query with ROWNUM < 5000, which gives no error. If I run with ROWNUM > 5000 and ROWNUM < 6000 then the error pops up...

    This is the query:
    with
    DATES as 
      (select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL),
    MONTHS as 
      (select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1),
    CALCULATIONS as
      (select 
        PNM.PNM_AUTO_KEY PNM_KEY,
        MONTHS.DT DT, 
        NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING, 
        NVL((select sum(saj.qty_adj) from stock_adjust saj 
                                    inner join stock stm on saj.stm_auto_key = stm.stm_auto_key 
                                    inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING
      from MONTHS, PARTS_MASTER PNM)
    SELECT
      ROWNUM, CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE
    FROM
      CALCULATIONS;
    Published by: layout of the code user574699 on November 17, 2008 02:10

    the problem is that you use the same alias in your view online as well as in your main query in the second statement-nvl...

    HTH

  • "ORA-01427: einreihig subquery returns more than one line.

    Hi all
    I have a SQL query where I need a subquery for certain fields (like fields are optional), and the thing is some of the subqueries are works well, but when I use some, it gives me an error * "ORA-01427: einreihig subquery returns more rows" *, so I looked to the top of the internet and found if I give *' and rownum = 1' * in the subquery ". It eliminates the error and there certainly, but the thing is I have test the XML data. I have two addresses that should appear on the report and both follow the same path, but one is required optional and another so I put the option in the subquery, but in the XML data, I see that both addresses are the same, but they need to be different, because the status of the relationship with that I question is different. I ALSO POST MY SQL so that if anyone of you has an idea can help out me. Once more, the sql, I put here has the SQL subqueries with ' and rownum = 1', which gives me bad output

    Select S_FN_INCEXP_CON. RELATION_TYPE_CD as RELATION_TYPE_CD,
    S_ORDER. ORDER_NUM as ORDER_NUM,
    S_ORDER. FRGHT_AMT as FRGHT_AMT,
    S_ORDER. ORDER_DT as ORDER_DT,
    S_ORDER. CARRIER_CD as CARRIER_CD,
    S_ORDER. CARRIER_PRIO_CD as CARRIER_PRIO_CD,
    S_ORDER. ACCNT_ORDER_NUM as ACCNT_ORDER_NUM,
    S_CONTACT. FST_NAME as FST_NAME,
    S_CONTACT. Last_name like LAST_NAME,
    S_ADDR_PER. ADDR_NAME as ADDR_NAME-> it's the address required
    S_ADDR_PER. POSTAL CODE such as POSTAL code,
    S_CON_ADDR. ADDR_MAIL_CD as ADDR_MAIL_CD,
    S_ADDR_PER. EMAIL_ADDR as EMAIL_ADDR,
    S_ADDR_PER. PH_NUM as PH_NUM,
    S_SRC_PAYMENT. PAYMENT_NUM as PAYMENT_NUM,
    S_ORDER. STATUS_CD as STATUS_CD,
    (select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
    of SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD! = ALL ('Donor', 'Notified Party', ' in memory of ', ' in honor of ')) RELATION_TYPE_CD_1

    , (select S_CONTACT_1.FST_NAME |') '|| S_CONTACT_1.LAST_NAME
    of SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD! = ALL ('Donor', 'Notified Party', ' in memory of ', ' in honor of ')) NAME.

    (select S_ORDER_TYPE.NAME
    of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
    where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
    and S_ORDER_TYPE.NAME = 'Général'), GENERAL

    (select S_ORDER_TYPE.NAME
    of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
    where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
    and S_ORDER_TYPE.NAME = 'Memory') MEMORY,

    (select S_ORDER_TYPE.NAME
    of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
    where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
    and S_ORDER_TYPE.NAME = 'Honour') HONOR,.

    (select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
    of SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in memory of ') R1,.

    (select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
    of SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in honor of ") R2,.


    (select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
    of SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = 'notified Party') R3.

    (select S_ADDR_PER. ADDR_NAME | ',' | S_ADDR_PER. Zip code
    of SIEBEL. S_ADDR_PER S_ADDR_PER,
    SIEBEL. S_CON_ADDR S_CON_ADDR,
    SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_CONTACT. ROW_ID = S_CON_ADDR. CONTACT_ID
    and S_CON_ADDR. ADDR_PER_ID = S_ADDR_PER. ROW_ID
    and rownum = 1
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD IN 'Notified Party') NP_ADDR-> it's the optional address


    (select S_PARTY_REL. REL_TYPE_CD
    of SIEBEL. S_PARTY_REL S_PARTY_REL,
    SIEBEL. S_CONTACT S_CONTACT_1,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
    and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
    and S_PARTY_REL. REL_PARTY_ID = S_CONTACT_1.ROW_ID
    and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in memory of ') RLNSHIP


    of SIEBEL. S_CONTACT S_CONTACT,
    SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON,
    SIEBEL. S_ORDER S_ORDER,
    SIEBEL. S_ADDR_PER S_ADDR_PER,
    SIEBEL. S_CON_ADDR S_CON_ADDR,
    SIEBEL. S_SRC_PAYMENT S_SRC_PAYMENT
    where S_ORDER. ROW_ID = S_FN_INCEXP_CON. FN_INCM_EXP_ID
    and S_FN_INCEXP_CON. CONTACT_ID = S_CONTACT. ROW_ID
    and S_CONTACT. ROW_ID = S_CON_ADDR. CONTACT_ID
    and S_CON_ADDR. ADDR_PER_ID = S_ADDR_PER. ROW_ID
    and S_FN_INCEXP_CON. RELATION_TYPE_CD = 'donor '.
    and S_SRC_PAYMENT. ORDER_ID = S_ORDER. ROW_ID

    Use
    ' and S_CONTACT_1.ROW_ID = S_CON_ADDR. CONTACT_ID'
    your 3rd condition in where clause.

    So it would be to get the address of the 'notified part' information instead of the donor

  • error:-row subquery returns more than one line, pls help

    SELECT dsg_code, dsg_name, dsg_grade FROM designation_master WHERE dsg_orgn =:parameter.p_orgn and dsg_ctry =:parameter.p_ctry and dsg_loc =: parameter.p_loc and dsg_oru =: parameter.p_oru
    and dsg_code <>: emp_desig and dsg_grade in (decode(:radio_group,)
    1, (SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select distinct grd_osm_code FROM grade_master WHERE grd_orgn =:parameter.p_orgn and grd_ctry =:parameter.p_ctry and grd_loc =: parameter.p_loc and grd_oru =: parameter.p_oru and grd_code =: emp_grade)).
    2, (SELECT grd_code FROM grade_master WHERE grd_osm_code > all (Select distinct grd_osm_code FROM grade_master WHERE the grd_orgn =:parameter.p_orgn and grd_ctry =:parameter.p_ctry and grd_loc =: parameter.p_loc and grd_oru =: parameter.p_oru and grd_code =: emp_grade)).
    3, (SELECT grd_code FROM grade_master WHERE grd_osm_code < all (Select distinct grd_osm_code FROM grade_master WHERE the grd_orgn =:parameter.p_orgn and grd_ctry =:parameter.p_ctry and grd_loc =: parameter.p_loc and grd_oru =: parameter.p_oru and grd_code =: emp_grade)))

    Try something like this:

    SELECT dsg_code,dsg_name,dsg_grade
      FROM designation_master
     WHERE dsg_orgn=:parameter.p_orgn
       AND dsg_ctry=:parameter.p_ctry
       AND dsg_loc =:parameter.p_loc
       AND dsg_oru = :parameter.p_oru
       AND dsg_code!=:emp_desig
       AND (   (    :radio_group=1
                AND dsg_grade in (SELECT grd_code
                                    FROM grade_master
                                   WHERE grd_osm_code in (Select distinct grd_osm_code
                                                            FROM grade_master
                                                           WHERE grd_orgn=:parameter.p_orgn
                                                             and grd_ctry=:parameter.p_ctry
                                                             And grd_loc =:parameter.p_loc
                                                             And grd_oru = :parameter.p_oru
                                                             and grd_code =:emp_grade
                                                          )
                                  )
                )
             OR (    :radio_group=2
                 AND dsg_grade in (SELECT grd_code
                                     FROM grade_master
                                    WHERE grd_osm_code >any (Select distinct grd_osm_code
                                                               FROM grade_master
                                                              WHERE grd_orgn=:parameter.p_orgn
                                                                and grd_ctry=:parameter.p_ctry
                                                                And grd_loc =:parameter.p_loc
                                                                And grd_oru = :parameter.p_oru
                                                                and grd_code =:emp_grade
                                                            )
                                  )
                )
             OR (    :radio_group=3
                 AND dsg_grade in (SELECT grd_code
                                     FROM grade_master
                                    WHERE grd_osm_code 
    

    not tested

  • ORA-01427: row subquery returns more than one line

    Hello
    I get the above error but I'm not sure how

    its on the line in bold (it says line 16)

    Thanks in advance

    (s_entry IN varchar2)
    return ind_field_value_table
    IS
    found_count number (10);
    T_RETURN ind_field_value_table: = ind_field_value_table();
    Start

    for news (select master, table_name, column_name
    from all_tab_columns
    where <>'SYS' owner and owner <>'SYSTEM '.
    and (Data_type = 'CHAR' OR Data_type = 'NCHAR' OR Data_type = "NVARCHAR2" OR Data_type = 'VARCHAR2')
    Order by owner, table_name, column_name)

    loop

    immediate execution
    ' *'select count (1) of "| cur. Owner | '.' || cur.table_name | 'where ' | cur.column_name | ' = ' || '''' || s_entry | ''' '*
    in found_count;

    found_count: = nvl (found_count, 0);

    If found_count <>0 then
    T_RETURN.extend;
    T_RETURN (T_RETURN. (Count): = ind_field_value (cur.owner, cur.table_name, cur.column_name);
    end if;

    end loop;

    Return t_return;
    end;

    Create an exception handler to dig deeper into the analysis and may use a string instead of direct statement on run immediately, it is often easier for debugging of object, for example:

    ...
    begin
    stmt:='select count(*) .....';
    execute immediate stmt into your_count;
    exception when others then dbms_output.put_line(sqlerrm||' '||stmt);
    end;
    ...
    

    Nicolas.

  • DECODE does not work in the WHERE clause when subquery returns more than one line

    Hi gurus,

    I want to write a query against the table CCENTERS (Script given below) and wait for the following result:

    1. in the transition from a value of 0 for the ID, it returns all the rows in the table.
    2. in the passage of one value other than 0, it returns the row corresponding to the given value and all its records of the child.

    CCENTER has parent-child relationship in the column ID and the BASE. I use a query with the DECODE function. but the function in the WHERE clause is not capable of managing the subquery with multiple lines of DECODE.

    *************************************************
    VARIABLE ParaCCenter NUMBER

    BEGIN
    : paraccenter: = 0;
    END;
    /

    CREATE TABLE ccenters
    (id NUMBER,
    name VARCHAR2 (20).
    number base);

    INSERT INTO ccenters VALUES(1,'NUST',null);
    INSERT INTO ccenters VALUES(2,'SEECS',1);
    INSERT INTO ccenters VALUES(3,'NBS',1);
    commit;

    SELECT * from ccenters
    WHERE id IN DECODE(:ParaCCenter, 0, id,)
    (SELECT id FROM ccenters
    START WITH basic =: ParaCCenter
    ID of CONNECTION BY PRIOR = base
    UNION
    SELECT: ParaCCenter OF double
    )
    )
    /
    BEGIN
    : paraCCenter: = 1;
    END;
    /

    SELECT * from ccenters
    WHERE id IN DECODE(:ParaCCenter, 0, id,)
    (SELECT id FROM ccenters
    START WITH basic =: ParaCCenter
    ID of CONNECTION BY PRIOR = base
    UNION
    SELECT: ParaCCenter double))
    /
    The result is
    (SELECT id FROM ccenters
    *
    ERROR at line 3:
    ORA-01427: einreihig subquery returns multiple rows

    How this query can be rewritten for the given feature. Any response will be appreciated.

    Thank you

    Try something like this:

    SELECT * FROM ccenters
    WHERE :ParaCCenter = 0
    OR id in
      (SELECT id FROM ccenters
       START WITH base=:ParaCCenter
       CONNECT BY PRIOR id = base
       UNION
       SELECT :ParaCCenter FROM dual
      )
    
  • First 4.0.0.12.84 (ORA-01427 einreihig subquery returns more than one line)

    Hi Jeff,

    I use the ai2 since September 13 and I got this error when I run several reports from the RAC (2 knots) databases.

    For ex.    in the DBA Panel, according to the Performance option, when I try to launch ASHES for las 5 minutes, the ORA-01427 out immediately.

    I want just to be sure you're already aware of this problem and taken into account for the next version.

    Thanks in advance,

    Andraly Ng

    EA3 just came out a few hours ago - have a go at it and let us know what you think!

  • Returns more than one result set. How?

    I have a stored Proc that returns 4 results for games, what to call them a page of cfm for each result set?
    Here's my proc. The Proc is a CFC

    umuayo wrote:
    > Hi,.
    >
    > The Proc is a CFC. I need to invoke the cfc from the cfm page to return the results of query cfstoredproc.

    Then, just do it.

    Of course you can only return a value from a function so you'll need
    to put these four results in a table or structure or something to
    group them.

    Then use the complex variable of your choice in the cfm page.

  • Subquery returns more than one value subquery returns more than one value......

    UPDATE CORPORATECARD_TST SET (CORPORATECARD_TST. USERNAME, CORPORATECARD_TST. CREDITCARDIDCD, CORPORATECARD_TST. DATEINSERTED, CORPORATECARD_TST. DATEUPDATED, CORPORATECARD_TST. CUSTOMERNAME, CORPORATECARD_TST. FORMOFPAYCCNUMFIRSTSIX, CORPORATECARD_TST. FORMOFPAYCCNUMLASTFOUR) = (select distinct CORPORATECARD_SQL. USERNAME, CORPORATECARD_SQL. CREDITCARDIDCD, CORPORATECARD_SQL. DATEINSERTED, CORPORATECARD_SQL. DATEUPDATED, CORPORATECARD_SQL. CUSTOMERNAME, CORPORATECARD_SQL. FORMOFPAYCCNUMFIRSTSIX, CORPORATECARD_SQL. Join FORMOFPAYCCNUMLASTFOUR internal CORPORATECARD_SQL CORPORATECARD_TST on CORPORATECARD_SQL. CORPORATECARDID = CORPORATECARD_TST. CORPORATECARDID);

    CREATE TABLE CORPORATECARD_TST

    (

    CORPORATECARDID NUMBER(*, 0) NOT NULL

    VARCHAR2 (50 BYTE) USER NAME NOT NULL

    CREDITCARDIDCD CHAR (2 BYTES) NOT NULL

    DATEINSERTED DATE NOT NULL

    DATEUPDATED DATE NOT NULL

    VARCHAR2 (255 BYTE) CUSTOMERNAME

    FORMOFPAYCCNUMFIRSTSIX CHAR (6 BYTES)

    FORMOFPAYCCNUMLASTFOUR CHAR (4 BYTES)

    )

    CREATE TABLE CORPORATECARD_SQL

    (

    CORPORATECARDID NUMBER(*, 0) NOT NULL

    VARCHAR2 (50 BYTE) USER NAME NOT NULL

    CREDITCARDIDCD CHAR (2 BYTES) NOT NULL

    DATEINSERTED DATE NOT NULL

    DATEUPDATED DATE NOT NULL

    VARCHAR2 (255 BYTE) CUSTOMERNAME

    FORMOFPAYCCNUMFIRSTSIX CHAR (6 BYTES)

    FORMOFPAYCCNUMLASTFOUR CHAR (4 BYTES)

    )

    Here is the data in the table _TST

    2044 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2007 TestUser AX 30 January 12 January 30, 12 TestClient 123456 9876

    2004 TestUser AX 30 January 12 January 30, 12 TestClient 123456 9876

    2010 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    TestUser AX 19-SEVEN 6. - 11 19 - SEPT. - 11 123456 9876 TestClient

    2045 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2020 TestUser AX 1 February 12 February 1, 12 TestClient 123456 9876

    2011 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    2012 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    2046 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2138 TestUser AX 26 July 12 July 26, 12 TestClient 123456 9876

    Here is the data in the table _SQL

    2009 NEW TestUser DS 31 January 12 January 31, 12 NEW TestClient 999999 0

    2044 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2007 NEW TestUser DC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2004 NEW TestUser MC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2010 NEW TestUser VI 31 January 12 January 31, 12 NEW TestClient 999999 0

    6 NEW TestUser AX 19-SEVEN. - 11 19 - SEPT. - 11 NEW TestClient 999999 0

    2045 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2020 NEW TestUser DS 1 February 12 February 1, 12 NEW TestClient 999999 0

    2011 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2012 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2046 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2138 NEW TestUser AX 26 July 12 July 26, 12 NEW TestClient 999999 0

    Here's the MERGE statement...

    MERGE INTO CORPORATECARD_TST D
    USING
    (
    Select distinct
    CORPORATECARD_SQL. CORPORATECARDID
    CORPORATECARD_SQL. USERNAME
    CORPORATECARD_SQL. CREDITCARDIDCD
    CORPORATECARD_SQL. DATEINSERTED
    CORPORATECARD_SQL. DATEUPDATED
    CORPORATECARD_SQL. CUSTOMERNAME
    CORPORATECARD_SQL. FORMOFPAYCCNUMFIRSTSIX
    CORPORATECARD_SQL. FORMOFPAYCCNUMLASTFOUR
    Of
    CORPORATECARD_SQL
    ) S
    WE
    (
    D.CORPORATECARDID = S.CORPORATECARDID
    )
    WHEN MATCHED, THEN UPDATE GAME
    S.USERNAME = D.USERNAME
    D.CREDITCARDIDCD = S.CREDITCARDIDCD,
    D.DATEINSERTED = S.DATEINSERTED,
    D.DATEUPDATED = S.DATEUPDATED,
    D.CLIENTNAME = S.CLIENTNAME,
    D.FORMOFPAYCCNUMFIRSTSIX = S.FORMOFPAYCCNUMFIRSTSIX,
    D.FORMOFPAYCCNUMLASTFOUR = S.FORMOFPAYCCNUMLASTFOUR,

    WHEN NOT MATCHED THEN INSERT
    (
    D.CORPORATECARDID
    D.USERNAME
    D.CREDITCARDIDCD
    D.DATEINSERTED
    D.DATEUPDATED
    D.CLIENTNAME
    D.FORMOFPAYCCNUMFIRSTSIX
    D.FORMOFPAYCCNUMLASTFOUR
    )
    VALUES
    (
    S.CORPORATECARDID
    S.USERNAME
    S.CREDITCARDIDCD
    S.DATEINSERTED
    S.DATEUPDATED
    S.CLIENTNAME
    S.FORMOFPAYCCNUMFIRSTSIX
    S.FORMOFPAYCCNUMLASTFOUR
    )
    ;

    The desired output would be for the _TST and the _SQL to have the same data as the _SQL as below...

    2009 NEW TestUser DS 31 January 12 January 31, 12 NEW TestClient 999999 0

    2044 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2007 NEW TestUser DC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2004 NEW TestUser MC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2010 NEW TestUser VI 31 January 12 January 31, 12 NEW TestClient 999999 0

    6 NEW TestUser AX 19-SEVEN. - 11 19 - SEPT. - 11 NEW TestClient 999999 0

    2045 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2020 NEW TestUser DS 1 February 12 February 1, 12 NEW TestClient 999999 0

    2011 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2012 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2046 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2138 NEW TestUser AX 26 July 12 July 26, 12 NEW TestClient 999999 0

    However, after I compile and run the Sp that has the MERGER, data still looks like this...

    Here is the data in the table _TST

    2044 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2007 TestUser AX 30 January 12 January 30, 12 TestClient 123456 9876

    2004 TestUser AX 30 January 12 January 30, 12 TestClient 123456 9876

    2010 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    TestUser AX 19-SEVEN 6. - 11 19 - SEPT. - 11 123456 9876 TestClient

    2045 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2020 TestUser AX 1 February 12 February 1, 12 TestClient 123456 9876

    2011 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    2012 TestUser AX 31 January 12 January 31, 12 TestClient 123456 9876

    2046 TestUser AX 2 February 12 February 2, 12 TestClient 123456 9876

    2138 TestUser AX 26 July 12 July 26, 12 TestClient 123456 9876

    Here is the data in the table _SQL

    2009 NEW TestUser DS 31 January 12 January 31, 12 NEW TestClient 999999 0

    2044 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2007 NEW TestUser DC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2004 NEW TestUser MC 30 January 12 January 30, 12 NEW TestClient 999999 0

    2010 NEW TestUser VI 31 January 12 January 31, 12 NEW TestClient 999999 0

    6 NEW TestUser AX 19-SEVEN. - 11 19 - SEPT. - 11 NEW TestClient 999999 0

    2045 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2020 NEW TestUser DS 1 February 12 February 1, 12 NEW TestClient 999999 0

    2011 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2012 NEW TestUser AX 31 January 12 January 31, 12 NEW TestClient 999999 0

    2046 NEW TestUser VI 2 February 12 February 2, 12 NEW TestClient 999999 0

    2138 NEW TestUser AX 26 July 12 July 26, 12 NEW TestClient 999999 0

  • single row subquery returns more than 1 row

    UPDATE Rftm_Pidwise_Revenue_Dtls
    SET cost_prior_qtr = (select cost_forecast_end
    of rftm_time_entry_calc
    where rftm_time_entry_calc.pid = Rftm_Pidwise_Revenue_Dtls.pid
    AND rftm_time_entry_calc.ideal_ref_no = Rftm_Pidwise_Revenue_Dtls.ideal_ref_no
    )
    WHERE ideal_ref_no = '140014';

    Hi all
    I have a requirement where I have to update a table (Rftm_Pidwise_Revenue_Dtls) and the value of the column 'cost' to the ' 140014 ideal_ref_no'. for this issue, there are several records in the tables that I use in my application. I want to match the corresponding 'pid' and update the cost for each "pid".
    Please help me with a correct query.

    Kind regards
    Belin
    Try once...(untested)
    
    MERGE INTO Rftm_Pidwise_Revenue_Dtls TRG
    using
    (
    select DISTINCT A.cost_forecast_end cost_forecast_end,B.ROWID RI
    from rftm_time_entry_calc A,Rftm_Pidwise_Revenue_Dtls B
    where A.pid=B.pid
    AND A.ideal_ref_no=B.ideal_ref_no
    AND B.ideal_ref_no='140014';
    ) SRC
    on
    (TRG.ROWID=SRC.RI)
    WHEN MATCHED THEN UPDATE
    SET TRG.cost_prior_qtr =SRC.cost_forecast_end;
    
  • Error - ORA-01422: exact fetch returns more than number of lines

    Hello

    I get the error when running script below. Please help me.

    /****************** ERROR ******************/

    Error report:
    ORA-01422: exact fetch returns more than number of lines
    ORA-06512: at line 71
    01422 00000 - "exact fetch returns more than number of lines."
    * Cause: Exact extraction specified number is less than the returned rows.
    * Action: Rewrite the query or change the number of rows requested



    /****************** SCRIPT ******************/

    DECLARE

    l_xml XMLTYPE: = XMLTYPE ("< LoggingInformation >
    < commandeEmplacement >
    < name > ServiceCall1 < / name >
    < StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
    < EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
    < ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
    < status > completed < / status >
    < ExceptionMessage > error here... < / ExceptionMessage >
    < ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
    < ServiceLoggingEntries >
    < item >
    < foo > 1 < / foo >
    < / ServiceInformation >
    < item >
    < foo > 2 < / foo >
    < / ServiceInformation >
    < / ServiceLoggingEntries >
    < InformationLoggingEntries >
    < ProcessInformation >
    < bar > 1 < / >
    < / ProcessInformation >
    < ProcessInformation >
    < bar > 2 < / >
    < / ProcessInformation >
    < / InformationLoggingEntries >

    < / commandeEmplacement >
    < commandeEmplacement >
    < name > ServiceCall2 < / name >
    < StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
    < EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
    < ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
    < status > completed < / status >
    < ExceptionMessage > error here... < / ExceptionMessage >
    < ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
    < ServiceLoggingEntries >
    < item >
    < foo > 3 < / foo >
    < / ServiceInformation >
    < item >
    < foo > 4 < / foo >
    < / ServiceInformation >
    < / ServiceLoggingEntries >
    < InformationLoggingEntries >
    < ProcessInformation >
    < bar > 3 < / >
    < / ProcessInformation >
    < ProcessInformation >
    < bar > < / > 4
    < / ProcessInformation >
    < / InformationLoggingEntries >
    < / commandeEmplacement >

    < commandeEmplacement >
    < name > ServiceCall3 < / name >
    < StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
    < EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
    < ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
    status of <>failed < / status >
    < ExceptionMessage > error here... < / ExceptionMessage >
    < ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
    < / commandeEmplacement >
    (< / LoggingInformation > ');

    v_txt VARCHAR2 (2000);

    BEGIN

    SELECT XMLTYPE. Extract (value (TT),'/ CommandInformation/Name/Text () '). GETSTRINGVAL()
    IN v_txt
    TABLE (XMLSEQUENCE (l_xml. Extract('/LoggingInformation/CommandInformation'))) tt;

    DBMS_OUTPUT. Put_line (v_txt);

    END;

    Select...

    means only 1 row can be returned.

    Your select returns more than one line.
    Change v_txt in a collection, define a cursor and the extraction of it or change the statement, i.e. it returns a single line.

    ---------
    Sybrand Bakker
    Senior Oracle DBA

  • I can't have more than one value of function?

    I hope all of you can point me to some introductory articles/documents on function.

    I know the function is used to calculate a value and it always returns a single value.

    I want to know I can get more than one value of function? If so please share a few lines of code

    Hello

    Certainly, you CAN define functions with OUT parameters. It is generally not advisable to do so, however. Working with settings, for example, can be called from SQL, among other useful things.

    If you are wanting a function that returns multiple values, you would generally be

    -create a procedure that has several OUT parameters

    -create a function that returns a type of object that encapsulates the values that you want to return

    How to make FUNCTION returns several columns and several outputs line

    can functions return multiple values?

    oracle function to return more than one value

    You must give several values of function that can be found in Sql

  • Error creating a salary. ORA-01422: exact fetch returns more than the requested number of rows in the hr_maintain_proposal_swi procedure insert_salary_proposal package

    Hi all

    We try to add new proposal for a salary of some employees from form August 1, 2015 (the Date of the beginning of employee)

    There is no existing salary proposal doesn't exist for these employees.

    We get below error.


    ORA-01422: exact fetch returns more than the requested number of rows in the hr_maintain_proposal_swi procedure insert_salary_proposal package


    Help, please.

    Thank you

    Tarun

    Hi John,.

    If it helps, take a look at the following note:

    ORA-01422 exact Fetch returns more than number of lines requested in Hr_maintain_proposal_swi (Doc ID 1673527.1)

    Kind regards

    Rajen

Maybe you are looking for

  • Unable to take a screenshot

    I'm taking a screenshot, and it refuses to work. [If I use the command] + [Shift] + 3 for a full screen grab, or command] + [Shift] + 4 to select a part, nor work. All I get is the "thump" sound warning me of an invalid command / typo.

  • I just took a new turn computer w/Win 7 64 bit and I'm installing on an existing network

    I downloaded the Software Solution complete HP Color LaserJet 2600n hp_CLJ_2600n_Full_Solution-v20110217-50132926-RC5-signed and tried to install it.  However, it stops (failure) after that, he sees the 2600n on the network.  Any ideas?

  • Object CitadelControl

    Hi people, I want to introduce in my default application Lookout (now 6.1), the ability to periodically make a backup of the historical database to another on the same PC, that way I can fix the life expectancy of default database for a few days inst

  • Need XP drivers for laptop Pavilion G6-1215sp

    Hello, can someone help me find the drivers for Windows XP? Thank you!

  • HP Photosmart 7520 vs 7525

    Forgive me if this is the wrong place to post this questin, but I could not learn the difference between the HP Photosmart 7520 and the HP Photosmart 7525 anywhere.  Y at - it you to experts who can direct me to where HP provides this information. or