Update Field1.Table1 based on a compound join between Table1 and Table2
HelloI want to run the update on Oracle 11 g, but it fails with the following error:
SQL error: ORA-01427: einreihig subquery returns multiple rows
01427 00000 - "einreihig subquery returns several lines.
Here's what I'm trying to do in pseudo-code:
Update Table1
Set Flag_Column = 1
Where
Table1.ColumnX = table2. ColumnX
and
Table1.ColumnY = table2. ColumunY
Is there a way to do this in SQL?
Try1 *.
Update Table1
Set Flag_Column = 1
where ColumnX =
select (separate Table1.ColumnX
from Table1, Table2
where Table1.ColumnX = Table2.ColumnX
and Table1.ColumnY = Table2.ColumnY)
and ColumnY =
select (separate Table1.ColumnY
from Table1, Table2
where Table1.ColumnX = Table2.ColumnX
and Table1.ColumnY = Table2.ColumnY)
Try2 *.
Update Table1
Set Flag_Column =
(select 1
from Table1, Table2
where Table1.ColumnX = Table2.ColumnX
and Table1.ColumnY = Table2.ColumnY)
Any help is appreciated
Published by: 977424 on March 8, 2013 12:13
Hello
Maybe:
UPDATE table1 t1
SET flag_column = 1
WHERE EXISTS (
SELECT 1
FROM table2
WHERE columnX = t1.columnX
AND columnY = t1.columnY
)
;
Depending on your needs, the MERGER could be better than the UPDATE.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
See the FAQ forum {message identifier: = 9360002}
Tags: Database
Similar Questions
-
Join between PAY_GRADE_RULES_F and BEN_CWB_PERSON_RATES
Hi Experts,
I'm working on the module of work remuneration and creating custom ETL based on some sources eBS bench.
Can anyone let me know the joins between the tables: PAY_GRADE_RULES_F and BEN_CWB_PERSON_RATES?
Thank you
AnamikaHi med.
I would start here; http://ETRM.Oracle.com
Good luck
Daan Bakboord
http://obibb.WordPress.com -
Join between mtl_material_transactions and po_lines_all pla
Hey there! I hope you can help me.
I do a query to join po_headers_all, po_lines_all, mtl_transaction_accounts and mtl_material_transactios.
But, when I add the table po_lines_all he make me a cross with mtl_material_transactions join.
I have a purchase order (i.e. 12015) with two lines and 2 receptions on the inventory.
the first movement has been Po 12015 had a single line, and we had the reception on the inventory.
later, to a new stage, we add an additional line to 12015 IN. and then we did the respective reception and for that PO, we two receptions, but when I join po_lines_all it to me 2 receptions through 2 and the result is 4 rows.
I don't know what I'm doing wrong, if you can help me, that will be appreciated.
This is my query:
SELECT poh.revision_num, mmt.transaction_id, mmt.transaction_quantity cantidad_recepcion, mmt.organization_id, MSI.PRIMARY_UOM_CODE uom_recepcion, DECODE ( MMT.TRANSACTION_TYPE_ID, 24, NULL, 80, NULL, DECODE ( MTA.PRIMARY_QUANTITY, 0, NULL, NULL, NULL, DECODE (MTA.ACCOUNTING_LINE_TYPE, 1, MTA.BASE_TRANSACTION_VALUE / MTA.PRIMARY_QUANTITY, 14, MTA.BASE_TRANSACTION_VALUE / MTA.PRIMARY_QUANTITY, 3, MTA.BASE_TRANSACTION_VALUE / MTA.PRIMARY_QUANTITY, ABS (MTA.BASE_TRANSACTION_VALUE / MTA.PRIMARY_QUANTITY)))) unit_price_recepcion, mmt.inventory_item_id, mmt.transaction_source_id, poh.po_header_id, poh.segment1, pol.item_id, pol.UNIT_MEAS_LOOKUP_CODE uom_OC, (SELECT uom_code FROM mtl_uom_conversions WHERE 1 = 1 AND inventory_item_id = 0 AND NVL (disable_date, SYSDATE) >= SYSDATE AND unit_of_measure = pol.UNIT_MEAS_LOOKUP_CODE) UOM_CODE_OC, pol.unit_price unit_price_OC, pol.quantity cantidad_OC FROM mtl_transaction_accounts mta, MTL_SYSTEM_ITEMS_VL MSI, mtl_material_transactions mmt, po_headers_all poh, po_lines_all pol WHERE 1 = 1 AND mta.transaction_id = mmt.transaction_id AND MSI.INVENTORY_ITEM_ID = MMT.INVENTORY_ITEM_ID AND MSI.ORGANIZATION_ID = MMT.ORGANIZATION_ID AND poh.po_header_id = pol.po_header_id AND poh.po_header_id = mmt.transaction_source_id AND mmt.INVENTORY_ITEM_ID = pol.ITEM_ID AND mta.inventory_item_id = mmt.inventory_item_id AND mmt.transaction_source_id = 3502169 AND mta.accounting_line_type = 5;
The line 'AND mta.accounting_line_type = 5 " line is because I only want the type"Enter". .
Thank you very much.
It can be related through RCV_TRANSACTIONS, who can be reached at PO_LINES_ALL.
RCV_TRANSACTIONS PO_LINES_ALL RCV_TRANSACTIONS.PO_LINE_ID RCV_TRANSACTIONS PO_LINE_LOCATIONS_ALL RCV_TRANSACTIONS.PO_LINE_LOCATION_ID
-
update of column based on the sum of the data from another table
I have two tables:
Table1 (col1, col2, col3, col4, val1, status) Table2 (col1, col2, col3, col4, val2)
For Table1 and Table2, column (col1, col2, col3, col4) are the primary key of composit.
Table2 could have duplicated lines, that's why I want to group by (col1, col2, col3, col4) and sum (val2)
After that, I want to update Table1.val1 with the value of sum (Table1.val2) where Table1.col1 = Table2.col1 and Table1.col2 = Table2.col2 and Table1.col3 = Table2.col3 and Table1.col4 = Table2.col4 and status = 'V '.
I did something like this:
UPDATE Table1 SET val1 = (
WHERE Table1.col1 = t_sommevbrute.col1 and Table1.col2 = t_sommevbrute.col2 and Table1.col3 = t_sommevbrute.col3 and Table1.col4 = t_sommevbrute.col4)
Could someone help me please? Thank you
merge into table1 t1
using (select col1, col2, col3, col4, sum (val2) val2
from table2
Group
by col1, col2, col3, col4) t2
on (t1.col1 = t2.col1 t1.col2 = t2.col2 and t1.col3 = t2.col3 and t1.col4 = t2.col4 and)
When matched then
update set t1.val1 = t2.val2;
-
Compare multiple columns and update a column based on the comparison
Hi all
I have to update the column STATUS of the slot structure of the table.
Status should be 'P' if all the columns count are equal on the other should be "F".
The value of the column can be "NA'. If the value is NA, then avoid this comparison column; compare only other 3 columns.
My output should look like below.
State of cnt1, cnt2 cnt3 ID cnt4
1 4 4 4 4 P
2 4 5 4 4 F
3 4 4 NA 4 P
NA 4 4 3 4
I tried with the statemnt with BOX WHEN conditions and DECODE UPDATE, but could not succeed, can someone please help
To do this, if you use my statement in response #11 box (Re: Re: comparison of multi-column and update a column based on the comparison of)
-
In the form of table-update of rows based on the selection of the checkbox
Hi all
I have a tabular layout with line selector. I need to update manually checked columns, how would write a process audited records updated?
Something like this:
Thank you very much.BEGIN FOR i in 1..apex_application.g_f01.count LOOP IF apex_application.g_f01(i) is not null THEN UPDATE TEST_USERS set USER_ID = :P14_TO WHERE rowid = :APEX$ROW_ID; COMMIT; END IF; END LOOP; END;
You can refer to the line that you want to process through the value stored in the box.
If you use apex_application.g_f01 (i) to make reference to the line and you want to update the row based on the ROWID in your request, your SQL query should have the box as follows:
apex_item. CheckBox2 (1, rowid)
Then your PLSQL process would be like this:
BEGIN FOR i in 1..apex_application.g_f01.count LOOP IF apex_application.g_f01(i) is not null THEN UPDATE TEST_USERS set USER_ID = :P14_TO WHERE rowid = APEX_APPLICATION.G_F01(i); COMMIT; END IF; END LOOP; END;
I hope this helps.
Cheers, Pete
-
Under certain conditions, update a table based on the comparison with a SQL statement
I have a table (table 1) that has 4 columns:
UID. THE NEST | VALUE1 | VALUE2
I have another statement SQL (STMT) that returns the 3 columns of a few other tables:
UID. THE NEST | VALUE1
Now this is the condition of the way in which I want to put up-to-date TABLE1:
First, to compare a pair of UID and PID of STMT with those in TABLE1,
-1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).
2, for an existing UID and PID pair in STMT and TABLE1, do:
a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1
b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.
I can't seem to come with a solution for condition 2. Any help is appreciated!Hello
Here's one way:
MERGE INTO table1 dst USING ( SELECT ... -- your stmt query goes here ) src ON ( src.uid = dst.uid AND src.pid = dst.pid ) WHEN MATCHED THEN UPDATE SET dst.value1 = CASE WHEN dst.value2 > 0 OR ( dst.value2 = 0 AND dst.calue1 != src.value1 ) THEN src.value1 END WHERE dst.value2 > 0 OR ( dst.value2 = 0 AND dst.calue1 != src.value1 ) ;
This assumes that the combination (uid, pid) is unique in stmt. It doesn't have to be unique in table1.
sb92075 wrote:
-1, for any new pair UID and PID not in TABLE1, insert a new line of STMT in TABLE1 set TABLE1. Value2 = 0 (I already did this).
FUSION could also do parts 1 and 2 together, in the same statement.
2, for an existing UID and PID pair in STMT and TABLE1, do:
a. in TABLE1. Value2 > 0, update TABLE1. VALUE1 = STMT. VALUE1
b. to TABLE1. Value2 = 0 and if TABLE1. VALUE1! = STMT. Value1, update of TABLE1. VALUE1 = STMT. Value1, otherwise nothing to do.
Why are they not simply your needs ' uid and pid that already exist in stmt and table1, if table1.value2 > = 0, then the value table1.value1 = stmt.value1 "? Are you concerned about shooting triggers unnecessarily? It has something to do with null values? The MERGE statement above does exactly what you asked, but, depending on your needs, something simpler and more efficient could do it as well.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002}Published by: Frank Kulash, June 6, 2012 14:51
-
In the form of table-update a column based on the other
Greetings,
I want to update a column based on the value of another column in a tabular presentation. What should I use? Calculation or validation process?
-VatsaYes, get rid of the update of "pims_component" - this is the cause of the error table mutation - and simply set
: new.state_ind: = Ls_state;
CITY
-
just joined net flix and I have a TV 32 inches use as my moniter I can't go louder sound
Help
I just joined net flix and I have a tv 32 inches using as my moniter I can't sound further strong net flix, I called and they told me unistall mircosoft Ribbon of light
then the reinstall but still no change is there something I can do to my computer to go stronger and another thing I can't find flix net in my programs when I want
to watch a movie that I have to go to the web address, I'm not very smart when it comes to computers I use mainly to [play games on the Trombinoscope please help me
Hello
I suggest trying to update the latest drivers for the sound card and check if it helps:
http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly
It will be useful.
-
Hi gurus,
I have a fact table that contains several fields of candidate that can be attached to a lookup table
2 folders
fact_table
lookup_table1
2 joins are possible between two folders
fact_table.code_combination_id-> lookup_table1.code_combination_id
fact_table.accrual_code_combination_id-> lookup_table1.code_combination_id
When I try to create a new workbook and include the fields of the fact table, and then include the fields of the table of correspondence he asks me to choose the join.
If I then want to add fields based on the second join, it do not ask me what join to use in the future. He seems to assume that the first join is always between two records for the report. I know that I can create another folder using the same table and move one of the existing joints of the current folder to the new folder. Am I missing something or is this the only way to go?
Kind regards
JohnHi John,.
Interesting question. This is how we solved in my last job.
Created files:
Fact table: AR's
Search folder: combination of Code search
Search folder: search for combination of Code of accumulationThen join AR made in each search folder. Generally, point the search folder on the AR folder in creating joins. Discoverer, prefer this direction. As a combination of additional code types are referenced, add additional code combination files. All of these files come from the same table. The only thing that is different is the column joined actually AR.
So, in the end, your knuckles would be:
Code combination Lookup.code_combination_id-> AR Fact.code_combination_id
Accrual Code combination Lookup.code_combination_id-> AR Fact.accrual_code_combination_idI hope this helps.
Kind regards
Nancy -
Hallo why? When I update ios. When the image has finished error itunes and usb
Hallo why? When I update ios. When the image has finished error itunes and usb
Connect the iPhone to the computer that you are synchronizing usually with
and follow the prompts to iTunes on this computer. If you
do not generally in sync with a computer, you should always use
iTunes on a computer to complete the update.
-
After the last update of firefox toolbar at the top of the screen and the taskbar at the bottom of the screen no longer appear. How can I get back them?
Wingfield said
After the last update of firefox toolbar at the top of the screen and the taskbar at the bottom of the screen no longer appear. How can I get back them?
I solved this problem by clicking the 3 horizontal bars (open the Menu) at the top right of the screen, then clicking on "Menu bar" in the options presented. All of a sudden my bar of task and the toolbar appears on the screen and remained.
-
Since the last update to FF, I can't log out of Yahoo and when I close FF it tells me it crashed.
When I try logging out of Yahoo, it comes up with:
The secure connection failedAn error occurred during a connection to login.yahoo.com. You have received an invalid certificate. Please contact the server administrator or email correspondent and give them the following information: your certificate contains the same serial number for another certificate issued by the certification authority. Please get a new certificate containing a unique serial number. (Error code: sec_error_reused_issuer_and_serial)
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified. Please contact the web site owners to inform them of this problem.
I have run CCleaner and erased cookies. Uninstalled and reinstalled FF to no availe.
When I close FF one box comes telling me it crashed.
I can log out of Yahoo in Internet Explorer.
the advantage of this feature to scan https is at least questionable. in order to make it work, avast has sort of a man-in-the-middle 'attack' in order to access the contents of the encrypted connection (firefox supports a feature called pinning of key which can be used by Web sites to address these MITM attacks and who also seems to pick up interference from AVAST).
When you download files via a https connection, they will be analysed by the AV software once they land on your hard drive in any case. However, it should be the job of the Navigator to make it impossible to get infected by malicious software trying to surf around...Edit: Please try to restart the browser once again, it may take a new session for the change to take effect.
-
Since a recent issue of app updates on my iPad a applications - Gummy Drop mini disappeared and there seems to be no update in my update of the applications list or I can delete. I tried a reset nothing helps. What can I do? Thank you very much. Steve.
Not quite sure what "disappeared" means. You can try to remove and re - download.
-
Now that I've updated to El Capitan, my Brother DCP will not work and I can't find a driver update. Everyone finds something?
Here are the current models of Brother products which are supported.
http://support.brother.com/g/s/ID/OS/Macintosh.html
If your model is supported drivers will be on this page. Otherwise, contact the manufacturer and see if they have a driver for your printer from specific model for this OS. Otherwise, you may need to downgrade to a previous operating system from a backup Time Machine or a downgrade for compatibility, if it is not offered by the brother of your device to model on a computer running OS 10.11.
Apparently not all printers DCP mind are compatible, but most that were compatible with the OS 10.10.x always conform to their page.
Maybe you are looking for
-
can not put cookies and exceptions on the same screen. Need to fix this.
Went to the options today and the format has changed. Now I can't put Cookies and Exceptions on the same page at the same time. It is vital that I can put together up to manage cookies. Please fix this. Anyone have any ideas?
-
Satellite S2800-500: upgrade CPU and RAM
Anyone know if I can update the chip - currently a PIII 800 and also memory which is 128?I live in England.
-
Old VI does not run in 8.5
Hi all One of my friends is relatively new by using LabVIEW. He is currently working for a company that has just improved their lisence from 6.0 to 8.5. However, because of the upgrade its VI measure no longer exists. I offered to help him, but I'm a
-
Can someone tell me how to get rid of internal 2908 error? __
I get an internal error: 2908 when you try to install a software of hunting. I searched google and microsoft sites to get answers and tried a lot of things listed in the forums and technical support from microsoft, but to enjoy. I also tried insall
-
I try to install java s.-e. 8 64 bit on my 64-bit windows operating system 8. I confirmed that I'm under 64-bit windows. Even before the start of the installation, I get the error code 1632. I ran into this error code above all when trying to install