ORA-01427 single row subquery return several rows.
It's my request. Something wrong with this request... ?UPDATE OT_QUOT_COMP_MRN MNR
SET THE MNR. LINKS_1 = (SELECT IN. LINKS TO MNR, OT_QUOT_COMP_PO PO OT_QUOT_COMP_MRN WHERE MRN.) LINKS IS IN.. VOUCHER_NO
AND IN. LINKS LIKE 'QTN %' AND THE MNR. LINKS_1 NOT LIKE '% QTN %')
WHERE EXISTS (SELECT IN. LINKS TO OT_QUOT_COMP_PO IN. WHERE MNR.) LINKS = IN. VOUCHER_NO AND IN. LINKS LIKE 'QTN %' AND THE MNR. LINKS_1 NOT LIKE '% QTN %')
Thank you and best regards!
Deva
Perhaps update a join
update (select mrn.links_1 x_links_1,po.links y_links
from ot_quot-comp_po po,
ot_quot_comp_mrn mrn
where po.voucher_no = mrn.links
and instr(po.links,'QTN') > 0
and instr(mrn.links_1,'QTN') = 0
)
set x_links_1 = y_links
Tags: Database
Similar Questions
-
01427 00000 - "einreihig subquery returns several lines.
Hi all
How can I solve it
This code gives me this errorSELECT 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
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
-
single-line subquery returns moret one line han
UPDATE T74
SET LORRYOWNERNAME = 'BELLA. "
OWNERFATHERNAME = "GHANIMIYA"
AND
(SELECT T74 INVOICEDATE, T74A WHERE T74.) REFERENCENO = T74A. REFERENCENO AND T74. "LORRYNO ="KA05AA4916"AND INVOICEDATE > = February 25, 2011")= February 25, 2011 "
my inner query returns 5 rows ihave to update only the data that are greater than 25 February 2011"
not below when I use > = any it updates all rows, if I removed everything he is in error:
single-line subquery returns moret one line han
could you please correct the query
Published by: 848525 on Sep 7, 2011 12:18 AMTry
UPDATE T74 SET LORRYOWNERNAME='BASHA', OWNERFATHERNAME='GHANIMIYA', PANNO='AGNPD4113G' WHERE LORRYNO='KA05AA4916' AND exists (SELECT INVOICEDATE FROM T74A WHERE T74.REFERENCENO=T74A.REFERENCENO AND INVOICEDATE>='25-FEB-2011')
do not duplicate the post please
Published by: Alexandr Sep 6, 2011 23:52
-
ORA-01427 during the attempt to INSERT SQL job
Hello
I have non-logiques problem.
I use Oracle 10 g.
I have a query that contains some subqueries, this is pretty normal query as similar milion:
SELECT a.field1,
(SELECT b.field2 FROM tab2 b WHERE b.key = a.key) Field2
OF tab1 a
Query works fine, amount of the returns expected Recordset, but while I'm saving it somehow it returns me an error:
ORA - 01427:single - line subquery returns multiple rows
It would be normal that I have by running a SELECT statement. But SOME major work - error occurs when I try to save the results somehow - INSERT, CREATE TABLE AS or save it to file.
Help, please.
Thank you.nodeX wrote:
Query works fine, amount of the returns expected Recordset, but while I'm saving it somehow it returns me an error:
ORA - 01427:single - line subquery returns multiple rowsNo it's not. Most likely you use SQL * Developer, Toad, SQL * Navigator or another GUI tool that retrieves the screen by screen lines. So when you run this select your tool retrieves and displays just the first screen and it happens so that for the first lines of the scalar subquery in your select screen returns just one line. However, when you issue INSERT SELECT all lines are read, and at least one of them, results in a scalar subquery returns more than one line. Do a complete test of your question, SELECT, SELECT your tool try and extract all lines (in most of the tools it's > button) or post your query in SQL * more. In all cases:
SELECT a.field1, (SELECT b.field2 FROM tab2 b WHERE b.key = a.key) field2 FROM tab1 a
means the key of the column in the table tab2 is logically unique for any value of tab1.key.
SY.
-
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;
-
Update query does not work (ora-01427)
RDBMS 10 g 2
Long story short, I created a column in a table in another table, that it has been moved is not really necessary that all other information is stored in other tables. With the original column has values that need to be copied to the new column before the old table is deleted.
I use this update query:
If I run the select statement separately, I get the exact results that I need however, every time I run the whole statement, I get:update bi_req bir set bir.job_name = (select distinct bij.job_name from bi_jobs bij, bi_freq bif, bi_apps bia, bi_req bir where bij.fk_bi_req_id = bir.pk_bi_req_id and bia.pk_bi_apps_id = bij.fk_bi_apps_id and bif.pk_bi_freq_id = bij.fk_bi_freq_id) where bir.job_name is null;
Error: ORA-01427: single-row subquery returns more than one row
The problem is that your subquery returns two or more names different jobs for a line of update.
Which of these task names are you using? If it is not serious, then you can go with a like this aggregate query
update bi_req bir set bir.job_name = (select max(bij.job_name) /* use just one job name */ from bi_jobs bij, bi_freq bif, bi_apps bia where bij.fk_bi_req_id = bir.pk_bi_req_id and bia.pk_bi_apps_id = bij.fk_bi_apps_id and bif.pk_bi_freq_id = bij.fk_bi_freq_id) where bir.job_name is null;
What I don't understand is why you need the bi_freq and bi_apps in the subquery. A simple query as follows: should not be enough?
update bi_req bir set bir.job_name = (select max(bij.job_name) /* use just one job name */ from bi_jobs bij where bij.fk_bi_req_id = bir.pk_bi_req_id) where bir.job_name is null;
Published by: W. Sven on September 4, 2009 14:06
-
updated - einreihig subquery returns multiple rows
I'm trying to update the values in a column in a table to match the value in a table of validation/look-up. Why do I get an error with this sql?
UPDATE TABLE_A
SET field_x = (SELECT field_x
OF TABLE_B, TABLE_A
WHERE TABLE_A.field_Y = TABLE_A.field_Y)
WHERE THERE ARE
(SELECT field_x
OF TABLE_B, TABLE_A
WHERE TABLE_A.field_Y = TABLE_A.field_Y)
I get the error "einreihig subquery returns several lines.
I can run the subquery only without any problem.
ideas?Hello
You get this error becauseYour request
SELECT field_x FROM TABLE_B, TABLE_A WHERE TABLE_A.field_Y = TABLE_A.field_Y
Returns a value greater than 1 for field_x.
You may wan to check your data.Now, it depends entirely on your data if the following query will work ok or not?
Try thisUPDATE TABLE_A SET field_x = (SELECT field_x FROM TABLE_B WHERE TABLE_A.field_Y = TABLE_A.field_Y) WHERE EXISTS (SELECT field_x FROM TABLE_B WHERE TABLE_A.field_Y = TABLE_A.field_Y)
Kind regards
BobinPublished by: Buga added second query
-
Update TBL to TBL (ORA-01427 ' row subquery returned more line ")
Hello...
I'm new in this stuff and need a little help... Thank you very much for your answers!
I have the error ORA-01427 when run this script:
Update tblproduct
the value (instock) = (select b2.instock - tblproduct b2, b1, b3 tblorder tblitem b1.quantity
where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid to 3025)
The main purpose of the script is the actualization of the butts of the inventory when the order is completed.
The TBLITEM primary key (ORDERID and PRODUCTID). This prevents repeat the question on the agenda.
The structure of tables are:
1. (TBLITEM)
Name Null? Type
---------------------------------- -------------- ---------------
PRODUCTID NOT NULL NUMBER (10)
ORDERID NOT NULL NUMBER (10)
QUANTITY NOT NULL NUMBER (10)
PRICE FLOAT (126)
ITEMID NUMBER (5)
2. (TBLPRODUCT)
Name Null? Type
----------------------------------------- --------------- --------------------
PRODUCTID NOT NULL NUMBER (10)
PRODNAME NOT NULL VARCHAR2 (25)
DESCRIPTION VARCHAR2 (255)
PRICE NOT NULL NUMBER (7.2)
NUMBER (7.2) TAX
STATUS NOT NULL VARCHAR2 (25)
NUMBER (10) NOT NULL INSTOCK
REORDERPOINT NOT NULL NUMBER (10)
DATE OF RESTOCKDATE
CATEGORYID NOT NULL NUMBER (10)
VENDOR NUMBER NO. (10)
2. (TBLORDER)
Name Null? Type
----------------------------------------- ------------ ----------------
ORDERID NOT NULL NUMBER (10)
NOT NULL ORDERDATE DATE
DATE OF ORDERCOMPT
USERID NOT NULL NUMBER (10)
ACCOUNTID NOT NULL NUMBER (10)
STATUS NOT NULL VARCHAR2 (25)
NUMBER (2) CANCELLED
THANKS FOR YOUR HELP ONCE AGAIN!
Published by: user10084733 on April 20, 2009 12:25It is the right way to update your table.
update tblproduct b2 set (instock) = (select b2.instock - b1.quantity from tblitem b1, tblorder b3 where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid in 3025) where exists ( select 1 from tblitem b1, tblorder b3 where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid in 3025) ; Without the where condition you are updating the full table.
-
"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_IDUse
' 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
-
Help in the treatment of "subquery returns multiple rows.
Appreciate your help on this.
I have under sql query fails with the error "ORA-01427: einreihig subquery returns multiple lines"
WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT distinct col2 FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 WhenI checked the count using below query WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT count(col2) FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 (+) it shows as below ----------------- COL1 RND_COL A 2 A 2 D 1 E 0 My Requirement is for all the values in the column 'RND_COL' > 1 it should display text as 'Multiple', for 'RND_COL' = 1 display actual value returned by sub query and 'RND_COL' = 0 display it as NULL. expected output ------------------- COL1 RND_COL A Multiple A Multiple D E E NULL
Hello
Here's another way. It's like the solution in response #1, but it does not use a subquery:
SELECT t.col1
CASE
WHEN COUNT (DISTINCT t2.col2) > 1
THEN "Multiple."
For ANOTHER MIN (t2.col2)
END AS rnd_col
T
LEFT OUTER JOIN t2 ON t2.col1 = t.col1
GROUP OF t.col1, t.col2, t.col3
ORDER BY t.col1
;
This assumes that in table t (col1, col2, col3) combination is unique. If theat is not the case, change the GROUP BY clause, but you need to ensure that all lines of t becomes a separate group.
-
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_custI 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.
-
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... error
Hi friends,
How can I change my program to avoid any «single-line subquery»
Thanks in advanceUPDATE AR.HZ_CONTACT_POINTS B SET B.PHONE_COUNTRY_CODE = (SELECT D.PHONE_COUNTRY_CODE FROM CAX.CAX_CUSTOMERS_ALL A, AR.HZ_CONTACT_POINTS X, AR.HZ_PARTY_SITES C, AR.HZ_PHONE_COUNTRY_CODES D, CAX.HZ_LOCATIONS_V E WHERE ( A.ORG_ID=111 AND X.OWNER_TABLE_NAME='HZ_PARTY_SITES' AND X.PHONE_NUMBER IS NOT NULL) AND ( (C.LOCATION_ID=E.LOCATION_ID) AND (X.OWNER_TABLE_ID=C.PARTY_ID) AND (E.COUNTRY=D.TERRITORY_CODE) AND (X.OWNER_TABLE_ID=A.CUSTOMER_ID) AND (B.PHONE_NUMBER=X.PHONE_NUMBER) ) ) WHERE B.OWNER_TABLE_NAME='HZ_PARTY_SITES' AND B.PHONE_NUMBER IS NOT NULL;
Maybe you want to exclude ambiguous lines - so you could do smth like
UPDATE ar.hz_contact_points b SET b.phone_country_code = (SELECT d.phone_country_code FROM cax.cax_customers_all a, ar.hz_contact_points x, ar.hz_party_sites c, ar.hz_phone_country_codes d, cax.hz_locations_v e WHERE ( a.org_id = 111 AND x.owner_table_name = 'HZ_PARTY_SITES' AND x.phone_number IS NOT NULL) AND ( (c.location_id = e.location_id) AND (x.owner_table_id = c.party_id) AND (e.country = d.territory_code) AND (x.owner_table_id = a.customer_id) AND (b.phone_number = x.phone_number))) WHERE b.owner_table_name = 'HZ_PARTY_SITES' AND b.phone_number IS NOT NULL AND (SELECT COUNT (d.phone_country_code) FROM cax.cax_customers_all a, ar.hz_contact_points x, ar.hz_party_sites c, ar.hz_phone_country_codes d, cax.hz_locations_v e WHERE ( a.org_id = 111 AND x.owner_table_name = 'HZ_PARTY_SITES' AND x.phone_number IS NOT NULL) AND ( (c.location_id = e.location_id) AND (x.owner_table_id = c.party_id) AND (e.country = d.territory_code) AND (x.owner_table_id = a.customer_id) AND (b.phone_number = x.phone_number))) = 1
-
10g TRANSPOSE a single ROW/columns in ROWS/columns
Hello
I have a query that returns a single row with 4 columns
I need output in a single line by column
Here is a table of test;
the output current is;CREATE TABLE TEST ( SEQ VARCHAR2(10), FT DATE, CD DATE, DELTA NUMBER(10) ); INSERT INTO TEST (SEQ, FT, CD, DELTA) VALUES ('1111',SYSDATE-1,SYSDATE,1); SET NUM 999; SELECT SEQ, FT, CD, DELTA FROM TEST; DROP TABLE TEST;
and want;SEQ FT CD DELTA ---------- ------------------------- ------------------------- ---------------------- 1111 09-AUG-10 10-AUG-10 1
SEQ 1111 FT 09-AUG-10 CD 10-AUG-10 DELTA 1
SQL> ed Wrote file afiedt.buf 1 select regexp_substr(str,'[^,]+',1,level) 2 from 3 ( 4 SELECT SEQ||','|| FT||','||CD||','||DELTA str FROM TEST25 5 ) 6* connect by level <= length(str) - length(replace(str,','))+1 SQL> / REGEXP_SUBSTR(STR,'[^,]+',1,LEVEL) ----------------------------------------------------------------------- 1111 09-AUG-10 10-AUG-10 1
-
Aggregate XML columns in a single row in Oracle
Hello
I have a table named TMTABLE HT and it followed columns:
ID, NAME, TEXT
1 orders XML1
2 orders XML2
3 orders for XML3
where XML1, XML2 and XML3 follow:
XML1:
<? XML version = "1.0" encoding = "utf-8"? >
The <>rowsets
rowset <>
< row >
< Uom IN. = "" > < DB > 4500005146
< Uom of line = "" > 10 < / Line >
< / row >
< / lines >
< / sets of lines >
XML2:
<? XML version = "1.0" encoding = "utf-8"? >
The <>rowsets
rowset <>
< row >
< Uom IN. = "" > < DB > 4500005147
< Uom of line = "" > 10 < / Line >
< / row >
< / lines >
< / sets of lines >
XML3:
<? XML version = "1.0" encoding = "utf-8"? >
The <>rowsets
rowset <>
< row >
< Uom IN. = "" > < DB > 4500005148
< Uom of line = "" > 10 < / Line >
< / row >
< / lines >
< / sets of lines >
Now, I want to query Oracle get this XML1, XML2 and XML3 in a single row, in the following format:
<? XML version = "1.0" encoding = "utf-8"? >
rowset <>
< row >
< Uom IN. = "" > < DB > 4500005146
< Uom of line = "" > 10 < / Line >
< / row >
< row >
< Uom IN. = "" > < DB > 4500005147
< Uom of line = "" > 10 < / Line >
< / row >
< row >
< Uom IN. = "" > < DB > 4500005148
< Uom of line = "" > 10 < / Line >
< / row >
< / lines >
I tried various queries, but not able to do this. Can someone help me please how to do in this regard?Hello
Assuming that TEXT column of XMLType data type:
SQL> select xmlelement("Rowset", 2 xmlagg(x.column_value) 3 ) as result 4 from tmtable t 5 , xmltable('/Rowsets/Rowset/Row' passing t.text) x 6 ; RESULT --------------------------------------------------------------------------------
4500005146 10 4500005147 10 4500005148 10
Maybe you are looking for
-
29 Firefox: toolbar guard reset after reboot
Hello I use Firefox 29 since the first beta, and I did several customization menu. But if I take the 'Star + favorite' icon to the next restart I find in its default location (that is, before the menu button).Other items added to the toolbar disappea
-
How we prevent data lost on the relocation by recovery dvd
Dear Sir. I bought the computer laptop pavalion g6 1002tx At that time, I had win 7 OS. later another two months, I installed win 10. now I want to reinstall Win 7 again because I like more. I have the DVD of recovery also for win 7,. But the problem
-
Hello, today I opened safari as usual but it suddenly crushed and from then until now I can't open the app. It opens then the rainbow circle/cursor appears and after a few seconds, it crushes. What is the problem? It's a virus or a malware? (I am cur
-
Hi there... I just came back to the world of AS400, I'm really lost in the coding :-( I saw eval of coding RPG... I wonder what that means? FieldA to FieldB average MOVEMENT is? EVAL FieldB FieldB I tried to move QDATE in my field ch
-
File Explorer Windows open in a window separate from the App
Want to open my computer to a particular folder location. Simply needs to open separately for the user to browse the files. How to do this? Thank you.