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!
NewOra

Here 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.

Similar Messages

  • 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 updated matrix into related table?

    hi, can anyone help me below coding how to updated matrix into related table?
    Thank you.
                For rowNum = 0 To oMatrix.RowCount
                    oRecordset.Fields.Item("Code").Value = oMatrix.Columns.Item("DSCode").Cells.Item(rowNum).Specific.Value
                    oRecordset.Fields.Item("Name").Value = oMatrix.Columns.Item("DSName").Cells.Item(rowNum).Specific.Value
                    oRecordset.Fields.Item("U_RPTC").Value = oMatrix.Columns.Item("DSReport").Cells.Item(rowNum).Specific.Value
                    oRecordset.Fields.Item("U_USRC").Value = oMatrix.Columns.Item("DSUser").Cells.Item(rowNum).Specific.Value
                    oRecordset.MoveNext()
                Next

    For Fast Matrix Loading you can user some thing like this.
            Dim Column As SAPbouiCOM.Column
            Dim Matrix As SAPbouiCOM.Matrix
            Dim Table As SAPbouiCOM.DataTable
            Table = oForm.DataSources.DataTables.Add("Documents")
            Table.Columns.Add("Code", SAPbouiCOM.BoFieldsType.ft_Integer)
            Table.Columns.Add("Name", SAPbouiCOM.BoFieldsType.ft_Integer)
            Table.Columns.Add("U_RPTC", SAPbouiCOM.BoFieldsType.ft_AlphaNumeric, 255)
            Table.Columns.Add("U_USRC", SAPbouiCOM.BoFieldsType.ft_AlphaNumeric, 255)
            Matrix = oForm.Items.Item("MatrixUID").Specific
            Column = Matrix.Columns.Item("Code")
            Column.DataBind.Bind("Documents", "Code")
            Column = Matrix.Columns.Item("Name")
            Column.DataBind.Bind("Documents", "Name")
            Column = Matrix.Columns.Item("U_RPTC")
            Column.DataBind.Bind("Documents", "U_RPTC")
            Column = Matrix.Columns.Item("U_USRC")
            Column.DataBind.Bind("Documents", "U_USRC")
            Table.ExecuteQuery(SQLQuery)
            Matrix.LoadFromDataSource() 'Load The Data to the Matrix
    To pull the data form the display back to the Table you can use this
    Matrix.FlushToDataSource()

  • Reg:How to delete the column in table control also from database table.

    Hi Experts,
    Once again thank u all for giving the responses.
    one more doubt is how to delete the columns of table control and also the record shold delete from ztable.
    With Regards,
    Saroja.P.

    Hi,
    If you want to delete the rows in the table control and simultaneously delete it from the database table, then you can implement a 'DELETE' functionality specific to your table control. Have a MARK field (you will find that in the screen attributes of the table control -> give a name for the MARK field, you will find an additional MARK column at the beginning of your table control). You can check whatever rows you want to delete from the table control, call the delete module.
    "This portion of code inside the LOOP...ENDLOOP.
    IF sy-ucomm eq 'F_DELETE'.
       gt_itab2-check = mark.  " Store the MARK field status into your internal table's correspoding field 'check'
      MODIFY gt_itab INDEX tabcontrol-current_line.
    ENDIF.
    iF sy-ucomm eq 'DELETE1'.
      DELETE gt_itab WHERE check eq 'X'. "Your internal table does not have rows that you want to delete
    ENDIF.
    Now you can modify your database table using the MODIFY statement.
    MODIFY ZDB FROM TABLE gt_itab.

  • How to add a column in table control

    Hi ,
       Can any one tell me how to add a column in table control? My requirement is to add two columns ( custom fields ) into table control ( It is a standard program). I have added the column in the table and also in the table control. But when I am running the standard program, The newly added column is not there. But I have added in the perticular screen. Change is not reflected.
       Can anyone help me on this please.
    Thanks in advance.
    Regards,
    Lakshmi.

    Hi,
    Ensure the following :
    1. After adjusting the database, you`ll have to use the database utility and activate the table.
    2. If you have changed the standard screen, in tcode se80 -- right click on the program and click activate all. This activates all objects related to that program.
    Now execute the program.
    Reward if helpful.
    Regards

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • How to update duplicate row from table

    Hi,
    how to update duplicate row from table?
    First to find duplicate row then update duplicate row with no to that duplicate row in oracle.
    can you give me suggestion on it?
    Thanks in advance.
    your early response is appreciated...

    In order to find a duplicate row, see:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1224636375004
    (or search this forum, your question has been asked before)
    In order to update it, just create and use an Oracle sequence, have it start and increment at a value that doesn't exist in your table.
    If that doesn't get you going, post some CREATE TABLE + INSERT INTO statements, and the results you want from them, in other words: a complete testcase.

  • How to find the columns and tables used in a stored procedure?

    Hi,
    Can someone suggest how to find the columns and tables used within a stored procedure?
    Thanks
    VBK

    For example:
    SQL> create or replace
      2    procedure p1
      3      is
      4          cnt number;
      5      begin
      6          select count(*) into cnt from emp;
      7  end;
      8  /
    Procedure created.
    SQL> select  referenced_owner,
      2          referenced_name
      3    from  dba_dependencies
      4    where owner = 'SCOTT'
      5      and name = 'P1'
      6      and referenced_type = 'TABLE'
      7  /
    REFERENCED_OWNER               REFERENCED_NAME
    SCOTT                          EMP
    SQL> SY.

  • How to make a column in Table popin read only

    Hi Everyone
    Could anyone let me know how to make a column in table popin read only.
    Regards

    if you ar eusing an ALV table
    try this
      DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table,
            r_table TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
    * get reference to ALV component interface
      lr_salv_wd_table = wd_this->wd_cpifc_alvmain( ).
    * get ConfigurationModel from ALV Component
      wd_this->r_table = lr_salv_wd_table->get_model( ).
    * init ColumnSettings
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_col_header TYPE REF TO cl_salv_wd_column_header.
      lr_column_settings ?= wd_this->r_table.
    * get table of column settings - each line one column
      DATA: lt_columns TYPE salv_wd_t_column_ref.
      lt_columns = lr_column_settings->get_columns( ).
    * loop over table - in each loop another column can be modified
      DATA: ls_column TYPE salv_wd_s_column_ref.
    * define visible columns (fields) by naming them,
    * exclude others by setting visibility to none
      DATA: ls_tooltip TYPE string.
      LOOP AT lt_columns INTO ls_column.
        " get header of column
        lr_col_header = ls_column-r_column->get_header( ).
        " do settings here
    ENDLOOP.
    Or see this document for more tips.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4</a>
    regards,
    Joris

  • 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

  • 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 acheive

    It 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 tu update a column having type 'Long raw' in oracle table with an image

    Hello,
    I must change the image loading in a column with 'long raw' type in the table. I find an image data already in the table.
    I have my new imgae in a file .bmp.
    What SQL instruction I mut use to update this column to load my new image ?
    I work in Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod.
    thanks for your helps.
    Regards.

    Unless I'm missing something MSFT are making it unecessarily complex by not implementing the SQL/XML standard...
    SQL> alter table emp add ( emp_xml xmltype)
      2  /
    Table altered.
    SQL> update emp set emp_xml = XMLELEMENT("EMPLOYEE",xmlattributes(EMPNO as "id"), XMLElement("Name",ENAME))
      2
    SQL> /
    14 rows updated.
    SQL> set pages 0
    SQL> select EMPNO, EMP_XML from EMP
      2  /
          7369
    <EMPLOYEE id="7369">
      <Name>SMITH</Name>
    </EMPLOYEE>
          7499
    <EMPLOYEE id="7499">
      <Name>ALLEN</Name>
    </EMPLOYEE>
          7521
    <EMPLOYEE id="7521">
      <Name>WARD</Name>
    </EMPLOYEE>
          7566
    <EMPLOYEE id="7566">
      <Name>JONES</Name>
    </EMPLOYEE>
          7654
    <EMPLOYEE id="7654">
      <Name>MARTIN</Name>
    </EMPLOYEE>
          7698
    <EMPLOYEE id="7698">
      <Name>BLAKE</Name>
    </EMPLOYEE>
          7782
    <EMPLOYEE id="7782">
      <Name>CLARK</Name>
    </EMPLOYEE>
          7788
    <EMPLOYEE id="7788">
      <Name>SCOTT</Name>
    </EMPLOYEE>
          7839
    <EMPLOYEE id="7839">
      <Name>KING</Name>
    </EMPLOYEE>
          7844
    <EMPLOYEE id="7844">
      <Name>TURNER</Name>
    </EMPLOYEE>
          7876
    <EMPLOYEE id="7876">
      <Name>ADAMS</Name>
    </EMPLOYEE>
          7900
    <EMPLOYEE id="7900">
      <Name>JAMES</Name>
    </EMPLOYEE>
          7902
    <EMPLOYEE id="7902">
      <Name>FORD</Name>
    </EMPLOYEE>
          7934
    <EMPLOYEE id="7934">
      <Name>MILLER</Name>
    </EMPLOYEE>
    14 rows selected.
    SQL>

  • How to update multiple columns from different tables using cursor.

    Hi,
    i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
    I have a code written as follows :
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
         LOOP
              FETCH C1 INTO v_mydept1,v_mydept2;
              EXIT WHEN C1%NOTFOUND;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
         END LOOP;
         COMMIT;
    END;
    The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
    It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
    I am not sure what is the exact problem when we want to update multiple columns of different tables.
    Can anyone help me on this ?

    oops my mistake.....typo mistake...it should have been as follows --
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    Now here is the upated PL/SQL code where we are trying to update columns of different tables --
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1,v_mydept2;
    EXIT WHEN C1%NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    END LOOP;
    COMMIT;
    END;
    Please let us know why it is not updating by using using CURRENT OF

  • How to update and retrieve the table control entries and field entries.

    Hello everyone,
    i have a requirement,
    i have    company code , plant, fiscal year, posting period  fields in the selection screen and then below that i have a  table control which contains 4 fields  invoice no., check number, check date and amount.
    i have to enter the values and when i press  SAVE button , these values have to update in a custom table which i had created.
    please send me the coding how to do this object.
    will be rewarded.
    thanks in advance.

    Hi Suresh
      this is actual requirement
    in the CAT2.
    1. Add a new column for WBS description and derive the value as per the FS
    2. Retrieve project number and description and update in the column specified
    3. When a service order is selected it should do the same for 2.
    4. Finally repeat for the worklist view (which is the section above)
       here i am able to display values at data entry area
    for service order and network but not worklist area ?
        updation is not coming, can u plz go throw it..
    Thanks
    Chinna

  • How to update values in the table control at  Cat2 transaction,

    Hi,
    i am working on cat2 transaction, here
    i am using the exit_saplcats_006 and updating values at catsdb table, but i want to display this values at the table control in the cat2 transaction.
       can any one provide me solution for this same.
    Regards

    Hi Suresh
      this is actual requirement
    in the CAT2.
    1. Add a new column for WBS description and derive the value as per the FS
    2. Retrieve project number and description and update in the column specified
    3. When a service order is selected it should do the same for 2.
    4. Finally repeat for the worklist view (which is the section above)
       here i am able to display values at data entry area
    for service order and network but not worklist area ?
        updation is not coming, can u plz go throw it..
    Thanks
    Chinna

Maybe you are looking for

  • How can I get music from my ipod to iTunes?

    I have a tablet through work (Lenovo x61).  Our IT group had to wipe the tablet for some new software, so I made sure I had all of my music on my itouch.  Now that I've gotten the tablet back, I'd like to take all of that music (some of it not purcha

  • Help Cloning Old iPhone 3g to new iPhone4 issue

    A friend has given me her new iphone 4 and asked if I can sync her old iphone's content over to the new handset. (contacts, apps,music, etc) However, she has already tried herself and so the iphone4 is already recognised by itunes. Is there any way t

  • HT201240 can i put a password on my e mail account?

    Can i add a password to my email on imac??

  • JSF component displaying incorrectly

    I have a problem when i run my jsf application. The components don't display correctly. For instance, a button that is suppose to have the rounded edges and hint of blue color show up like a normal sqaure gray button. This only happens on my computer

  • Substr/Instr/analytics question

    I have a table like this on 9i (soon to be 10g) CREATE TABLE BASELINE_TESTRUN RUNID VARCHAR2(42 BYTE) NOT NULL with data like this: insert into BASELINE_TESTRUN values ('DEV1-XXX-01'); insert into BASELINE_TESTRUN values ('DEV1-XXX-03'); insert into