How can I update several lines based on the comparison of the fields table 1 and 2

I create the following SQL to test what I found a method to update the records where the fields below the game, but what ends up happening is that the update functions works the first time and then basically updates everything to null. I don't understand what I'm doing wrong. New to this.

UPDATE SLS_HDR B
DEFINE (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT, B.UPDATED_DT)
(SELECT =
A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2, A.PLAN_DEL_DT, A.TXTA, A.TXTB,
A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT, A.PAY_CONTACT, A.ORD_AMT, SYSDATE
Of
SLS_HDR_TEMP HAS
WHERE
A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS <>B.STATUS);

Can someone advise?
Thank you

Published by: 903292 on December 19, 2011 13:15

you don't have a where clause in your update so no-matched lines will be updated with null values

UPDATE SLS_HDR B
SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
= (
          SELECT
          A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
          A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
          A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
          A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
          FROM
          SLS_HDR_TEMP A
          WHERE
          A.FIN_COMP = B.FIN_COMP AND
          A.LOG_COMP = B.LOG_COMP AND
          A.ORD_NO = B.ORD_NO AND
          A.TRANS_DT = B.TRANS_DT AND
          A.BP_TYPE = B.BP_TYPE AND
          A.STATUS= B.STATUS
     )
WHERE EXISTS
(
     select null from SLS_HDR_TEMP A
     WHERE
     A.FIN_COMP = B.FIN_COMP AND
     A.LOG_COMP = B.LOG_COMP AND
     A.ORD_NO = B.ORD_NO AND
     A.TRANS_DT = B.TRANS_DT AND
     A.BP_TYPE = B.BP_TYPE AND
     A.STATUS= B.STATUS
)

OR using Merge

Merge into SLS_HDR B
using SLS_HDR_TEMP A
on (A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS= B.STATUS)
when matched then update set (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT ) = (A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE)

HTH...

Thank you

Tags: Database

Similar Questions

  • How can I register several OCX files at the same time

    How can I register several OCX files at the same time. OCX depending on the application files are stored in a network location, IE. R:\HR\whatever\whatever\*. OCX instead of manually record each ocx file, I would be with a simple batch file or an automated script. Anyone have any good ideas?

    Hi James,

    The Microsoft Answers community focuses on the context of use. Please join the professional community of COMPUTING in following the link MSDN forum

    http://social.msdn.Microsoft.com/forums/en-us/categories

  • How can I select several images contiguous hundreds of thousands of people in my library and copy them...

    How can I select several images contiguous hundreds of thousands in my organizer of items and copy them to a USB key so I can share with a family member who doesn't have photoshop?

    I fear that even if I find a method to select and move a batch of photos, images can be in a format that his computer is not supported.

    roberts80288042 wrote:

    How can I select several images contiguous hundreds of thousands in my organizer of items and copy them to a USB key so I can share with a family member who doesn't have photoshop?

    I fear that even if I find a method to select and move a batch of photos, images can be in a format that his computer is not supported.

    If I understand correctly...

    The photos you have posted in a particular order (probably the result of a selection). You can select contiguous files by clicking the first item, and then, with the SHIFT key, click the last item you want. That should highlight your contiguous files.

    Then, you use the function "export" in the file menu.

    In the dialog box, you have several useful options: file format, compression, the file size, the possible change of name and the destination. This destination can be a USB key or a Dropbox folder, as suggested by hatstead.

    If you have a large number to select, it's usually possible create a search with various criteria so that only the desired files are indicated.

    If you are not satisfied with the sort order (chronological, filename, import batch), I suggest to create an album. In an album, you can manually sort you want by moving the thumbnails in the navigation area. (Depends on your version of elements).

    Then all you have to do after that selection should select all (Ctrl A) and to export.

  • How can I get my account number of the device Apple Watch and iPhone 5?

    How can I get my account number of the device Apple Watch and iPhone 5?

    Try this below - it can help you!

    In the Apple Watch app on the iPhone, under My Watch > booklet & Apple pay > [your specific credit card]

  • How can I recover my windows vista serial, the tile is broken and im missing a few numbers... __i lost my toshiba recovery CD, it is an a135/s4677, I reinstalled vista, but in the first instance. I am already taking pictures of the sticker and serial No.

    How can I recover my windows vista serial, the tile is broken and im missing some numbers...
    I lost my toshiba recovery CD, it is an a135/s4677, I reinstalled vista, but in the first instance. I am already taking pictures of the sticker and serial No. my laptop if you need if you can help me please write me * address email is removed from the privacy * thank you

    If you had not reinstalled Vista, we helped you recover the product key of Vista for running old, Vista activated using specific programs.

    But, as you have wiped the hard and reinstall Vista, we will not help you recover the product key.

    http://www.CSD.Toshiba.com/cgi-bin/TAIS/support/JSP/home.jsp

    Contact your computer manufacturer and ask them to send a recovery disk/s Vista set.

    Normally, they do this for a cost of $ small.

    Using recovery disks is normally not need to insert a product key.

    See you soon. Mick Murphy - Microsoft partner

  • How can I change outlook settings to display the field 'to', so that I can see that the emails were sent at a glance?

    How can I change outlook settings to display the field 'to', so that I can see that the emails were sent at a glance?

    Outlook:

     

    http://answers.Microsoft.com/en-us/Office/default.aspx

    Office at the above link forums

    http://answers.Microsoft.com/en-us/Office/ee861097.aspx

    Outlook Help Forums at the link above.

    They will help you with your Outlook questions when repost you in the Office Forums above.

    See you soon.

    Mick Murphy - Microsoft partner

  • How can I get several lines to be printed for a blank text field so that it can be filled by hand?

    I have to create forms that are to be completed by hand and by electronic means.  The problem that I am running provides several lines that will be printed for the people who are the form of fill by hand.  I tried to add an image of lines behind the text field, but these would have got in the way when the form has been completed electronically.

    I use LiveCycle Designer ES2 v. 9.0 on a Windows computer.

    Thank you.

    Ok.

    1. Take a textfield
    2. Navigate to the object. Allow multiple lines
    3. Go to the Layout | Height | activate "develop to adapt."
    4. Go to initialize or readyform event (you must change the _ for your textfield) this.rawValue = "___\n___\n___";
    5. Go to the event, enter - this.rawValue = null;
    6. Go to the exit event

    If (this.) RawValue is nothing)

    {

    this.rawValue = "___\n___\n___";

    } else {}

    With this solution you can simulate the same reason above.

    I hope it's useful for you,

    Mandy

  • How can I get several lines in a form?

    I have a form that contains five fields inside.  One of the fields may require several lines to exist and when it is printed, you cannot use a scroll bar.

    This field is "Allow multiple lines" checked.  Just to make it work, everything else do as well.  Of course, that did not work anyway.  This subform which can repeat has a 'RepeatingData' node, which has a "Repeat" node that contains five fields that can repeat.  I don't see any property on each node so that it can grow dynamically.

    Any ideas?

    The problem is at the disposal of the field. Right-click on the field, hover over pallet, and then click page layout.

    You should see that the height and width parameters. under the entry for the height, there is a checkbox indicating "develop to adapt."

    Hope that helps!

    -PastAdobe

  • How the dynamic Action to update several items based on a JavaScript Expression producing a table?

    Using APEX 4.2.

    I have the list of selection using a LOV which returns a display value and a value separated by a comma e.g. return 'reserved to items' and "66,88" or "Available items" and "90,23".

    I want that return values for example "66,88" to be assigned to two my form fields.

    I have a dynamic action that fires when the field with the changes of the list/select-LOV. I am using an action of 'Set value' and set 'Expression JavaScript' with the expression itself type value ' $v("P1_MY_SELECT_LIST").split(",") and using Type "Article (s)' selection and listing the two points that I want to set as the items in question (from the description of the JavaScript expression field it appears that a table of the results would be assigned to the changed items , in the order.

    However, the original value of the LOV return value is passed to the first of the elements concerned (complete with the comma if the original return value was of the form '10')

    If I add more REAL action of the JavaScript "alert (" HELLO "+ $v ("P1_MY_SELECT_LIST") .split (", ") [0] +" WORLD "+ $v("P1_MY_SELECT_LIST").split (", ") [1]" ") I * see two expected values.»

    Any ideas what I could do wrong?

    The action 'Set value' affects the value specified to all affected elements: a value to one or more items. To set a different value at different points, you need several actions "Set value", or simply use javascript to do it in one.

    Even if you use a javascript expression that corresponds to a table, the table is just being converted to a string again. It creates a mapping of some sort. That is why for example with '10', she also translated as such. Actually you set this value to these two elements: ' 10, ".split(",").toString () (implicit in the chain of course).

    The code makes it very obvious that it doesn't handle values, as described in the help of the element. Aid is not correct or is the implementation simply not here yet?

    Just look at the javascript for dynamic actions, images/libraries/apex/dynamic_actions.js, service da.setValue directory file:

        function _setValue( pValue ) {
            lAffectedElements$.each( function( i ) {
                // Set all affected elements to the value passed
                $s( this, pValue, null, lSuppressChangeEvent );
            });
            /* Resume execution of actions here and pass false to the callback, to indicate no
            error has occurred. */
            da.resume( lResumeCallback, false );
        }
    

    And when you use a javascript expression:

        } else if ( lSetType === "JAVASCRIPT_EXPRESSION" ) {
            _setValue( lJavaScriptExpression.call( this ));
    

    It's pretty simple. (and this is checked on apex 5. It's the same on 4.2)

  • In MXML, how can insert you a line break in the label of a mx:Button?

    In other MXML components, you can do things like use curly braces to incorporate scripts, use '& #13' and stuff like that in their text and label attributes.  Apparently the mx label attributes: Buttons are so locked that normal suggestions for other components do not work.  I might try just setting the labels in the main script of an MXML file or something, but it's a sloppy programming if it can be avoided (values of labels will be constant in this case).  Is there a way to put a line break in the attribute in MXML?

    Regarding the use "& #13", which gave me a line break at least, but any text to the right of this sequence has disappeared.  This makes me think that there may be a way to make this work, but so far I have not found the way.

    Thank you!

    The response occurred in the thread that I put at the beginning for this:

    http://StackOverflow.com/questions/11621952/in-MXML-how-can-you-insert-a-newline-into-the-label-attribute-of-a-mxbutton

  • How can I draw several plots by using the XY graph during execution?

    Hello

    I want to draw several plots in the graph XY to the means of execution user will select the number of plots that he wants to draw, depending on this value, I have to get these values and use table generation and then I give to graph XY.

    During execution, but how to do this?

    Please help me in this regard.

    Kind regards

    Herald

    Why start a new thread?

  • How can I disable him flipping back between the pages with PgUp and PgDn? Please tell me that I can!

    From Firefox 4, it seems to have been decided that PgUp and PgDn are now buttons with which you return back between the pages. For me, this means essentially almost lose valuable information, because I actually use up and down pages, so I wonder. How can I disable this new and quite bothersome?

    Please tell me that I can!

    In the details of your system, I see this card installed: Macromedia Shockwave for Director Netscape plug-in, version 8.0

    You also seem to have the last, although always obsolete installed namely Adobe Shockwave for Director Netscape plug-in, version 11.5

    First, click on the orange button Firefox, go to add-ons and Plugins and disable the version of Macromedia.

    Then go to http://get.adobe.com/shockwave/ and update it.

    If the problem persists then, try running Firefox in Firefox to solve the issues in Safe Mode. If it works properly in this configuration, then one of your modules is the culprit.

  • How can I save by iPad 3 when the screen is black and nothing appears?

    How can I save my iPad in ITunes or iCloud 3 when the screen is black and nothing appears?

    Is the empty screen, because just the screen is broken, or is the iPad just dead? Have you tried a soft-reset/reboot it?

    At least you can see what you touch on the screen of the iPad, you cannot force a backup to iCloud.

    If the iPad still works and is connected to wifi, a backup should automatically happen (if iCloud backups are enabled) if it is connected and the locked screen.

  • How can I synchronize a new track to the audio spectrum, effects and audio amplitude logo

    Hello!

    How do I paid recently a graphic designer to create a sound model for my music on youtube channel, but the problem is that I do not know how to synchronize a new track to the audio spectrum, the effects and the logo of the audio amplitude (pumps logo to the sound of the track that he gave me in the layout) but I would like to synchronize it instead of a new track at all. [Please help:]

    Click on the tab "LOGO of MOUNTAIN" or double-click the color icon in the Panel layer to open the publication.

    Import the audio file in the project Panel.

    Click on the new audio file in the project Panel to highlight.

    Click on the 'old' audio file in the Panel layer to select it.  (they are both put in evidence now)

    Now, hold down the 'Alt' key and then drag the new audio file of the project on the old audio layer panel in the layer panel.

    Doing it this way will automatically do all necessary connections to the old file to the new file.

    Or... you could just drag the the new audio tracj in the Panel layer compositions 'sound '.

    Select the solid layer that has the applied Audio Spectrum effect.

    Then in the Audio Spectrum effect setting pane, find the list at the top of "Audio Layer" drop-down list, click the menu drop-down and select the new audio layer.

  • How can I update several contacts at the same time?

    Hello. I want to update the contact information for a group of contacts in the instance which changes phone number or address of the group. How to accomplish this? Thank you.

    This is not something the Contacts Apple app supports, which means find a third-party application that supports this, or perhaps export, then changing the export and then re-import the data.  Or find another way to store only the contacts information on a support CardDAV taking server, export data to this server (possibly shared with other authorized people?), then changing the data on the server.

Maybe you are looking for