Getting Error - Single-row subquery returns more than 1 row (Help Needed)

I have the following SQL. It selects several rows of data. This data reflects changed records. I want to update PS_UNI_TEXTBK_SKEW for the values selected. Any ideas. For updating I used:
update ps_uni_textbk_skew s
set (s.ssr_txbdtl_title, s.ssr_txbdtl_isbn, s.ubs_skew_num, s.process_date, s.ubs_rec_type) = (
and then I included theselect listed below. (this selects does work). It always produces an error saying 'singl-row subjquery returns more than 1 row'.
Any help would be appreciated. I've worked on this for a week now trying many different ways. Thanks, Mary
SELECT NOW.SSR_TXBDTL_TITLE
,NOW.SSR_TXBDTL_ISBN
,0
,SUBSTR(SYSDATE,1,8)
,'C'
FROM
SELECT C.SUBJECT||C.CATALOG_NBR||C.CLASS_SECTION||C.STRM||B.SSR_TXBDTL_SEQNO AS TYINGKEEN
,C.CRSE_ID
,C.CRSE_OFFER_NBR
,C.STRM
,C.SUBJECT
,C.CATALOG_NBR
,C.CLASS_SECTION
,C.DESCR
,B.SSR_TXBDTL_SEQNO
,B.SSR_CRSEMAT_TYPE
,B.SSR_TXBDTL_STATUS
,B.SSR_TXBDTL_TITLE
,B.SSR_TXBDTL_ISBN
,B.SSR_TXBDTL_AUTHOR
,B.SSR_TXBDTL_PUBLISH
,B.SSR_TXBDTL_EDITION
,B.SSR_TXBDTL_PUBYEAR
,B.SSR_TXBDTL_NOTES
FROM PS_CLASS_TBL C,
PS_SSR_CLS_TXB_DTL B
WHERE C.CRSE_ID = B.CRSE_ID
AND C.CRSE_OFFER_NBR = B.CRSE_OFFER_NBR
AND C.STRM = B.STRM
AND C.CLASS_SECTION = B.CLASS_SECTION
) NOW,
SELECT SUBJECT||CATALOG_NBR||CLASS_SECTION||STRM||SSR_TXBDTL_SEQNO AS TYINGKEEL
,CRSE_ID
,CRSE_OFFER_NBR
,STRM
,SUBJECT
,CATALOG_NBR
,CLASS_SECTION
,DESCR
,SSR_TXBDTL_SEQNO
,SSR_CRSEMAT_TYPE
,SSR_TXBDTL_STATUS
,SSR_TXBDTL_TITLE
,SSR_TXBDTL_ISBN
,SSR_TXBDTL_AUTHOR
,SSR_TXBDTL_PUBLISH
,SSR_TXBDTL_EDITION
,SSR_TXBDTL_PUBYEAR
,SSR_TXBDTL_NOTES
FROM PS_UNI_TEXTBK_SKEW
) LAST
WHERE NOW.TYINGKEEN = LAST.TYINGKEEL
AND (NOW.SSR_TXBDTL_TITLE <> LAST.SSR_TXBDTL_TITLE
OR NOW.SSR_TXBDTL_ISBN <> LAST.SSR_TXBDTL_ISBN
OR NOW.SSR_TXBDTL_AUTHOR <> LAST.SSR_TXBDTL_AUTHOR
OR NOW.SSR_TXBDTL_PUBLISH <> LAST.SSR_TXBDTL_PUBLISH
OR NOW.SSR_TXBDTL_EDITION <> LAST.SSR_TXBDTL_EDITION
OR NOW.SSR_TXBDTL_PUBYEAR <> LAST.SSR_TXBDTL_PUBYEAR
OR NOW.SSR_TXBDTL_NOTES <> LAST.SSR_TXBDTL_NOTES
OR NOW.SSR_TXBDTL_STATUS <> LAST.SSR_TXBDTL_STATUS
OR NOW.SSR_CRSEMAT_TYPE <> LAST.SSR_CRSEMAT_TYPE
OR NOW.DESCR <> LAST.DESCR);

1. Take your subqueries
2. Run those separately to see if they really can return more than one row. If needed modify the subquery by adding GROUP-BY and HAVING-COUNT>1 clauses to determien that.
3. If you see more than one row coming up from subqueries then the error message you named will arise.
This is what i would do.
But in first look you don't have subqueries, you have "inline-views". so i don't understand how the eroor could occur.
Edited by: CharlesRoos on 22.10.2010 16:38

Similar Messages

  • Discoverer 11g Workbook Fails With Single row subquery returns more than 1

    All -
    We are using discoverer-11g workbook using EBS 12.1.3 integration
    We are seeing below error message only for few users on all workbooks in discoverer.
    ORA-01427 Single row subquery returns more than one row
    EBS Version : 12.1.3
    Discoverer Version : 11.1.1.6
    Database Version : 11.2.0.3
    Please advise on this
    Regards
    VSH

    Hi,
    If it is happening for only a few users then the problem may be caused by security conditions built into the query. However, you need to give us some information about the SQL the workbooks are running. Do you get this error even for the very simple queries?
    Rod West

  • ORA-01427: single-row subquery returns more than one row HELP

    I need to update baemployee.Stock_nbr field with select substr(C.CHECK_DIGIT, 3, 10)
    from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE
    Please help.
    update baemployee e
    set Stock_nbr = (select substr(C.CHECK_DIGIT, 3, 10)
    from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
    where exists
    (select C.CHECK_DIGIT
    from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
    and exists (select 1 from EMPLOYEE ee where ee.employee = e.employee and ee.emp_status like 'A%');
    ORA-01427: single-row subquery returns more than one row

    Hi,
    Welcome to the forum!
    Whenever you have a question, please post some sample data, so that people can re-create the problem and test their solutions.
    CREATE TABLE and INSERT statements, like the ones below, are great:
    CREATE TABLE      baemployee
    (     employee     NUMBER (4)
    ,     stock_nbr     VARCHAR2 (10)
    INSERT INTO baemployee (employee, stock_nbr) VALUES (1234, 'FUBAR');
    CREATE TABLE     employee
    (     employee     NUMBER (4)
    ,     emp_status     VARCHAR2 (10)
    INSERT INTO employee (employee, emp_status) VALUES (1234, 'ACTIVE');CREATE TABLE AS is good, too:
    CREATE TABLE     emp_check_dig
    AS          SELECT  1234 AS employee, 'AA1234567890ZZZ' AS check_digit     FROM dual
    UNION ALL     SELECT  1234,            'AA2121212121ZZZ'               FROM dual
    ;Also post the results you want from that data. In this case, the results would be the contents of the baemployee table after you run the UPDATE.
    Would you want:
    employee  stock_nbr
    1234       1234567890or would you want
    employee  stock_nbr
    1234       2121212121If you run the UPDATE statement you posted with the data above, you'll get the "ORA-01427: single-row subquery returns more than one row" error, and you can see what causes it: there is more than one row from emp_check_dig that could be used to UPDATE the same row of baemployee. Say what you want to do in this situation (and why), and someone will help you find a way to do it.

  • Update gives "single-row subquery returns more than one row"

    Hi,
    I have to update a table by getting values from two other tables. While doing that the inner query returns more than one value. I am not sure how to implement the logic without returning more than one row in sub quesry. Need help on that.
    My query:
    update buf_office_str o
    set o.manager_ident =
    (select sp.ident
    from se2_r_src_sourceperson sp ,
    (select distinct director_name, team_name from buf_sales_dump )t
    where SP.SRCNAME = upper(substr(t.director_name,instr(t.director_name,' ')+1,length(t.director_name))||', '||substr(t.director_name,1,instr(t.director_name,' ')-1 ) )
    and o.office_descr = t.team_name
    Basically the query gets teh manager id from sp table where sp.srcname = t.team-name.
    The office descr should be equal to the team_name.
    This is the logic I am working towards:
    For each office, i get the office_descr and get corresponding team_name. Match the team's director_name (from table t) with the sp.name and return the employee's id (sp.ident) for that office_descr.
    I need to update all 50 offices with corresponding managerid for that office in buf_office_str table.
    Is it possible to get done in one update? Pls let me know.

    Hi,
    "Single-row subquery returns more than one row" is one of those error messages that actually means what it says: the correlated sub-query in your SET clause is sometimes returning 2 or more rows .
    The solution could be as simple as making the sub-query SELECT DISTINCT , as its in-line view, t, already is.
    It's possible you have bad data, or a mistake in your statement.
    To find the problem cases, you can run something like this:
    WITH  sub_q     AS
                       SELECT  -- DISTINCT ?
                                sp.ident
                       ,         t.team_name
                       ,         COUNT (*) OVER (PARTITION BY t.team_name)     AS cnt
                       FROM    se2_r_src_sourceperson     sp
                       ,         (  SELECT DISTINCT director_name
                                   ,                  team_name
                               FROM            buf_sales_dump
                             )                    t
                       WHERE   sp.srcname     = UPPER ( SUBSTR ( t.director_name
                                                         , INSTR ( t.director_name
                                                  ) + 1
                                                , LENGTH (t.director_name)
                                          || ', '
                                          || SUBSTR ( t.director_name
                                                          , 1
                                                   , INSTR ( t.director_name
                                                        ) - 1
    SELECT     o.*     -- or whatever helps you
    ,     sq.*
    FROM     buf_office_str     o
    JOIN     sub_q          sq     ON     o.office_descr = sq.team_name
    WHERE     sq.cnt          > 1
    ;If you'd like more help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables as they exist before the UPDATE, and the results you want from that data (that is, the contents of buf_office_str after the UPDATE). Make sure the problem occurs with the sample data you post.

  • Still problem with single-row subquery returns more than one row

    //i did join each table but query runs forever and fail. looks Cartesian join so comes up the following SQL
    the following query has a problem. would you please help me, please
    Select pe.expense_id
    ,PE.CODE
    ,PE.PROJECT_ID
    ,PE.LDATE
    ,PE.INAMOUNT pe_amount
    ,(SELECT TRX.INV_AMOUNT FROM TRXEXPENSES TRX
    WHERE PE.EXPENSE_ID=TRX.EXPENSE_ID) AS invamount
    ,(SELECT RE.AMOUNT FROM REEXPENSES RE WHERE
    PE.EXPENSE_ID=RE.EXPENSE_ID) AS recogamount
    ,(SELECT MLE.M_AMOUNT FROM MATEXPENSES MLE
    WHERE PE.EXPENSE_ID=MLE.EXPENSE_ID) AS matamount
    from EXPENSES PE
    where pe.expense_id=5600
    group by expense_id,CODE,PROJECT_ID,LDATE,inamount
    //get error message
    ora-01427:single-row subquery returns more than one row
    //check database
    select expense_id,count(*) from TRXEXPENSES
    where expense_id in(select expense_id from
    expenses)
    group by expense_id
    having count(*)>1
    //here is duplicate record a lot
    EXPENSE_ID     COUNT(*)
    4176     2
    5600     3
    9572     2
    9573     2
    9574     2

    Yes, Expense_id has so many returning rows for trx.inv_amount from trxexpenses in subquery.
    I want to show Expense_id with retruning rows using the above query.
    ex)The result of the query is like that;
    Expense_ Id project_id Ldate InvAmount RecogAmount MatAmount
    5600 123 3/2/02 $100(InvAmount)
    5600 432 3/12/02 $200(recogAmount)
    5600 432 4/12/02 $250(MatAmount)
    Thank you so much
    Message was edited by:
    user524064
    Message was edited by:
    user524064

  • TWO ERRO ORA-01427: single-row subquery returns more than one row

    Hi,
    I have a procedure which contains a cursor. If i run the select statement in the cursor separetly, it returns only value and works fine. But the same select statement in the cursor of a procedure throws me the error as below:
    TWO ERRO ORA-01427: single-row subquery returns more than one row
    Not sure what going on...any help appreciated.
    Below is the select statement:
    SELECT DISTINCT PSE.PARENT_POSITION_ID,
    (SELECT DISTINCT PPD1.SEGMENT2
    FROM PER_POSITION_DEFINITIONS PPD1,
    HR_ALL_POSITIONS_F HAPF2,
    PER_POS_STRUCTURE_ELEMENTS PSE2
    WHERE TRUNC(SYSDATE) BETWEEN
    HAPF2.EFFECTIVE_START_DATE AND
    HAPF2.EFFECTIVE_END_DATE
    AND PPD1.POSITION_DEFINITION_ID =
    HAPF2.POSITION_DEFINITION_ID
    AND
    HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
    AND PSE2.PARENT_POSITION_ID =
    PSE.PARENT_POSITION_ID
    AND ROWNUM = 1) SEGMENT2,
    (SELECT DISTINCT PAPF1.FIRST_NAME || ' ' ||
    PAPF1.LAST_NAME CHIEF_NAME
    FROM PER_ALL_PEOPLE_F PAPF1,
    PER_ALL_ASSIGNMENTS_F PAAF1
    WHERE TRUNC(SYSDATE) BETWEEN
    PAPF1.EFFECTIVE_START_DATE AND
    PAPF1.EFFECTIVE_END_DATE
    AND TRUNC(SYSDATE) BETWEEN
    PAAF1.EFFECTIVE_START_DATE AND
    PAAF1.EFFECTIVE_END_DATE
    AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
    AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
    AND ROWNUM = 1) CHIEF_NAME
    FROM PER_POS_STRUCTURE_ELEMENTS PSE,
    HR_ALL_POSITIONS_F HAPF,
    PER_POSITION_DEFINITIONS PPD
    WHERE PSE.SUBORDINATE_POSITION_ID = 52744
    AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND
    HAPF.EFFECTIVE_END_DATE
    AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
    AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;
    Thanks
    PK
    Edited by: user539616 on Jun 30, 2009 6:30 PM

    Hi,
    The cursor has a different parameter? Maybe the query is not exactly the same. Could you check this?
    This is your query (formatted):
    SELECT DISTINCT PSE.PARENT_POSITION_ID,
                    (SELECT DISTINCT PPD1.SEGMENT2
                       FROM PER_POSITION_DEFINITIONS   PPD1,
                            HR_ALL_POSITIONS_F         HAPF2,
                            PER_POS_STRUCTURE_ELEMENTS PSE2
                      WHERE TRUNC(SYSDATE) BETWEEN HAPF2.EFFECTIVE_START_DATE AND
                            HAPF2.EFFECTIVE_END_DATE
                        AND PPD1.POSITION_DEFINITION_ID = HAPF2.POSITION_DEFINITION_ID
                        AND HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
                        AND PSE2.PARENT_POSITION_ID = PSE.PARENT_POSITION_ID
                        AND ROWNUM = 1) SEGMENT2,
                    (SELECT DISTINCT PAPF1.FIRST_NAME || ' ' || PAPF1.LAST_NAME CHIEF_NAME
                       FROM PER_ALL_PEOPLE_F      PAPF1,
                            PER_ALL_ASSIGNMENTS_F PAAF1
                      WHERE TRUNC(SYSDATE) BETWEEN PAPF1.EFFECTIVE_START_DATE AND
                            PAPF1.EFFECTIVE_END_DATE
                        AND TRUNC(SYSDATE) BETWEEN PAAF1.EFFECTIVE_START_DATE AND
                            PAAF1.EFFECTIVE_END_DATE
                        AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
                        AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
                        AND ROWNUM = 1) CHIEF_NAME
      FROM PER_POS_STRUCTURE_ELEMENTS PSE,
           HR_ALL_POSITIONS_F         HAPF,
           PER_POSITION_DEFINITIONS   PPD
    WHERE PSE.SUBORDINATE_POSITION_ID = 52744
       AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND HAPF.EFFECTIVE_END_DATE
       AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
       AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;Tips: To put formatted code you must use {noformat}{noformat} tags, start tag and end tag are the same,you don't need to put '/' in the close tag.
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • ORA-01427 single-row subquery returns more than requested number of rows

    Hi All,
    SR#3-5155460391
    When opening the Expense report form the given error occurs.
    This is happening with only one employee.
    The condition could not be evaluated because of error ORA-01427
    single-row subquery returns more than requested number of rows.
    query is:
    select pea.segment5
    from
    per_all_assignments_f paf,
    pay_personal_payment_methods_f ppm,
    pay_external_accounts pea,
    fnd_application fap,
    fnd_id_flex_structures ffs
    where
    paf.person_id=:employee_id
    and paf.primary_flag='Y'
    and paf.assignment_type='E'
    and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
    and ppm.assignment_id=paf.assignment_id
    and trunc(sysdate) between ppm.effective_start_date and ppm.effective_end_date
    and ppm.attribute2='Y'
    and pea.external_account_id=ppm.external_account_id
    and pea.id_flex_num=ffs.id_flex_num
    and fap.application_short_name='PAY'
    and ffs.application_id=fap.application_id
    and ffs.id_flex_code='BANK'
    and ffs.id_flex_structure_code='GB_BANK_DETAILS';
    Thanks,
    Shikha
    Edited by: user10456902 on Feb 3, 2012 1:57 AM

    Hi,
    First try to find pea.external_account_id from per_all_people_f,per_all_assignments_f,fnd_application.fnd_id_flex_structures etc
    and then find
    SELECt pea.segment5
    FROM pay_external_accounts pea
    WHERE pea.external_account_id = : external_account_id -- derived from SQL1
    and check how many rows are returned

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

    I have a problem something like this:
    table A
    id col1 after_update
    1 ? 11
    2 ? 22
    3 ? 33
    3 ? 44
    3 ? 55
    4 ? 66
    5 ? 88
    5 ? ? /* won't be updated */
    6 ? 99
    7 ? null /* updated to null */
    9 ? 20
    table B
    id col2
    1 11
    2 22
    3 33
    3 44
    3 55
    4 66
    4 77
    5 88
    6 99
    8 10
    9 20
    When I try the query:
    update table A
    set col1 = (select distinct col2 from table B) it gives me the error ORA-01427: single-row subquery returns more than one row
    When I try the query:
    update (select x.col1 x_col1,y.col2 y_col2
    from (select id,col1,row_number() over (partition by id order by null /*col1*/) rn
    from table_a
    ) x,
    (select id,col2,row_number() over (partition by id order by col2) rn
    from table_b
    ) y
    where x.id = y.id
    and x.rn = y.rn
    set x_col1 = y_col2
    it gives me an error saying ora-01779 :cannot modify a column which maps to a non key- preserved table. It shows the same even when I add the key to the tables.
    My Database version is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
    Kindly help.

    Another way, not waterproof too relay on rowid, but in your case it could work.
    You have to verify it by yourself
    update test_a aa
    set col1 =
    (select b.col1 from
    (select
    id, col1
    ,row_number() over
      (partition by id order by col1) rn
    from table_b) b,
    ( select
      rowid, id, col1
    ,row_number() over (partition by id order by col1) sort_order
    from test_a
    ) a
    where
    a.id=b.id
    and
    sort_order = rn
    and
    aa.rowid=a.rowid
    )Edited by: chris227 on 03.04.2013 06:42
    Table name corrected

  • ORA-01427: single-row subquery returns more than one row -- no solution

    Hello to all:
    I have to tables:
    Table a anwender (Email,Dept). --> all fields are filled
    Table b dingo (Name,email,dept) --> all fields are filled
    I now want to update the table a with the data from table b:
    update anwender a set a.abteilung = ( select distinct b.abteilung from dingo b where b.email = a.email);
    Then I got the error: ORA-01427: single-row subquery returns more than one row
    Every dept is about 100x in the database, so it is clear that i got more than one row back. But how can I update the table now?

    Okay, I got several duplicates, and I deletet a lot of data in my database.
    Now I want to remove all entries with more than one departments per mail adresses.
    a
    select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung)
    shows me all the fake mailadresses.
    But a
    delete from dingo where email in (select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung) );
    gives me a
    SQL Error: ORA-00907: missing right parenthesis
    I´m very confused now ...
    Oops, now I got the solution:
    delete from dingo where email in (select email from (select email,count(abteilung) from dingo group by email having count(abteilung)>1 )) ;
    Edited by: user8309218 on Dec 18, 2009 6:24 AM

  • Single-row subquery returns more than one query

    Hi,
    i'm receiving the following error: Single-row subquery returns more than one query. I have no idea how I should debug this query. For all I know, the subqueries can only return 1 row... :S
    I only have Oracle SQL Developer to run/test my queries. I can run the query with ROWNUM < 5000, which gives no errors. If I run with ROWNUM > 5000 and ROWNUM < 6000 then the error appears....
    Here's 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;Edited by: user574699 on Nov 17, 2008 2:10 AM code formatting

    I suppose (how can i be sure?) that the queries in question are:
    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) INCOMINGand
        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) OUTGOINGBoth queries have an aggregate function based on the grouping on PNM_AUTO_KEY. Both WHERE clauses also include the = PNM_AUTO_KEY statement. So how can these return more than 1 row?
    As I stated I cannot run the subqueries without the rest. The database contains over 200000 PNM_AUTO_KEYS, and I don't know which one is causing the problems....

  • Single row subquery Returning more than one row

    Hi,
    This is urgent.............
    could u any one please suggest me on this query it returning single row subquey returnin more than one row
    In this 2nd suquery fails some of the order_numbers returning more than price_list based on dates and in that situvation also my query has to successfull
    fro that i added this condition l.ordered_quantity between trunc(product_attr_value_from) and (product_attr_value_to) for that condition also failing this query
    pls give me the correct condition to approach this solution
    select
    substr(party.party_name,1,13),
    c.account_number,
    substr(h.order_number||'-'||l.line_number||'-'||l.shipment_number,1,15),
    q.name,l.unit_selling_price,
    (select qll.operand
    apps.qp_list_headers qlh,
    apps.qp_list_lines qll,
    apps.qp_list_lines qllx
    apps.qp_pricing_attributes qpa,
    apps.qp_rltd_modifiers qrm,
    apps.mtl_system_items msi
    wherer qll.list_header_id=qlh.list_header_id
    and qpa.list_header_id=qlh.list_header_id
    and qpa.list_line_id=qll.list_line_id
    and qrm.rltd_modifier_grp_type='PRICE BREAK'
    and qll.list_line_id=qrm.to_rltd_modifier_id
    and qll.list_line_type_code='PLL'
    and qllx.list_header_id=qlh.lsit_header_id
    and qllx.list_line_id=qrm.from_rltd_modifier_id
    and qllx.list_line_type_code='PBH'
    and qlh.list_header_id=l.price_list_id
    and qpa.product_attr_value=msi.inventory_item_id
    and qpa.product_attr_value=l.inventory_item_id
    and msi.segment2 is null
    and msi.organization_id=89
    and trunc(l.request_date) between trunc(qllx.start_date_active) and trunc(nvl(qllx.end_date_active,sysdate))
    and l_ordered_quantity between qpa.pricing_attr_value_from and qpa.pricing_attr_value_to
    and qpa.product_uom_code=l.pricing_quantity_uom),
    substr(l.ordered_item,1,13),
    u.user_name,
    t.name,
    l.ordered_quantity,
    l.creation_date,
    l.request_date,
    l.pricing_date,
    l.flow_status_code
    from apps.oe_order_headers_all h,
    hz_cust_Accounts c,
    hz_parties party,
    apps.oe_order_lines_all l,
    apps.qp_list_headers_tl q,
    apps.qp_list_headers_b qb,
    apps.fnd_user u,
    apps.so_order_types_all t
    where h.header_id=l.header_id
    and h.sold_to_org_id=c.cust_account_id
    and c.party_id=party.party_id
    and trunc(l.request_date)!=trunc(l.pricing_date)
    and qb.attribute1='Q'
    and q.list_header_id=qb.list_header_id
    and l.price_list_id=q.list_header_id
    and l.flow_status_code=!='CANCELLED'
    AND t.name!='ECOM'
    and t.name!='RMA'
    and l.open_flag='Y'
    and l.item_type_code='MODEL'
    and u.user_id=l.created_by
    and t.order_type_id=h.order_type_id
    and u.user_name='XXCONVERSION'
    and (l.unit_selling_price -
    (select qll.operand
    from apps.qp_list_headers qlh,
    apps.qp_lsit_lines qll,
    apps.qp_list_lines qllx,
    apps.qp_pricing_attributes qpa,
    apps.qp_rltd_modifiers qrm,
    apps.mtl_system_items msi
    where qll.list_header_id=qlh.list_header_id
    and qpa.list_header_id=qlh.lsit_header_id
    and qpa.list_line_id=qll.list_line_id
    and qrm.rltd_modifier_grp_type='PRICE BREAK'
    AND qll.list_line_id=qrm.to_rltd_modifier_id
    and qll.list_line_type_code='PLL'
    and qllx.list_header_id=qlh.list_header_id
    and qllx.list_line_id=qrm.from_rltd_modifier_id
    and qllx.list_line_type_code='PBH'
    and qlh.list_header_id=l.price_list_id
    and qpa.product_attr_value=msi.inventory_item_id
    and qpa.product_Attr_value=l.inventory_item_id
    and msi.segmetn2 is null
    and msi.organization_id=89
    trunc(l.request_date) between trunc(qllx.start_date_active) and trunc(nvl(qllx.end_date_active,sysdate)) and
    and l.ordered_quantity between qpa.pricing_attr_value_from and qpa.pricing_attr_value_to
    and qpa.product_uom_code=l.pricing_quantity_uom)!=0)
    order by creation_date

    Hi,
    995631 wrote:
    Hi,
    This is urgent.............Then don't use this forum.
    could u any one please suggest me on this query it returning single row subquey returnin more than one row
    In this 2nd suquery fails some of the order_numbers returning more than price_list based on dates and in that situvation also my query has to successfullRemember, none of the people who want to help you are as familiar with your application as you are, so you have to explain things that are obvious to you.
    What does "sucessful" mean in this case? Does is mean producing the right results? What are the right results? How can you tell them apart from the wrong results?
    As the errror message says, the (immediate) problem is that a single-row sub-query is returning more than a single row. If the sub-query tries to bring back more than 1 row, which one do you want to use? Or do you want to use some kind of aggregate, such as the average, which might not be the same as any of them?
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Simplify the problem as much as possible. For example, remove all columns and tables that have nothing to do with the part you don't know how to do.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Single-row subquery returns more than one row - help with update

    Hello,
    I know this a probably a well documented question but when I checked the search I couldn't find anything relevant to my needs.
    I am getting the single-row error when I run this query, i have tried a where exists clause and where column_name in to no avail. Can anyone put me right with this?
    My code is:
    UPDATE test_sales
    SET total =
                (SELECT
                        p.list_price * t.quantity
                  FROM 
                        test_sales t,
                        price p
                  WHERE
                        t.product_code IN p.product_id
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) >= TO_DATE(TO_CHAR(p.start_date,'DD-MON-RR'))
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) <= TO_DATE(TO_CHAR(p.end_date,'DD-MON-RR'))
                  AND    
                        t.ship_date IS NOT NULL)the query runs fine on its own and returne 4638 rows which is the number I need to update but it wont work as part of and update. I have also tried this:
    UPDATE test_sales
    SET total =
                (SELECT
                        p.list_price * t.quantity
                  FROM 
                        test_sales t,
                        price p
                  WHERE
                        t.product_code IN p.product_id
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) >= TO_DATE(TO_CHAR(p.start_date,'DD-MON-RR'))
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) <= TO_DATE(TO_CHAR(p.end_date,'DD-MON-RR'))
                  AND    
                        t.ship_date IS NOT NULL)
    WHERE product_code IN 
                (SELECT
                        product_code
                  FROM 
                        test_sales t,
                        price p
                  WHERE
                        t.product_code = p.product_id
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) >= TO_DATE(TO_CHAR(p.start_date,'DD-MON-RR'))
                  AND
                        TO_DATE(TO_CHAR(t.order_date,'DD-MON-RR')) <= TO_DATE(TO_CHAR(p.end_date,'DD-MON-RR'))
                  AND    
                        t.ship_date IS NOT NULL)but that wont work either. by uising WHERE and AND clauses that select a match first on product code and then place the order_date in between the start and finish times of a distinct pricing period for each item I figured this would work but it won't. Any ideas what to try?
    Mike

    or:
    SQL> create table test_sales
      2  as
      3  select 2 quantity, 1 product_code, trunc(sysdate) order_date, trunc(sysdate) ship_date, 0 total from dual
      4  /
    Tabel is aangemaakt.
    SQL> create table price
      2  as
      3  select 10 list_price, 1 product_id, trunc(sysdate) start_date, trunc(sysdate) end_date from dual
      4  /
    Tabel is aangemaakt.
    SQL> alter table price add constraint price_pk primary key (product_id)
      2  /
    Tabel is gewijzigd.
    SQL> update ( select p.list_price * t.quantity a
      2                , t.total
      3             from test_sales t
      4                , price p
      5            where t.product_code = p.product_id
      6              and t.order_date between p.start_date and p.end_date
      7              and t.ship_date is not null
      8         )
      9     set total = a
    10  /
    1 rij is bijgewerkt.Regards,
    Rob.

  • ORA-01427: single-row subquery returns more than one row 01427. 00000 -  "single-row subquery returns more than one row"

    Hi All
    I have facing the  Single row sub query Error . I tried to resolve , but my condition not working .can please any help to rewrite the query (sub query)
    SELECT DISTINCT wdlsv.serial_number
         ,wdlsv.date_shipped
         ,wdlsv.inventory_item_id
         ,wdlsv.organization_id
         ,wdlsv.lot_number
         ,(select distinct engine from xxtc_tr_pr_open_data where chassis=wdlsv.serial_number and rownum=1
           union
           select distinct replace(replace(attribute11,'*',''),' ','')
           from xxtc_chassis_scanout_details
           where serial_number=wdlsv.serial_number
           and operation_line_code ='CHASSIS')                                     "ENGINE_NO"
         ,oola.attribute1     oh_excise_no
         ,msi.attribute16     vehicle_type
         ,bbom.attribute2     model_no
         ,xxst.tariff_code    tariff_code
         ,substr(xxst.color_type,1,1) color_type
         ,(SELECT TO_CHAR(trunc(rt.transaction_date),'RRRRMMDD')
                        FROM rcv_transactions rt,
                               rcv_shipment_lines rsl,
                               rcv_shipment_headers rsh
                        WHERE rsh.shipment_header_id=rsl.shipment_header_id
                           AND rt.shipment_header_id=rsl.shipment_header_id
                           AND rsl.attribute1=wdlsv.lot_number
                           AND rt.organization_id=wdlsv.organization_id
                           AND rt.organization_id=rsh.organization_id
                           AND ROWNUM<=1
                           union
                           select distinct to_char(xxtp.indent_import_date,'RRRRMMDD')
                 from xxtc_tr_pr_open_data  xxtp
                 where xxtp.chassis = wdlsv.serial_number)                                    "CKD_IMPORT_DATE_YEAR"
         ,to_char(xxtp.indent_import_date,'RRRRMMDD') import_date
    FROM WSH_DELIVERY_LINE_STATUS_V  WDLSV
        ,oe_order_headers_all        ooha
        ,oe_order_lines_all          oola
        ,mtl_system_items_b          msi
        ,bom_bill_of_materials       bbom
        ,xxtc_sales_tax_cal          xxst
    WHERE 1=1
    AND PICK_STATUS              = 'C'    
    AND delivery_status          = 'CL'
    AND ooha.header_id           = wdlsv.source_header_id
    AND ooha.header_id           = oola.header_id
    AND oola.line_id             = wdlsv.source_line_id
    AND msi.inventory_item_id    = wdlsv.inventory_item_id
    AND msi.organization_id      = wdlsv.organization_id
    AND bbom.assembly_item_id    = wdlsv.inventory_item_id
    AND bbom.organization_id     = wdlsv.organization_id
    AND xxst.inventory_item_id   = wdlsv.inventory_item_id
    AND xxst.organization_id     = wdlsv.organization_id
    and upper(msi.attribute15) not like 'SUB%'
    AND WDLSV.SERIAL_NUMBER IS NOT NULL;
    Regards
    Sanjay 

    This forum is for questions about working with SQL*Developer.  The title is "SQL Developer (Not for general SQL/PLSQL questions)" and yours is a general SQL question.  You should get a better answer by re-posting in the SQL and PL/SQL forum in the Oracle Database section.  Please mark this tread as answered and re-post there.

  • Single row subquery return more than one row

    Hi,
    this query rerurn no rows as i am query for perticular vendor name
    select v.id,v.vendor_id,v.vendor_name,vo.corporate_code,v.pee_id,v.vu_id,v.MAIL_ADDRESS1,v.MAIL_ADDRESS2,v.MAIL_ZIP4,vp.REDEEM_MONTH,vp.PARTICIPANTS from v_vendors v,V_VENDOR_PARTICIPANTS vp
    ,v_owners vo where vp.ven_id =v.vendor_id and vp.PARTICIPANTS <= 60 and v.vs_id in (1,4,5,6) and v.vendor_name=vo.corp_name and
    v.vendor_name = (select vo.corp_name from v_owners vo where corporate_code in (003,005,0017,0036,0111,014,0116,0120,0126,0127,0128,0130,0137,0138,0139))
    thanks.

    if the corporate_code is varchar2 of data type. i think the corporate_code should be place with
    a single quote ' such that it will look something like:
    select v.id,
           v.vendor_id,
           v.vendor_name,
           vo.corporate_code,
           v.pee_id,v.vu_id,
           v.MAIL_ADDRESS1,
           v.MAIL_ADDRESS2,
           v.MAIL_ZIP4,
           vp.REDEEM_MONTH,
           vp.PARTICIPANTS
      from v_vendors v,
           V_VENDOR_PARTICIPANTS vp,
           v_owners vo
    where vp.ven_id = v.vendor_id
       and vp.PARTICIPANTS <= 60
       and v.vs_id in (1,4,5,6)
       and v.vendor_name = vo.corp_name
       and v.vendor_name = (select vo.corp_name
                              from v_owners vo
                             where corporate_code in ('003','005','0017',
                                                      '0036','0111','014',
                                                      '0116','0120','0126',
                                                      '0127','0128','0130',
                                                      '0137','0138','0139')) or to simplify:
    select v.id,
           v.vendor_id,
           v.vendor_name,
           vo.corporate_code,
           v.pee_id,v.vu_id,
           v.MAIL_ADDRESS1,
           v.MAIL_ADDRESS2,
           v.MAIL_ZIP4,
           vp.REDEEM_MONTH,
           vp.PARTICIPANTS
      from v_vendors v,
           V_VENDOR_PARTICIPANTS vp,
           v_owners vo
    where vp.ven_id = v.vendor_id
       and vp.PARTICIPANTS <= 60
       and v.vs_id in (1,4,5,6)
       and v.vendor_name = vo.corp_name
       and vo.corporate_code in ('003','005','0017','0036','0111','014',
                                 '0116','0120','0126','0127','0128','0130',
                                 '0137','0138','0139'))

  • Single row subquery returns more than 1 row

    UPDATE Rftm_Pidwise_Revenue_Dtls
    SET cost_prior_qtr = (select cost_forecast_end
    from 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 in i have to update a table (Rftm_Pidwise_Revenue_Dtls) and set the 'cost' column for the ideal_ref_no '140014'. for this number there are multiple records in both the tables i am using in my query. i want to match the corresponding 'pid' and update the cost for each 'pid'.
    please help me with a correct query.
    Regards,
    Basavaraj

    Please help me related to this program error
    CREATE OR REPLACE PROCEDURE APPS.XXMKSUPP
    ( errbuf OUT VARCHAR2,
    retcode OUT NUMBER
    IS
    TYPE supp_array IS TABLE OF XXMKS_EQRS_SUPPLIER_HOLD%ROWTYPE;
    CURSOR supp_details
    IS
    SELECT pv.segment1|| '-'||pvs.vendor_site_id "Supplier_Number",
    PV.END_DATE_ACTIVE AS "Inactive",
    PV.VENDOR_NAME AS "SUPPLIER NAME",
    PV.VENDOR_TYPE_LOOKUP_CODE AS "SUPPLIER TYPE",
    Pv.Segment1 AS INTERFACE_ATTRIBUTE1,
    NULL AS INTERFACE_ATTRIBUTE2,
    NULL AS INTERFACE_ATTRIBUTE3,
    NULL AS INTERFACE_ATTRIBUTE4,
    NULL AS Interface_Attribute5,
    (SELECT (Pvc.First_Name||' '||Pvc.Last_Name) FROM po_vendor_contacts pvc
    WHERE 1=1 AND Pvs.Vendor_Site_Id=Pvc.Vendor_Site_Id
    AND pvc.last_update_date = (SELECT MAX(p.last_update_date) FROM po_vendor_contacts p
    WHERE p.Vendor_Site_Id = Pvs.Vendor_Site_Id ) and rownum=1 ) " CONTACT_NAME",
    (SELECT Pvc.Title FROM po_vendor_contacts pvc
    WHERE 1=1 AND Pvs.Vendor_Site_Id=Pvc.Vendor_Site_Id
    AND pvc.last_update_date = (SELECT MAX(p.last_update_date) FROM po_vendor_contacts p
    WHERE p.Vendor_Site_Id = Pvs.Vendor_Site_Id and rownum=1) ) " Title",
    (SELECT (Pvc.Area_Code||' '||Pvc.Phone) FROM po_vendor_contacts pvc
    WHERE 1=1 AND Pvs.Vendor_Site_Id=Pvc.Vendor_Site_Id
    AND pvc.last_update_date = (SELECT MAX(p.last_update_date) FROM po_vendor_contacts p
    WHERE p.Vendor_Site_Id = Pvs.Vendor_Site_Id and rownum=1 ) ) "Telephone",
    NULL AS "EQRS Comments",
    PVS.ADDRESS_LINE1 AS "Address",
    PVS.CITY AS "CITY",
    PVS.STATE AS "STATE",
    Pvs.Zip AS "ZIP",
    FTV.TERRITORY_SHORT_NAME AS "Country",
    Pvs.Email_Address AS "Email_Address",
    (Pvs.Area_Code||' '||Pvs.Phone) AS "EQRS Phone",
    (Pvs.Fax_Area_Code||' '||Pvs.Fax) AS "EQRS FAX",
    NULL Interface_Attribute6,
    NULL Interface_Attribute7,
    NULL Interface_Attribute8,
    pvs.vendor_site_code AS interface_attribute9,
    NULL interface_attribute10,
    pvs.vendor_site_id
    FROM PO_VENDORS PV,
    Po_Vendor_Sites_All Pvs,
    FND_TERRITORIES_VL FTV
    WHERE Pv.Vendor_Id=Pvs.Vendor_Id
    AND pvs.country=ftv.territory_code;
    supp_info supp_array;
    BEGIN
    OPEN supp_details;
    EXECUTE IMMEDIATE 'TRUNCATE TABLE xxmks_eqrs_supplier_hold';
    LOOP
    FETCH supp_details BULK COLLECT INTO SUPP_INFO;
    FORALL supp_details IN 1 .. supp_info.COUNT
    INSERT INTO xxmks_eqrs_supplier_hold VALUES supp_info(supp_details);
    EXIT WHEN supp_details%NOTFOUND;
    END LOOP;
    CLOSE supp_details;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    FND_FILE.PUT_LINE(FND_FILE.LOG,'ERROR OCCURED DURING EXECUTION'||SQLERRM);
    retcode:=2;
    END XXMKSUPP;

Maybe you are looking for