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

Tags: Database

Similar Questions

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

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

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

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

  • 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

  • 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

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

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

  • More than one query

    You use oracle apex and an element hidden with sql query, I want to ask these two questions:
    one removes all of this table, while the other inserts the values 1.0
    My problem is how to do it following this exact order? If I write the two like that, it gives me an error, so somewhere is a problem

    Suppression of clicks where nr = (select nr of clicks where c > 0)
    insert into clicks values (1,0)

    but not sure you try

    BEGIN
    delete from clicks where nr =(select nr from clicks where nr>0);
    insert into clicks values (1,0);
    END;
    
  • 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;
    
  • einreihig subquery returns multiple rows

    Hello


    In the sub query, I get the error "ORA-01427: einreihig subquery returns more than one line. In this query below, I must also display only the bsr_ind_id from rm_cust where are.bsr_borr_ctg_id = '1' and also all cust_name and client_id

    How can I modify this query?

    Select cust_name
    client_id
    , (select bsr_ind_id from rm_cust r where are.bsr_borr_ctg_id = '1') as "SSB".
    of rm_cust

    I haven't used the pivotal enough to help with that without doing some research which I do not have time for this moment. But back to your original problem: there is obviously more than 1 line in rm_cust with bsr_borr_ctg_id = '1', so what one do you? You can guarantee that you will not get the error if you use:

    select cust_name
          ,client_id
          ,(select max(bsr_ind_id) from rm_cust r where r.bsr_borr_ctg_id = '1') as "BSR"
    from rm_cust
    

    Or you can use min max. Either avoid the error you get. If both give you the same result, then that is what you need. If they give different results, then you need to determine what (if) is correct.

  • 01427 00000 - "einreihig subquery returns several lines.

    Hi all
    How can I solve it
    SELECT 
           v.code
          ,v.bar_code
          ,v.arb_name
          ,v.eng_name
          ,v.branch_no
          ,(SELECT sum(quantity) FROM viw_whs_items_movement GROUP BY branch_no)
    FROM  viw_whs_items_movement V
    This code gives me this error
    01427 00000 - "einreihig subquery returns several lines.
    I know that I have more value, but I need this value

    Result group
    SELECT sum(v.quantity) 
    FROM viw_whs_items_movement v 
    GROUP BY v.branch_no
    ##########################
    SUM(V.QUANTITY)
    ---------------
             114453 
               2501 
               8137 
              13270 
              15230 
             120626 
              22536 
               2926 
              12848 
              37509 
              20911 
               7503 
               6248 
              17221 
                462 
                 24 
              15041 
              10307 
              12524 
             526627 
              10564 
               8230 
              13204 
               2840 
              80769 
            1418238 
             215694 
              15238 
               5063 
             104187 
                913 
             147079 
              11293 
              12678 
              18855 
    
     35 rows selected 

    Must be scalar subqueries. You demonstrate your subquery returns more than one line. Where the error.

    A solution would be to establish a correlation between the results of the subquery by joining the branch_id with branch_id of the outer query. However, as the two queries use the same table, you can simply use an analytical SUM():

    SELECT
           v.code
          ,v.bar_code
          ,v.arb_name
          ,v.eng_name
          ,v.branch_no
          ,sum(quantity) over (partition by branch_no) as branch_tot
    FROM  viw_whs_items_movement V      
    

    Cheers, APC

  • 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

Maybe you are looking for