Updating a Column in Table
Hi
We have a editable field in a table and we have to provide a button; on clicking of the button, the particular column of the table has to get updated based on the entered values. Please help me how to do this as i am new to this technology.
Also we need to populate one LOV coulmn of a table based on some other column values of the same. We are loading the 2 coulmns first say Name and Address Type. based on these parameters i need to load Address column which is messageChoice. Add Type can take only Ship To and Bill To. Kindly share ur knowledge.
If its a direct requirement like saving the table/column contents into the DB table, u can use the EO-VO BC4J to update the record. Its a straight forward method in OA. Refer dev guide for implementing this.
if u r talking about dependent poplist / LOV, refer old thread for the same.
- Senthil
Similar Messages
-
How can i update all column of table without know it's structure
hi to all
i want to make update to all columns of table with record type of this table
ex- consider the emp table and contain any number of columns
and you make record is row type of this table (emp) as emp_rec
and fech in it any record by select * from emp
and i want to update another record this the return record from data base as
update emp by using the emp_rec
i want to know how this will be acheiveIt is all written in the docs:
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#i20479
Although updating all columns for a table is VERY, VERY BAD practice.
Gints Plivna
http://www.gplivna.eu -
How to update 2 columns on table A with 2 cols in table B
Hi all,
I am confused when updating more that 1 cols from tableB to tableA.
Single column is easy as this:
update TableA set col1 = (select col1 from TableB where ssno=100)
where ssno=100;
But for 2 column updates, I can not do this:
update TableA set (col1,col2) = (select col1,col2 from TableB where ssno=100)
where ssno=100;
Please help,
Thanks a lot,Hi,
as far as the following subquery:
select col1,col2 from TableB where ssno=100
{code}
is returning only one row your statement:
{code:sql}
update TableA set (col1,col2) = (select col1,col2 from TableB where ssno=100)
where ssno=100;
{code}
is valid.
By the way, you can avoid repeating ssno=100 2 times in this way:
{code:sql}
update TableA A set (col1,col2) = (select col1,col2 from TableB where ssno=A.ssno)
where ssno=100;
{code}
Regards.
Al
Regards.
Al -
How to update specified column in table?
Hi,there,
I'm green in oracle,I have 2 tables with the same
fields, the same structure, I call it Ta and Tb,here
is their structure:
Ta:
Name Type
================
Col1 Varchar2(10)
Col2 Varchar2(10)
Col3 Varchar2(10)
Tb:
Name Type
========================
Col1 Varchar2(10)
Col2 Varchar2(10)
Col3 Varchar2(10)
Here is their Data:
Ta:
Col1 Col2 Col3
========================
c11 c31
c12 c32
c13 c33
Tb:
Col1 Col2 Col3
========================
c11 c21 c31
c12 c22 c32
c13 c23 c33
so how can I copy the contents of Col2 of Tb into
col2 of Ta using SQL or PL/SQL? I mean I want to
fill col2 of Ta with the data of col2 of Tb,pls
help me,thanks in advance!
NewOraHere is the query
update Ta set Ta.col2 = (select Tb.col2 from Tb where Ta.col1 = Tb.col1 and Ta.col3 = Tb.col3)
if u have the primary key columns is the tables u dont need to incolude all the columns in the where clause, u can use only key columns. -
Update columns in Table A based on columns in Table B for more than 500K rows
Guys,
I need to update 9 columns in table A based on value from table B for for more than 500K rows.
So what is best way to achieve this. I am thinking of writing a Procedure with cursor to update the rows of table A.
When i googled about it, they say cursor will decrease the performance. So i have no clue how to go for this.
Rough code which i though
1) Procedure with no parameter
2) Will declare 9 variable to store value from cursor
3) cursor will fetch row by row based on join condition between table a and table b
4) i will pass column values from table B to variables
5) will make an update statement for table A
Please let me know if above method is correct or is there any other way to do this without using cursor.Guys,
Below is the rough code i wrote as per my requirement. Does it look correct? As of now i dont have any platform to test it so any help with the below code is highly appreciated. As i said i need to update more than 500K rows by matching Table
A and Table B. One more thing which i would like to add in below code, is to get log of all the rows that are in table B but not exist in table A. Table A already has more than million data in it.
Also not sure how the loop in below code willl run when @rowcount is become to zero?
Please let me know if i need to consider performance related impact while running the script.
GO
SET SERVEROUTPUT ON
CREATE PROCEDURE ONETIMEUPDATE
DECLARE @cnt INT;
SET @cnt = 1;
DECLARE @MSG varchar(255);
DECLARE @COUNT_VAR INT;
SET @COUNT_VAR=0;
WHILE @cnt > 0
BEGIN
Update TOP (50000) A
Set A.Col1=B.Col1,
A.COL2=B.COL2,
A.COL3=B.COL3,
A.COL4=B.COL4,
A.COL5=B.COL5,
A.COL6=B.COL6,
A.COL7=B.COL7
From TableA A
Inner Join TableB B
on A.ID = B.ID--ID
WHERE A.Col1 <> B.Col1
OR A.Col2 <> B.Col2;
SET @cnt = @@ROWCOUNT;
IF @@ROWCOUNT=25000
@COUNT_VAR=@COUNT_VAR + @@ROWCOUNT
SELECT @MSG = CONVERT(varchar, @COUNT_VAR) + "Rows Updated" -- I WANT TO DISPLAY UPDATE after EVERY 25000 ROWS
PRINT @MSG
IF @@ROWCOUNT=0
BEGIN
COMMIT
END
WAITFOR DELAY '00:00:01' --wait for a second before the next update
END;
END; -
UPDATE COLS OF ONE TABLE FROM VALUES OF CERTAIN COLU OF ANOTHER TABLE
I have two tables table1 table1
(col1, (col1,
col2, col2,
col3, col3,
col4, col4,
timeperiod) timeperiod)
both have same column names. table1 has data for certain timeperiod. table2 also has the data for the same timeperiod. table2 has the correct data for col1, col2. I want to update the columns (col1, col2) in table1 with data from columns (col1, col2) in table2
and leave the col3, col4 in table1 untouched (no change). Each time I might have to update different columns. some tables have more than 20 columns. This is like, I need to update whatever field I want.
How do I do this with a script or block declaring variables. How do I control the update for certain columns. This is not a one time thing which I will be doing. I have to do this for several tables whenever the data is not right.
Thank you,
svHi ,
you can use MERGE for this kind of situations....here i have given some samples...refer this...
MERGE INTO bonuses D
USING (SELECT employee_id, salary, department_id FROM employees
WHERE department_id = 80) S
ON (D.employee_id = S.employee_id)
WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
VALUES (S.employee_id, S.salary*0.1);
By this way u can update any no. of columns...I hope this will help you...
Thanks
Raj -
Getting errors when updating a column on a table having a primary key
Hi,
I have an application on Oracle APEX that raises the following error after an attempt (through the application) to update a column with no specific constraint on it:
ORA-06550: line 1, column 17: PL/SQL: ORA-00936: missing expression ORA-06550: line 1, column 9: PL/SQL: SQL Statement ignoredUnable to fetch row.
The involved table has a primary key conatraint and the corresponding column can be populated by a sequence (but there is no trigger to manipulate the sequence).
The sequence is mentioned in the involved page definition for populating the primary key.
If I disable the primry key and set to null the corresponding value for the primary of the record to be updated, then it is possible to update that record (thus the above column) through the application.
Did someone encountered this situation before?
If yes, what was then your workaround/solution?
Kind Regards.Dear user8058501 ,
Firstly) Did you check
Auto Row Fetch (After upgrade to 4.0.1)
Automated Row Fetch on Table with Synonym causes ORA-00936: missing expr.
Secondly) If the problem is not resolved, Would you provide a sample on apex.oracle.com with workspace/developer account to be able to help you
Please, if this solves your question, mark it as Correct. Otherwise as helpful.
Best Regards
Mahmoud -
Update SAME column name in two tables from ONE query
Dear All Seniors
Please tell me is it possible to update a same column name in two tables.
I have two tables in same schema
(1)table name
pem.igp_parent
column name
igp_no.
igp_type
(2)table name
pem.igp_child
column name
igp_no.
igp_type
i want to update igp_no column in one query please tell me how it would be possible.
thanks
yassenYou want to update the data from what to what? Where is the new data coming from?
If you are trying to put the same data in two different tables, that strongly implies that you have a normalization problem that needs to be addressed.
Why do you want a single query rather than updating each table in turn? Can you join the two target tables to produce a key-preserved view?
Justin -
Updating a column from other table
Hi all,
I have a simple update query problem. I have four tables
activist(activist_id,first_name,last_name,c_state),
membership(activist_id,g_n_id),
group_network(g_n_id,g_n_type_id),
school_grop_det(g_n_id,state). For some records in activist table the c_state column is null, i want to update that column with state column of school_group_det table.
Here is the query for the states which are null
select distinct a.activist_id,a.first_name,a.last_name,
a.c_state,sd.state from activist a,membership m,
group_network g,school_group_det sd where
a.activist_id=m.activist_id and g.g_n_id=m.g_n_id and
g.g_n_id=sd.g_N_id and a.c_state is null and g.g_n_type_id='1001'
order by a.activist_id
I got the activist_id,first_name,last_name,c_state from activist and state from school_group_det. now i as i told you want to update the c_state with state column of school_group_Det table.
Pleae any one help me
Thanks
SrinivasFor ur query the reply whay u have got is correct one. For further quries similar to one u had u can download a tool named TOAD (Tools for Oracle Application Developer) from quest site (www.quest.com). Install it a proceed.
Do let me know how and what u feek about TOAD. -
Update A Column In A Database Table.
I am unable to update a column in a database table.
For example; I have ten records in an EMP table without having any EMPNO. I want to UPDATE (insert) 10 different EMPNO in a table. How can I do it? All I know is that there are ten records in the table; this means that I cannot use a WHERE clause with different criteria for each row.
Thanks.Try something like this
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> insert into emp_1(empno, ename, job, mgr, hiredate, sal, comm, deptno)
2 select null, ename, job, mgr, hiredate, sal, comm, deptno
3 from emp_1
4 where rownum <= 10
5 /
10 rows created.
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
SMITH CLERK 7902 17-DEC-80 800 20
ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
WARD SALESMAN 7698 22-FEB-81 1250 500 30
JONES MANAGER 7839 02-APR-81 2975 20
MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
BLAKE MANAGER 7839 01-MAY-81 2850 30
CLARK MANAGER 7839 09-JUN-81 2450 10
SCOTT ANALYST 7566 19-APR-87 3000 20
KING PRESIDENT 17-NOV-81 5000 10
TURNER SALESMAN 7698 08-SEP-81 1500 0 30
24 rows selected.
SQL> select max(empno) from emp_1
2 /
MAX(EMPNO)
7934
SQL> create sequence emp_seq start with 7935
2 /
Sequence created.
SQL> update emp_1 set empno = emp_seq.nextval where empno is null
2 /
10 rows updated.
SQL> select * from emp_1
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7935 SMITH CLERK 7902 17-DEC-80 800 20
7936 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7937 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7938 JONES MANAGER 7839 02-APR-81 2975 20
7939 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7940 BLAKE MANAGER 7839 01-MAY-81 2850 30
7941 CLARK MANAGER 7839 09-JUN-81 2450 10
7942 SCOTT ANALYST 7566 19-APR-87 3000 20
7943 KING PRESIDENT 17-NOV-81 5000 10
7944 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
24 rows selected. -
Update Columns in Table from Other Table based on Fund Code
Hello All!!
Hope you are doing good!!!
I like to update 5 columns in X Table based on fund_code. The Fund code and 5 column values come from Y Table. Please let me know how to wirte a sql statement to update all values for 5 columns in X Table. Please post me any template code.
Thanks.I think you are looking for an updatable join,
Please see the syntax below,
UPDATE (SELECT b.col1
FROM table1 b, table2 E
WHERE b.col_pk = E.col_pk) T
SET T.col1 = 0Thanks,
G. -
Need to update corresponding columns in details table
Hi,
I have a header and lines table.
In header table we have a comments field, requirement is whenever someone is updating comments in header it should update lines comment column as well.
I tried using fire action on Comments field like as soon as user is entering something in Comments field I am capturing that event and firing and update statement for lines table
but the problem here is, if user enters the comments and doesn't save it at header level it stills fire an update statement in lines and updating the comment field of lines table.
I need to update header comments in lines level at Apply button.
Please someone suggest something.
Best Regards
Ragni GuptaHi Gurus/Expert,
Please suggest something, its really urgent!!
Thanks
Ragni Gupta -
Hi all
I have a problem in updating one column in the target table(say table A) from a column in the source table (say table B).
All the columns in table A has been populated. Just one column should be populated. My source is a SQL object that contains a complex sql query that returns three columns date_from, date_to and ID.
In the table A, I have the same date_from and date_to and need to get the ID from the SQL object and set it to the corresponding ID in the table A.
I tried many ways to update the table, but it I couldn't ;(
I should read from a table and update it based on a look-up function mapped to the column I need to update.
I want to map the ID colmn from table A to a look-up ext function that can get the column from the table B. However I don't know how to use the Data Services objects to just update 1 column. If you could give me a consequence of the DS objects to be update a table based on a look-up , I would be so grateful.
Thanks.Your dataflow should look like this :
1) Source = the SQL transform with date_from, date_to and ID as columns.
2) Next add a query (copy all columns from schema in to schema out) and set date_from and date_to as keys. Also make sure column names exactly match the column names in your target table, if not rename them in this query.
3) Add a Map_Operation transform that maps all "normal" operation codes to "update"
4) Finally add your target table and in the properties/options set "use input keys" to yes (or checked).
This will generate UPDATE statements for all columns used in the query with a WHERE clause based on the keys defined in the query (date_from, date_to).
Ben. -
How to update two columns in two tables?
hi friends
I have two tables linked to each other through SaleNo and SaleDT. their structure as below
Sales Table============
SaleNo int PK auto increment
SaleDT Datetime PK
Qnty decimal
Units decimal
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SaleNo int FK
SaleDT Datetime FK
Note that SaleDT column is NOT assigned with getDate() expression.
1. what I need to do is update the SaleDT column of Sales table and Invoices table with the value '2013-01-31 10:31:55.813', how do I do this without manually breaking the link between the tables?
2. Assume SaleNos 15 to 27 needs update the SaleDT to '2013-06-12 10:31:55.813', how do I do this complex operation where I I have update SaleDt column of two table of SaleNo range from 15 to 27?
thanks
I use Visual studio 2012 Ultimate and SQL server 2008 developer edition!Why not below? May be you will not be able to change your design now, but just want to share.
Sales Table============
SALEID int PK autoincrement
SaleNo int
SaleDT Datetime
Qnty decimal
Units decimalUNIQUE (Saleno,SaleDT)
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SALEID int FK -
Updating the column of a table
Hello Gurur,
I have two tables they are
Test & emp_op
Desc empop
- empid
-id_num
-node_num
_Desc Test
-id_num
-node_num
-name
-addr
-empid
Now i m trying to update the column empid in test table, copying as it is from empid column of emp_op table . Below is the query i have wriiten to update
update test e
set e.empid = (select t.empid from emp_op t
where t.id_num = e.id_num and
t.node_num = e.node_num );
But it gives me an error ORA-01427: single-row subquery returns more than one row. any idea why ??
if not, is there is any way i can accomplish this task in a different way ??
Thank you so much. I appriciate it!!Hi,
That means some row (maybe more than one) in test matches two or more rows in emp_op.
What do you want to do in that case? Post some sample data (from both tables, relevant columns only) and the results you want to see in test after the UPDATE.
If you know that all the matching rows in emp_op will have the same empid, you can just change SELECT in the sub-query to SELECT DISTINCT .
Maybe you are looking for
-
If I copy the "lcds" folder, Tomcat starts with socket errors
In the documentation it is said that when you create a new server-side application, you can start by copying the 'webapps/lcds' folder. I did that but then, Tomcat starts with some socket errors: [LCDS]SocketServer 'my-rtmp-SocketServer' failed to pr
-
Version is 7.0.1 Windows 7 64 Bit I can open FF under my user name which is not an Administrator, but when I try to open it under one of the Administrator names I get that error message. I do have the password for that administrator.
-
5th gen ipod does not connect to mac desktop or itunes
My ipod does not connect with my desktop or itunes (ie when I plug the ipod in using the original USB cable nothing happens--no charging no recognition that it has been connected). My nano does work with the same cable so I know it's not that. I've f
-
I am continually getting error -69 when syncing iPad Air with latest iOS and iTunes versions. Any suggestions?
-
can anybody tell how i identified the data in ANSI X12 format which i received? which position identified which field?