Table update from T-SQL question

Ok, I have a T-SQL query that I'm trying to convert in Oracle SQL.
Here is the T-SQL:
Update E
Set field1 = 'some text',
field2 = NULL
from table1 E
Left join table2 A
On e.fieldx = a.fieldx
and e.fieldy = a.fieldy
I think I'm close, but I'm not sure about the left join:
Update table1 E
set (field1, field2) = (
select 'sometext', NULL
from table2 A
where a.fieldx = e.fieldx
and a.fieldy = e.fieldy)
What can I do to fix this?
Thanks.

The equivalent to your T-SQL Query would be:
Update table1 E
set (field1, field2) = (
select 'sometext', NULL
from table2 A
where a.fieldx (+) = e.fieldx
and a.fieldy (+) = e.fieldy);
But since you don't do anything with the columns from table A and it is left joined, you can simply write:
Update table1 E
set field1 = 'sometext', field2 = NULL ;

Similar Messages

  • Parse SQL: How to extract column names, table names from a SQL query

    Hi all,
    I have a requirement wherein a SQL query will be given in a text file.
    The text file has to be read (probably using text_io package), the SQL query needs to be parsed and the column names, table names and where clauses have to be extracted and inserted into separate tables.
    Is there a way to do it using PL/SQL ?
    Is there a PL/SQL script available to parse and extract column names, table names etc ?
    Pls help.
    Regards,
    Sam

    I think I jumped to conclusion too early saying it is completely possible and straight forward. But after reading through your post for one more time I realised you are not interested only in the column_names, also the table_names and the predicates .
    >
    SQL query needs to be parsed and the column names
    >
    The above is possible and straight forward using the dbms_sql package.
    I am pasting the same information as I did in the other forum.
    Check this link and search for Example 8 and .
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref6136
    Also check the working example from asktom
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1035431863958
    >
    table names and where clauses have to be extracted
    >
    Now this is the tricky bit. You can extract the list of tables by getting the sql_id from v$sql and joining it with v$sql_plan. But sometimes you may not get all the results because the optimizer may choose to refine your query (check this link)
    http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html
    and you can get the predicate information from the same table v$sql_plan but I will leave that area for you to do some R&D.
    Regards
    Raj
    Edited by: R.Subramanian on Dec 10, 2008 3:14 AM

  • Table update from text file on server

    How do I get a table in dreamweaver to update from a text
    file thats on the server it will be posted on? Do I need to use
    some sort of weird coldfusion or asp.net, or can i do it in basic
    html. It would be sweet to make happen for my portfolio news
    section ... thanks!

    Hello,
    What you need is to know the structure (fields) of your internal table LS_BKPF at runtime.
    The standard SAP class CL_ABAP_TYPEDESCR contains Methods to describe not only repository structures but also variables used in your ABAP program.
    DESCRIBE_BY_DATA : Description of data object type
    DESCRIBE_BY_NAME : Description of object type using relative/absolute names
    DESCRIBE_BY_OBJECT_REF : Description of object type using reference
    DESCRIBE_BY_DATA_REF : Description of data object type using reference
    Example on how to do this can be found here :
    [http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414700)ID1687263150DB21033411053326729243End?blog=/pub/wlg/2071|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3414700)ID1687263150DB21033411053326729243End?blog=/pub/wlg/2071]
    After you have retrieved the fieldnames of your internal table at runtime you can add them in the first line of your dataset.
    Success.
    Wim

  • RBKP and BKPF table update from MIRO

    Hi All,
    I am using the BADI BADI_FDCB_SUBBAS01 to add a custom field in MIRO transaction. The added custom field is getting updated in RBKP transaction.
    I also want to update the custom field data in BKPF table, but i dont know when the BKPF table gets updated in MIRO transaction.
    Can you help me where the BKPF table will get updated. Is there any BADI for updating the custom fields in table BKPF via MIRO?
    Thanks and Regards,
    Vijay

    Hi Baskar,
    I have done this thing from MIRO transaction to update BKPF table. Please check the below code.
    METHOD if_ex_badi_fdcb_subbas01~put_data_to_screen_object.
      CONSTANTS:
      c_bkpf_xref1(25) TYPE c VALUE '(SAPLFDCB)BKPF-XREF1_HD'.
      FIELD-SYMBOLS: <fs_bkpf_xref1> TYPE ANY.
    fill interface attributes from importing paramters
      me->if_ex_badi_fdcb_subbas01~invfo  = im_invfo.
      ASSIGN (c_bkpf_xref1) TO <fs_bkpf_xref1>.
      IF sy-subrc = 0.
        <fs_bkpf_xref1> = me->if_ex_badi_fdcb_subbas01~invfo-zlet_number.
      ENDIF.
    ENDMETHOD.
    METHOD if_ex_badi_fdcb_subbas01~get_data_from_screen_object.
    CONSTANTS:
    c_bkpf_xref1(25) TYPE c VALUE '(SAPLFDCB)BKPF-XREF1_HD'.
    FIELD-SYMBOLS: <fs_bkpf_xref1> TYPE ANY.
    fill export parameters from interface attributes
      ex_invfo  = me->if_ex_badi_fdcb_subbas01~invfo.
    ASSIGN (c_bkpf_xref1) TO <fs_bkpf_xref1>.
    if sy-subrc = 0.
    <fs_bkpf_xref1> = ex_invfo-zlet_number.
    endif.
    ENDMETHOD.
    After passing the data through field symbols, then you need to update the BKPF table using the BADI AC_DOCUMENT. Refer the below code.
    METHOD if_ex_ac_document~change_after_check.
    variable declaration
      DATA: lv_let_number  TYPE zisr_let_number,
            lv_field TYPE char18 VALUE '(SAPLMRMP)xaccit[]',
            lv_let_field TYPE char27 VALUE '(SAPLMR1M)RBKPV-ZLET_NUMBER'.
    Field symbol declaration
      FIELD-SYMBOLS : <ft_accit> TYPE accit_t,
                      <fs_accit> TYPE accit,
                      <fv_let_number> TYPE ANY.
    Constant declaration
      CONSTANTS : lc_miro TYPE sytcode VALUE 'MIRO'.
    Check for transaction code MIRO
      IF sy-tcode EQ lc_miro.
        ASSIGN (lv_field) TO <ft_accit>.
        CHECK sy-subrc EQ 0.
        ASSIGN (lv_let_field) TO <fv_let_number>.
        CHECK sy-subrc EQ 0.
    Assign the letter number to BKPF table field XREF1_HD
        LOOP AT <ft_accit> ASSIGNING <fs_accit>.
          lv_let_number = <fv_let_number>.
          <fs_accit>-xref1_hd = lv_let_number.
        ENDLOOP.
      ENDIF.
    ENDMETHOD.

  • Table update from workflow

    Hi,
      I have a requirement to start workflow when table entry or modification is made. And in one has to authorize for the data. then only data should be saved in data base. if manager rejects data should not be saved in data base.
      What i have done till now is i have generated a table maintainence and created and new (using business objects )event to raise. (writing a FORM). So when ever we create new table entries event is raised. And i am using this event to trigger my workflow.
      I have two problems
      first one. this event is only getting trigged if i make entry to table through se11 and create new entries option. if i am using a program to update the table then event is not getting trigged. Is there way i can make this event to trigger even if i insert  data to this table from any where?
    Second problem
         i want to complete my workflow. based on manager decision only database should be commited or rolled back.
      if any one needs further details regarding problem reply.
    Thanks in advance
    Mohan

    Hi,
    I also think you should use a temporary table where you store the data you want to insert into the database before the approval is done. You create the maintenance view on this temp table and start the workflow from there. Once manager approves the new entry / change, workflow automatically updates the permanent table and deletes the record from the temp one.
    You can use the change documents, maintenance view event routines or maintenance view screen logic to trigger the WF. But I`m not aware of any tools to capture a database change done by a direct update, so if you also have programs directly updating the database table, you have to trigger the workflow start event explicitely in those as well.
    Regards,
    Krisz

  • CUA user master table updates from child system

    Hi Experts,
    In my system although there are roles assigned to users in child system they are not showing up in CUA for few user.
    Is there any program in CUA which i can use to  update the user master tables for only a limited set of users from child systems.
    Regards,
    Sandeep

    Hi Sandeep,
    Just want to check below queries....if this solves your problem..
    Is these are the new systems assigned to CUA or moved from other CUA as you said that role assignment is available in child system but not in CUA ? Another  thing that  I want you to check the User Group  assigned to user in child system and in CUA.If user gorups assigned to users are different in CUA and child system or particular group is missing in any one of the system then idoc will not move. Also check the Output device type along with address data...Any mismatch of these will stop the idoc.
    After that run the SCUG for all users, in CUA as suggested by akshay, this you can run for all 10 child system from CUA, no need to go in every child system.....

  • BADI/User Exit for custom table update from Delivery

    Hi
    Our requirement is to update a custom table with the delivery number and other related details when the picking status is changed to "C". Kindly suggest BADI/User exit for this requirement .
    Thanks in Advance for your immediate help .

    Hi Joseph,
    See SAP Note 415716 - User exits in delivery processing. It says when you have the document number available, what is permitted, what not, ....
    I hope this helps you
    Regards
    Eduardo

  • SQL UPDATE from PL/SQL triggered by button

    I have a form with the normal buttons (create/save/delete) working.
    For 2 of the fields I want to introduce a calculation on demand system. What I did is: created a button compute and associated some PL/SQL with it. The button submits as "compute" (something I made up) and has a branch that goes back to the same page. The button's PLSQL code is the following process (After Submit):
    DECLARE
      rasaDom VARCHAR2(2);
      pRasaDom NUMBER;
    BEGIN
    tRace(:APP_SESSION, to_number(:P5_K));
    domRace(:APP_SESSION, rasaDom, pRasaDom);
    if (pRasaDom > 0 and pRasaDom <= 100) then
         :P5_RASADOM := rasaDom;
         :P5_PRASADOM := pRasaDom;
         update BOVIS.S_CIV_F SET RASADOM=rasaDom, PRASADOM=pRasaDom where K = to_number(:P5_K);
         commit;
         wwv_flow.debug('THEN! rasaDom=' || rasaDom || ' %=' || pRasaDom);
    end if;
    END;
    The problem is the the above UPDATE simply does not work!
    I should also mention that:
    - the normal update process does not run (which is fine), because:
    0.03: ...Do not run process "Apply MRU", process point=AFTER_SUBMIT, condition type=REQUEST_IN_CONDITION, when button pressed=
    - my process displays the success message
    - the "then" debug message shows just fine.
    It looks like the is a big rollback somewhere (this is why I added the commit there). My guess is that APEX is doing an update to the old value. What am I doing wrong?
    Thanks!
    Edited by: Şerban on 12.02.2009 03:43

    Hello:
    update BOVIS.S_CIV_F SET RASADOM=rasaDom, PRASADOM=pRasaDom where K = to_number(:P5_K);Your update statement is updating the columns back to their current values !
    If you want the rasaDom and prasadom updated to what is contained in p5_rasadom & p5_prasadom your code should be
         update BOVIS.S_CIV_F SET RASADOM=:P5_RASADOM , PRASADOM=:P5_PRASADOM  where K = to_number(:P5_K);
    ....Varad
    Edited by: varad acharya on Feb 12, 2009 4:51 AM

  • Table update from PAI

    Hi All,
    I have couple of fields in my screen,based on the entries made on these two fields i will have have to
    update my database table with the same entries.
    Please help as how my PAI should be..
    Thanks,
    Rahul

    Hi Rahul,
    Pl see
    Data: screen_input1,   "these are the field names defined as well on screen
             screen_input2,   "screen field name where data would come after entering on to screen
             input1,
             input 2.
    in PAI module
    input1 = screen_input1.     "trf the data to the field reqd by you.
    input2 = screen_input2.
    UPDATE <database table name>
                     SET field1 = input1
                     field2 = input2
                     WHERE condition to select the right record for updation.

  • How get all table name from database

    hi master
    sir
    how get all table name from database

    The big question is 'why'.
    Selecting from view 'dba_tables' will indeed give the list of all tables in the database, but that includes the dictionary tables and the internal tables, and many others that are probably not of interet to a person who needs to ask this question. Besides, the dba_tables view requires access to a DBA account.
    There are several other views: "user_tables" will list all the tables in this user's schema; and "all_tables" will list all the tables this user can access in some way.
    The above do not, of course, include any information about synonyms, sequences, views, indexes and so on.
    The correct answer and the meaningful answer may be two different things.

  • Getting table name from a query

    Hi, I'm trying to get the table name from my sql query
    My code is as follows;
    ResultSetMetaData metadata = rs.getMetaData();
    for (int i = 1; i < metadata.getColumnCount(); i++)
    System.out.println(metadata.getTableName(i));
    I just get a blank output. Yet my sql query executes and I can pull down the records, and grab the column names from the result sets.
    Any ideas on how I can get the table name for the columns. The reason being is on one of my querys I'm using join statements and i need to retrieve the table name for the column i'm displaying, as some tables have similar column names.
    Thanks in advance.

    Hi,
    What db are you using?
    I also get a blank output with ResultSetMetaData.getTableName because Oracle doesn't implement this method.
    Why do you not know the table name anyway?
    regards
    Nick

  • How to update or populate table in SQL server from PL/SQL

    Hello - I am starting in the fascinating world of PL/SQL. One of the first task I've been assigned is to rewrite a code (basically I was thinking of creating a package with proc included) on PL/SQL that updates and/or populates tables in MS SQL Server. How should I do this? Is it doable? I guess it is. How can I call tables from others databases from PL/SQL? How to establish the conecction? where? It should be included in the package?
    Any help will be appreciated
    Thanks,
    CC

    See PL\SQL and SQL Server

  • Combine tables from 2 SQL servers with different Schemas and update as new data is entered

     I have 2 SQL server 2000 machines, I need to take a table from each one and combine them together based on a date time stamp.  The first machine has a database that records information based on an event it is given a timestamp the value of variable is stored and a few other fields are stored in Table A.  The second machine Table B has test data entered in a lab scenario.  This is a manufacturing facility so the Table A data is recorded by means of a third party software.  Whenever a sample is taken in the plant the event for Table A is triggered and recorded in the table.  The test data may be entered on that sample in Table B several hours later the lab technician records the time that the sample was taken in Table B but it is not exact to match with the timestamp in Table A.  I need to combine each of these tables into a new SQL server 2005 database on a new machine.  After combining the tables which I am assuming I can based on a query that looks at the timestamp on both Tables A & B and match the rows up based on the closest timestamp. I need to continuously update these tables with the new data as it comes in.  I havent worked with SQL for a couple of years and have looked at several ways to complete this task but havent had much luck.  I have researched linked servers, SSIS, etc Any help would be greatly appreciated.

    Hi Catalyst,
    Welcome to the MSDN Forums!
    I would have a concern with respect to your issue.  If there is no way to identify a sample, save for the closest timestamp on table A - what would happen if two samples were taken in the plant, and the test results were entered in reverse order?  The samples would not tie back to the appropriate measurements.  Can't you get an identifier of some sort to tie that sample back to table A?
    If you can't, something like this should work, but I'm not sure how you'll "serialize" the samples to avoid the situation above.
    Code Snippet
    --Create sample data
    DECLARE @TableA TABLE ( SampleNo int NOT NULL,
    SampleTime datetime);
    DECLARE @TableB TABLE ( SampleTakenTime datetime,
    SampleColour varchar(50),
    SampleQuality char(1),
    SampleResultNo int);
    INSERT @TableA SELECT 1, GETDATE()
    WAITFOR DELAY '00:00:10';
    INSERT @TableB SELECT GETDATE(), 'Orange', 'A', '5'
    WAITFOR DELAY '00:00:20';
    INSERT @TableB SELECT GETDATE(), 'Purple', 'D', '7'
    WAITFOR DELAY '00:00:10';
    INSERT @TableA SELECT 2, GETDATE()
    --Actual Query begins now
    SELECT *
    FROM @TableA AS a
    JOIN @TableB AS b ON ABS(DATEDIFF(millisecond,a.SampleTime,b.SampleTakenTime)) = (SELECT MIN(ABS(DATEDIFF(millisecond,ta.SampleTime,tb.SampleTakenTime)) )
    FROM @TableB tb
    JOIN @TableA ta ON a.SampleNo = ta.SampleNo)
    Now, to account for the fact that you are querying data from a different server, you need to create a linked server (see sp_addlinkedserver and sp_addlinkedsrvlogin) and then use the fully qualified name (server.database.schema.table) to reference the table.
    Hope this helps,
    Aaron

  • How to update a table (CUSTOMER) on a Report Server with the data from the same table (CUSTOMER) from another server Transaction server?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) From another server ex: Transaction server?
    Set up steps so inset, update or delete operation takes place across the servers.
    It would be great if someone please enlighten me in details about this process in MS SQL Server 2008 R2.
    Also please describe would it be different for SQL Server 2012?
    If so, then what are the steps?

    I had an interview question that is:
    How to update a table (Customer) on a server ex: Report Server with the data from the same table (Customer) from another server ex: Transaction server?
    Set up steps so that inset, update or delete operation gets done correctly across servers.
    I was not sure about the answer, it would be great if someone please put some light on this and explain in details about this process in MS SQL Server 2008 R2.
    Also it would be very helpful if you please describe would it be different for SQL Server 2012? If so, then what are the steps?

  • Migrate tables from Ms SQL Server 20005 to Oracle 10g

    Hi all,
    I am trying to migrate 10 table from Ms SQL Server 2005 to Oracle 10g. I started creating a SSIS package to transfer them but it always fail when it tries to create the tables.
    Questions:
    - Is there any other way to import Ms SQL Server 2005 tables to Oracle
    - also I need to create a scirp that will update these tables periodically
    any ideas?
    Thanks

    YingKuan is right. jsut to expound a little further. This will also allow you to have have scripts which you can run again and again or even schedule them regularly too.
    B

Maybe you are looking for

  • Can you use regular PCI cards in Mac Pro?

    My G5 is getting a bit long in the tooth and I want to buy a Mac Pro. It says that it supports PCI Express cards, but I have several PCI cards in my PowerMac. Since I don't want to buy them all over again, I was wondering if they will work in the Mac

  • Mavericks mail keeps resending old Gmail notifications

    I've installed the new update as of this morning, but I'm getting mail notifications for mail messages that are several years old in my Gmail. It looks like it is running through all 20,000 messages that I have already viewed How do I get it to stop?

  • Oracle distributed document capture service not started

    Oracle distributed document capture service not started and timeout

  • How to enable usage of Jabber (& Google Talk) accounts w/Parental Controls

    Hello all, As someone who just spent a few hours trying to figure out how to get iChat in a Parental Controlled account to work with Jabber (and Google Talk) accounts, and seeing that there were no good solutions posted on these boards earlier, I jus

  • Using Home Hub 4 with TalkTalk after contract

    Hi all, Sorry if this is an FAQ, couldn't find clarification elsewhere on the forum. Basically I've relocated to my parents' home after living away for work for a while. My housemates and I were in a contract with BT for over a year at my old place,