update multiple columns in table B of table based on the corresponding pass.
HelloWill have two tables as below,
create table billing_info
(MS number,
RT_ID number,
BILL_NO number)
create table mu
(MS number,
RT_ID number,
BILL_NO number)
insert into billing_info (MS,RT_ID,BILL_NO) values (1,99,635);
insert into billing_info (MS,RT_ID,BILL_NO) values (2,99,635);
insert into billing_info (MS,RT_ID,BILL_NO) values (3,999,1635);
insert into billing_info (MS,RT_ID,BILL_NO) values (4,599,7635);
insert into mu(MS) values (1);
insert into mu(MS) values (2);
insert into mu(MS) values (3);
insert into mu(MS) values (4);
Here the table mu got nullability for columns RT_ID, BILL_NO. I need to update this coulmns in the mu of table with the RT_ID, BILL_NO of billing_info of table corresponding to the value of MS.How to on this subject.
I tried the follwing examples
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:43440209618042
and
http://decipherinfosys.WordPress.com/2007/01/31/update-data-in-one-table-with-data-from-another-table/
but without hope...
It throws errors like ora-01779...
UPDATE mu
SET rt_id = (
SELECT rt_id
FROM billing_info
WHERE billing_info.ms = mu.ms )
WHERE EXISTS (
SELECT 1
FROM billing_info
WHERE billing_info.ms = mu.ms )
updates all lines of MU with the RT_ID of the line in BILLING_INFO where there is a MS value assuming that such a line exists in BILLING_INFO. This assumes that MU is unique in both tables. If there are duplicates, you will need to explain how to know which line of BILLING_INFO corresponds to a particular line of MU.
Of course, from the point of view of standardization, two tables with the same key and the same nonkey column should be extremely unusual.
Justin
Tags: Database
Similar Questions
-
Update multiple columns from multiple tables in a single UPDATE request
Hello
I'm trying to figure if I'm heading in the right direction.
I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.
Scenario 1
UPDATE Table2, Table 3 SET T2.Column1 = T1.Column1 ,T2.Column2 = T1.Column2 ,T3.Column2 = T1.Column2 FROM Table1 T1, Table2 T2, Table3 T3 WHERE T1.id = T2.id and T1.id = T3.id
Scenario 2
UPDATE Table3 SET T3.Column1 = T1.Column1 T3.Column2 = T1.Column2 ,T3.Column3 = T2.Column3 ,T3.Column4 = T2.Column4 FROM Table1 T1, Table2 T2, Table3 T3 WHERE T3.id = T1.id and T3.id = T2.id
Hello
For scenario 1, you must write separate instructions UPDATE table2 and table3.
To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.
ENGAGE only when two tables have been changed.
You can write a procedure or an INSTEAD OF trigger to do all this.
For scenario 2, you can reference many tables that you need when new table3. It might be more efficient and simpler to use the MERGER rather than UPDATED. For example:
MERGE INTO table3 dst
WITH THE HELP OF)
SELECT t1.id
t1.column1
t1.column2
t2.column3
t2.column4
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id
) src
WE (dst.id = src_id
WHEN MATCHED THEN UPDATE
SET dst.column1 = src.column1
dst.column2 = src.column2,
dst.column3 = src.column3,
dst.column4 = src.column4,
;
-
How to update the password on the other table based on the mod
Hello
I need to update the password for the other table based on the mod.
I have two table 'user' and 'reset '.
User:
Username username password date_exp
s232322 Bobby John sdds4545df4r 10/12/2010
s454566 George Bill f444556gh76 07/14/2010
s343466 Bill Clinton fgf54tyujkkkhj 06/12/2011
.
.
.
Reset:
Series encrypt decrypt
fgf5656fg 0 Watellemon
1 dfggf5665 lime juice
dfdffd545 2 applesalad
3 54r4gggt airlines
construction of 4 hg44hh63
5 fgf4343yh security
.
.
.
How can I update the password of a table to another table "reset"?
Ex: query
Update user set password = (select Encrypt reset where mod (length (username), 10))
If mod (length (username), 10) is 0, it should take series "0" encrypt the password and update the password in the table "user".
If mod (length (username), 10) is 1, it should take serial '1' encrypt the password and update the password in the table "user".
If mod (length (username), 10) is 2, it should take series '2' encrypt the password and update the password in the table "user".
If mod (length (username), 10) is 3, it should take series '3' encrypt the password and update the password in the table "user".
If mod (length (username), 10) is 4, it should take series '4' encrypt the password and update the password in the table "user".
....
Please help me write an update query.
Thank you
NiharHi, Nihar,
You almost had it! You just need to correlate the subquery for the main UPDATE statement, like this:
UPDATE user_table u -- USER is a built-in function; it's not a good table name SET password = ( SELECT encrypt FROM reset -- RESET isn't a very good table name, either WHERE serial = MOD ( LENGTH (u.username) , 10 ) );
-
divide the table based on the number of lines
Hello
I am trying to split a table based on the number of lines and then treat.
Say I have a TEST_XXX table that contains 50 lines, what I would do is.
to access multiple lines of 10. How can we achieve this?
What I thought is, once the table is created and the line are filled.
Add a new column to the table and perform a procedure that inserts of 1 to 10 first lines
and 2 to 10 lines and 3 to 10 next ranks... etc. Based on this, that we can treat
the first set of lines then play next or etc...
is there a better way to do it?
Code to create the table:
Code to add lines:CREATE TABLE TEST_XXX ( A_ID VARCHAR2(10), B_ID NUMBER, c_ID VARCHAR2(10), D_ID NUMBER )
The original problem is, I have a huge table, and I write a sql query to process,DECLARE BEGIN FOR I IN 1..50 LOOP INSERT INTO TEST_XXX VALUES('ABCDE',123,'ZYXWV',321); END LOOP; COMMIT; END;
When I treat him by selecting all the values in the table, it is very slow.
But when I have treat small Coulon (say 100 rows), it works very well.
That's how I got the approach described above in mind.You can use NTILE.
See:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions101.htm#SQLRF00680
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:47910227585839 -
Is there an easy way to filter a 2D table based on the values in two fields?
Y at - it an easy way to filter a 2D table based on the values of one of the fields. In my attached VI the output array has the following format:
Ident Frame Type bytes TimeStamp data
10:57:07.621 3AD00016 POUVEZ 8 0000000000000000 data frame
10:57:07.622 3AD00017 CAN data frame 8 000005E000000000
10:57:07.624 3AD00018 POUVEZ 8 0000000003300000 data frame
10:57:07.625 2DC00000 POUVEZ 8 0000000000000000 data frame
10:57:07.626 3AD00019 POUVEZ 4 0000030000000000 data frame
I would like to delete all lines that do not have an "Ident" between the values of 3AD00000 and 3AD0001E. So for the data above the fourth row would be removed. The only way I can see to do this is to form a 1 d table. Is there a better approach?
Thank you.
Hi chuck72352,
After you've sorted your data, you can use the function InRange. Combined with a "search in 1 table D", you get the range you really want.
Mike
-
SQL script to insert values into a table based on the type of user
Hello
I have a requirement where I need to insert (username, groupname) in a table based on the user name.
We have two types of user accounts:
(1) user name, which starts with "DV" example: "DVPATM."
regular user 2) example: 'PATM '.
If the user name begins with "DV" under instruction insert should kick in
insert into < tablename > (username, groupname) VALUES (< username > ' < groupname1 >).
otherwise below insert statement should kick in
insert into < tablename > (username, groupname) VALUES (< username > ' < groupname2 >).
I need to use SQL or stored only procedure.
Please suggest
Thanks in advance
All things being constant, you could use decode/case just for groupname by examining the first character t the user name, for example
insert into
(username, groupname) VALUES ( , (substr ( , 1, 2) the case when "DV" then else end)); Fixed edit: value for OTHERS, as noted by Frank
-
insert into the table based on the difference in line (or using less)
Hello
Oracle Version: 11g
Operating system: Solaris 10.
I was wondering if it is possible to insert data in a table based on the operator 'less' Please?
We have a very large table in a database, we moved to a different database. The table is cleared by a line for a certain range of dates, and we wondered if it is possible to insert this line of data in the remote database using the difference of rank between the two tables.
Here's the query that we are running:
SELECT ID , TO_CHAR (creation_datetime, 'yyyy-mm-dd') from TABB10 where TO_CHAR (creation_datetime, 'yyyy-mm-dd')='2014-03-18' minus SELECT ID , TO_CHAR (creation_datetime, 'yyyy-mm-dd') from TABB10@TABB_LINK.APDB00 where TO_CHAR (creation_datetime, 'yyyy-mm-dd')='2014-03-18'
TO_CHAR (CR ID
---------------------- ----------
2.4111E + 17-18 / 03 / 2014
Any ideas please?
Thank you
If I don't get me wrong, you can insert as below
INSERT INTO REMOTE_TABLE@DBLINK
SELECT ID, TO_CHAR (creation_datetime, "yyyy-mm-dd")
of TABB10
where TO_CHAR (creation_datetime, 'yyyy-mm-dd') ='' 2014-03-18
less
SELECT ID, TO_CHAR (creation_datetime, "yyyy-mm-dd")
of TABB10@TABB_LINK. APDB00
where TO_CHAR (creation_datetime, 'yyyy-mm-dd') ='' 2014-03-18
Concerning
-
Select cursor for update: multiple columns of different tables
Hello
I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.
I have a code drafted as follows:
DECLARE
v_mydept1 TEST1. TYPE % DEPT_CD;
v_mydept2 TEST2. TYPE % DEPT_CD;
CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO v_mydept1, v_mydept2;
WHEN EXIT C1% NOTFOUND;
UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
END LOOP;
COMMIT;
END;
The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].
It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
I don't know what exactly is the problem when you want to update several columns of different tables.
Can someone help me on this?user12944938 wrote:
But it's more the notion of compensation and understanding.See the link below:
http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htmSee the section RESTRICTION in the link above.
Twinkle
-
How update the column in the table based on the value selected in apex4.1
Hi all
I have the following tables,
and it has the values as follows,leave_type table,it has the following fields, 1.emp_name, 2.sick 3.casual
leave_master table and it includes the following fieldsemp_name sick casual guru 10 10 mishra 10 10
I have the form based on the table "leave_master"1.emp_name, 2.leave_type 3.no_of_days
Here, the leave_type has the LOV which includes.
sick and casual.
When the form is filled out and clicked on the button submit,
I need to update the column leave_type in table leave_type,
for example,.
then I want to update the leave_type column,if emp_name:guru leave_type:sick no_of_days:3
sick sick = - no_of_days for the 'guru' of name
That is to say, ill = 10-3 = 7
then the leave_type of the table must be,
someone can such me what code or method I can use?emp_name sick casual guru 7 10 mishra 10 10
Thank you.
Published by: Gurujothi on May 24, 2012 21:54
Published by: Gurujothi on May 24, 2012 21:54Try something like this...
BEGIN
IF: PXX_LEAVE_TYPE = "Sick" THEN
UPDATE LEAVE_TYPE
THE PATIENT VALUE = SICK -: PXX_NO_OF_DAYS
WHERE EMP_NAME =: PXX_EMP_NAME;
ON THE OTHER
UPDATE LEAVE_TYPE
DEFINE CASUAL = CASUAL -: PXX_NO_OF_DAYS
WHERE EMP_NAME =: PXX_EMP_NAME;
END IF;
COMMIT;
END; -
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
-
UPDATE multiple columns with conditional parameters
I have a procedure that updates several columns of a table using the parameter of the procedure. Is it possible to have a update unique with the parameter SET conditional statement?
Is it possible to replace several IFs code to have only one UPDATE statement with the condition that update the column only if the parameter passed is not null? In the real world scenario, I have more than 3 columns and I do not want to write lots of IF blocks.CREATE TABLE TEMP (POL_NUM NUMBER, OED DATE, TERM NUMBER, TRANS_CD CHAR(2)); INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB'); INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL'); INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN'); COMMIT; CREATE OR REPLACE PROCEDURE TMP_PROC ( pPOL_NUM NUMBER, pOED IN DATE, pTERM IN NUMBER, pTRANS_CD CHAR2) AS BEGIN IF pOED IS NOT NULL THEN UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM; END IF; IF pTERM IS NOT NULL THEN UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM; END IF; IF pTRAN_CD IS NOT NULL THEN UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM; END IF; COMMIT; EXCEPTION WHEN OTHERS THEN NULL; END;
Please help gurus!
Published by: Kuul13 on September 18, 2009 13:26Hello
Maybe this,.
Create OR Replace Procedure TMP_PROC( pPOL_NUM IN Number , pOED IN Date , pTERM IN Number , pTRANS_CD IN Varchar2 ) As Begin UPDATE TEMP SET OED = NVL(POED , OED ) , TERM = NVL(PTERM , TERM ) , TRANS_CD = NVL(PTRANS_CD, TRANS_CD ) WHERE POL_NUM = PPOL_NUM; Commit; Exception When Others Then Null; End;
Kind regards
Christian Balz -
Deactivation of the column in a table based on the setting in the search box
Hi all
I use Oracle Apex 4.1. I have two region
1. search box
2. in the form of a table
In the search box, I have a LOV field where the user can select the value. Based on this LOV in the search box, tabular column f06 must disable or read-only.
For example if I select THREE in LOV then only column f06 is expected on the other it must disable. How to get there.
Thanks in advance
Ravi
Hi Bobo,
Hope link below will solve your query.
Disable the column in a table.
BR,
Patrick
-
Selectively hiding a row in a Table based on the value of the column
I have a data control that is populated from pro-grammatically, based on the user's selection in the page one of wanting to hide some lines on page 2 at the same time, I don't want to delete the value binding, is there to hide the lines instead of column?To the table of the ADF, to hide the lines according to the requirement, use the visible property on each of the columns.
For example, if you do not want to display all the lines that have IDs Director like 200 or 201.
Thank you
Nini -
How to highlight the line of the ADF table based on the value of the column?
Hi all
I use jdev 10.1.3.4. I want to highlight a table row or a cell based on the value of the column.
Lets say, I have a table emp with column empid, empname and sal. I want to emphasize the lines that have sal = 10000.
How can I achieve this? Please help me with this.
Thank you
AbhijitHello
You want to highlight the lines? or set a different color for the lines? If it's the second, you can set the inline style based on the salary. (+ Edit: well, never mind, both are same :)) +)
Something like
If you want the entire line to be a different color, you have 2 options.
1. define the same style inline for all columns in the table (good if you want to do only for a single table).
2. create a style class and apply the styleclass based on the value of sal (preferably if you want the same behavior in all of your application).Arun-
Published by: joel Ramamoorthy, October 23, 2009 16:56
-
Problems updating multiple columns with a TO... SELECT subquery
Hello
This statement works very well:
UPDATE scott.dept
SET (deptno) = (WITH AS gaga
(SELECT 1
THE DOUBLE)
SELECT DeptNo
GAGA)
/
The second statement gives an error ORA-01767: UPDATE... GAME expression must be a subquery:
UPDATE scott.dept
SET (deptno, dname) = (WITH AS gaga
(SELECT 1,
'CHANGED '.
THE DOUBLE)
SELECT deptno,
DNAME
GAGA)
/
What's wrong? Is this a limitation of Oracle 9i?
Thank you
HeinzHello
It is not fair to Oracle 9; I get the same error in Oracle 11.
Use MERGE instead of UPDATE. (Sorry, I do not have Oracle 9, so I can't test that it works there, but WITH works MERGE in Oracle 10 and 11; no hide or workaround is necessary).If you want to use the UPDATE and you really need to use a WITH clause (and, of course, you don't have in this simple example), you can hide the WITH clause in a view in line, like this:
UPDATE scott.dept SET ( deptno, dname ) = ( SELECT * FROM ( WITH gaga AS ( SELECT 1, ... ) ... ) ) ;
Maybe you are looking for
-
HP Slimline 450 desktop computer - a60n: "prepare windows."
Hello I bought the HP Slimline Office 450 - a60n last month. He has often used to freezing. I downloaded Office 365, then Windows 10 and have a 3 TB Seagate drive and backup HD. When the PC has frozen it cannot close by the Task Manager and I had t
-
Once 9.2 iPhone is no longer recognized by car radio Pioneer
I have an iPhone 6 + to connect to a Pioneer DEH-80PRS. My phone is not recognized after update to IOS 9.2, & when I select usb for phone, it climbs to Pandora & play phone but I lose control through stereo and all the data on the time music or selec
-
Hello world I use a module in series or with cRIO 9870 9014. I have need to acquire analog data with the GPS data and lang + long for each data point. I am able to get to the host vi gps data, but I am confused about the acquisition rate. I was curio
-
How to create the generation that run on the device.
I created a simple application. Now, I want to test this feature and I want to just put the build in Sd Card. So how can I make the executable file for the device. that run in the BlackBerry device. Thanks in advance.
-
Aid to understanding drawPolygon()
I have a triangle I draw using drawPolygon(). That's what I have: public void paint(Graphics g) { int[] xPoints = { 30, 70, 40 }; int[] yPoints = { 30, 30, 60 }; Poly