Need to update the table

Release of PL/SQL version 11.2.0.2.0 - Production

Hi gurus

You need assistance in question. I have the following data:

Sample data


drop table aa;

drop table bb;
create table aa
(
cust_no number (5),
cust_name varchar2 (30)
);

Insert in the NOA
(
Select 100, 'A' from two
Union of all the
Select 200, 'B' double
Union of all the
Select 300, 'C' of the double
);

create table bb
(
cust_no number (5),
cust_caty varchar2 (15)
);
Insert into bb
(
Select NULL, 'Potential' from dual
Union of all the
Select NULL, 'Not Potencial' of the double
Union of all the
Select NULL, "Unknown" of the double
);

Now, I want to update my bb with cust_id without no join table...

My required data should be something like below in the table of bb:

CUST_NO, CUST_CATY

100 potential

200 potential not

300 stranger

Please note that it doesn't matter what cust_no arrive at any cust_caty

Concerning

Shu

Hi, Shu,

Here's one way:

MERGE INTO dst bb

WITH THE HELP OF)

WITH aa_r_num AS

(

SELECT cust_no

ROWNUM AS r_num

AA

)

bb_r_num AS

(

SELECT cust_caty

ROWNUM AS r_num

BB

)

SELECT a.cust_no

b.cust_caty

Of aa_r_num one

JOIN bb_r_num b ON b.r_num = a.r_num

)             src

WE (dst.cust_caty = src.cust_caty)

WHEN MATCHED THEN UPDATE

SET dst.cust_no = src.cust_no

;

The results I get are exactly what you posted:

CUST_NO CUST_CATY

---------- ---------------

100 potential

200 potential not

300 stranger

But there is no guarantee that the same cust_no at the same cust_caty when you run it.

As posted, which means that bb.cust_caty is unique and not NULL.

If there are N + X lines in the bb, but only N lines in aa, then only N lines in bb will be updated.

Why do you want to do "without no join"?  If a join is the most simple, average the most effective to achieve the results expected, so why not use it?

If you really want to avoid the join, you can use a scalar subquery.

Tags: Database

Similar Questions

  • What API can be used to update the table cs_estimate_details (repair)

    I need to update the columns 'pricing_context' and 'pricing_attribute1' in the cs_estimate_details table.

    Which API can be used to update the columns. Where can I update the table directly?

    Try to use this "CS_Charge_Details_PVT" which in turn call "CS_ESTIMATE_DETAILS_PKG".

  • How to update the table with the number management

    Hello

    I need as there is a loc_tab of the created table as below,

    CREATE TABLE loc_tab
    (
    Country_ID NUMBER,
    country_code VARCHAR2 (3),
    country_name VARCHAR2 (50).
    State_ID NUMBER,
    state_code VARCHAR2 (3),
    state_name VARCHAR2 (50).
    city_id NUMBER,
    city_code VARCHAR2 (3),
    city_name VARCHAR2 (50)
    );

    I inserted records like below,
    COUNTRY_ID     COUNTRY_CODE     COUNTRY_NAME     STATE_ID     STATE_CODE     STATE_NAME     CITY_ID     CITY_CODE     CITY_NAME
    
              IND          INDIA                    TN          TAMIL NADU          CHN          CHENNAI
              IND          INDIA                    TN          TAMIL NADU          TRI          TRICHY
              IND          INDIA                    TN          TAMIL NADU          CMT          COIMBATORE
              IND          INDIA                    TN          TAMIL NADU          MDU          MADURAI
              IND          INDIA                    AP          ANDHRA PRADESH          HYD          HYDERABAD
              IND          INDIA                    AP          ANDHRA PRADESH          SEC          SECUNDRABAD
              AUS          AUSTRALIA               QLD          QUEENSLAND          BRI          BRISBANE
              AUS          AUSTRALIA               TAS          TASMANIA          HB          HOBART
              AUS          AUSTRALIA               TAS          TASMANIA          CCE          CITY OF CLEARANCE
              AUS          AUSTRALIA               TAS          TASMANIA          BUR          BURNIE
    Now, I wanted to update the table such that all ID columns are updated with running number.

    Each ID columns should get incremented so that, for Country_ID column corresponding to "India" If country_id is 1, that there must be one for all the lines with the name as "India". Likewise for "Australia".

    In the case of State, she also has the same logic with numbers repeated until the very name of the State comes.

    For the city, it of course will hold separate ID only because the name of the city will not get duplicated.

    This update must be done in the normal way using simple SQL such as no PLSQL don't like looping, etc... is involved.

    Here are the contents of the table, and that's how the table should be updated,
    COUNTRY_ID     COUNTRY_CODE     COUNTRY_NAME     STATE_ID     STATE_CODE     STATE_NAME     CITY_ID     CITY_CODE     CITY_NAME
                                            
    1          IND          INDIA          1          TN          TAMIL NADU     1     CHN          CHENNAI
    1          IND          INDIA          1          TN          TAMIL NADU     2     TRI          TRICHY
    1          IND          INDIA          1          TN          TAMIL NADU     3     CMT          COIMBATORE
    1          IND          INDIA          1          TN          TAMIL NADU     4     MDU          MADURAI
    1          IND          INDIA          2          AP          ANDHRA PRADESH     1     HYD          HYDERABAD
    1          IND          INDIA          2          AP          ANDHRA PRADESH     2     SEC          SECUNDRABAD
    2          AUS          AUSTRALIA     1          QLD          QUEENSLAND     1     BRI          BRISBANE
    2          AUS          AUSTRALIA     2          TAS          TASMANIA     1     HB          HOBART
    2          AUS          AUSTRALIA     2          TAS          TASMANIA     2     CCE          CITY OF CLEARANCE
    2          AUS          AUSTRALIA     2          TAS          TASMANIA     3     BUR          BURNIE
    Thank you and best regards,
    Shiva
  • need to update the date of the end of the user using the API of the IOM

    We have a requirement where we need to update the date of the end of the user. The details of the user as usr_key, number of days to extend (such as 30 days or 60 days), and affects manager is provided by SOA (maybe by BPEL). In the java class, I need to add the number of days of the closing date of the user and then update the table of the usr by IOM API method - usrMap.put ("USR_END_DATE", updatedEndDate);

    I wrote a small program, but it has erros. Please help me in this situation.
    ' public boolean updateEnddate (String usrKey, String managerKey, String NombreJours) {}
    Boolean result = false;
    String NombreJours;
    int totalNumUsers = 0;
    HashMap usrMap = new HashMap();
    usrMap.put ("Users.Key", usrKey);
    usrMap.put ("USR_MANAGER_KEY", managerKey);
    try {}
    DateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd");
    Date date = sdfSource.parse("USR_END_DATE");
    SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MMM-yyyy");
    String userEndDate = sdfDestination.format (date);
    tcResultSet = this.usrIntf.findUsers (usrMap) users;
    totalNumUsers = usersList.getRowCount ();
    If (totalNumUsers > 0)
    for (int i = 0; i < totalNumUsers; i ++) {}
    usersList.goToRow (i);
    updatedEndDate = userEndDate + NombreJours;
    usrMap.put ("USR_END_DATE", updatedEndDate);
    this.usrIntf.updateUser (users, usrMap);
    result = true;
    }
    on the other
    result = true;
    }




    Thank you
    Kalpana.

    Calculate the new date

    /**
    * This method is used to obtain the new date after adding x-days
    @param strDate - date today
    @param daysToAdd - x-days
    * @return Nouvelle_date - date after the addition of x days
    */
    private String incrementDate (Date strDate, int daysToAdd) {}
    Start date
    Logger.info("NotifyLastDayOfService::incrementDate(): entrez»);
    SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-DD 00:00:00");
    Dim str As String = sdf.format (strDate);
    Calendar c = Calendar.GetInstance ();
    try {}
    c.setTime (sdf.parse (str));
    } catch (ParseException exception) e {}
    e.printStackTrace ();
    }
    c.Add (Calendar.DATE, daysToAdd); number of days to add
    String PROMOTIONDate = sdf.format (c.getTime ());
    System.out.println ("calculated End Date:" + PROMOTIONDate);
    Logger.info("NotifyLastDayOfService::incrementDate(): sortie»);
    return Nouvelle_date;
    }

    This should solve your problem :)

  • Satellite Pro A120: Need to update the BIOS after upgrade CPU

    Hello

    I have a Toshiba Satellite Pro A120 and I need to update the bios of a change in cpu cause.
    The laptop works very well, but for some reason any with the new processor fan runs always full.

    A lot, I searched but found nothing.
    The model number is PSAC1E-0QL04CG3 of ideas where I can find the bios?

    THX in advance,
    John

    Hello

    First of all: update BIOS doesn t help you.
    Why do you think that BIOS update should help reduce the activity of fan?

    I guess that your new processor is faster. Right?
    So it offers more performance and this leads to higher heat dissipation... so finally the CPU must be cooled and this can be done only if the cooling module would turn faster you agree with me?

    By the way: the update of the BIOS is on the page of the Toshiba UE driver. Since the satellite Pro A120 is very old series, you will need to search for drivers in area Archive (Type of product-> Archive)

  • Need to update the Bios on the Satellite 4060XCDT to install Linux

    I need to update the bios to be able to install ubuntu 7.10 - where can I get the latest version of the BIOS?
    Thank you

    This laptop is a bit old and there is no real new version of BIOS.

    Take a look on this site
    http://EU.computers.Toshiba-Europe.com/cgi-bin/ToshibaCSG/download_drivers_bios.jsp

    In the Archive you will find-> Satellite Archive-> Sate 40xx you notebook series and the BIOS.
    The most recent one was released the 16/05/02-> it s BIOS 8.20

  • We need to update the drivers... Where can I get these and free would be great

    We picked up a nice all-in-one Photosmart C7200 series and run Windows 7 x 64 we need to update the drivers where I can get these and without would be great, I looked on the web, but I find virus and pilot will post that costs $ 40 and then I can download the drivers (I assume) this printer is clean looking again , but I guess that it is older that Windows 7 any help would be very appreciated

    Hi woodbywallace

    http://h30639.www3.HP.com/pub/softlib/software11/COL30662/MP-76036-1/PS_AIO_02_Net_Full_Win_WW_130_140.exe

    311,96 M
  • Need to update the license key of TEO

    Hello

    Does anyone know how to get the TEO license key? Please give me the steps to do...

    I used the trial version of TEO in training which has been exceeded, now I can't access TEO because I need to update the license key.

    Please share information... thank you.

    Kind regards

    Floriana

    External customers must follow the procedures given to them by their account manager and pass by [email protected] / * / and use SWIFT codes to ask for the keys.

    If you are internal cisco, please send an e-mail to Clint Havard (please look for it in the directory) and send him an email asking for an extended license for TEO/CPO. Be sure to include the hostname of your server of TEO in the query.

  • How do I update the table in Jdev

    Hello

    I use Jdev 11.1.1.7.1.

    The control of data, I added that ADF only read the table. When I click on the button create and return to the report screen, highlight lines are added.

    Highlighted those who is not inserted into the DB table but he showed in the report. How to remove it. How can I update the table?

    Kindly advice me.

    Thank you

    Swathi

    That's what I got:

    -You have a table read-only, and a link to create.

    -When you press the link create a popup will be launched with a new record (may be a form in the same table iterator).

    -When you press save to save the changes validation triggers, stop you to insert the record.

    -After the fire of validation you will close the pop-up window (by pressing icon or by pressing Cancel).

    -After closure of the pop-up window, you will find that reading one table has some blank lines.

    If it is your problem if you have 2 choices:

    1. in the AppModule you can make a new instance on the view object (to which redirect the table) If your view object called 'EmployeesView', so, in AppModule, you should have EmployeeView1 and EmployeeView2 and your table may point to EmployeeView1, and when you create new line create in EmployeeView2 and after completing the creation you can run the query and then refresh the table (as shown in the following code).

    2 - the second option in the popup cancelListener link at the rear bean method then you can update the table by program as:

        DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("TableIteratorName"); // from pageDef.
        iter.getViewObject().executeQuery();
        RequestContext.getCurrentInstance().addPartialTarget(getTableComponent());// from table Binding property bind it to object in back bean
    
  • Update the Table of Adf

    Hi all

    I have a page jspx, with a table and a button.

    Create the table data control, and it contains 4 columns

    (Name, card student, asked (Question or answer)).

    I create the code for the button to work

    1. Select a record

    2 send email

    3. when I send the request goes from Q to A

    All work fine. The mail has been sent. The demand for DB password Q has. But in my jspx table refreshes.

    Until I close and open again, it displays all the data.

    How cal I solve it?

    Thanks in advance

    Christos.

    Simply add partialTrigger on table pointing to the button.

    It will update the table when the button is clicked.

  • I need to export the table in "png" format, but continuied table also even exported to PDF...

    Dear all,

    I need to export the table as image format "png".

    in case any continuous table is there, sample suite table page 2. I need the same page by page (2 images) required.

    Please suggest how to handle these cases in javascript.

    Kind regards

    Sagna

    Thanks Laubender and uwe!

  • Good afternoon! I had a problem with Adobe Muse to pay. I was transferred to the free subscription. In a letter to the mailbox said he indicated that the need to update the card payment in detail, but I can do, and the site gives a

    Good afternoon! I had a problem with Adobe Muse to pay. I was transferred to the free subscription. In a letter to the mailbox said he indicated that the need to update the card payment in detail, but I can do, and the site gives an error. Credit card remains the same.

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • I need to update the screenshots for a new version of an app existing Itune application to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    I need to update the screenshots for a new version of an existing iTunes Connect App asks me to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    You must call the assistance of the company and ask them to help you with this. You can find contact information by logging on http://digitalpublishing.acrobat.com/ and looking at the Middle at the bottom of the page.

    Neil

  • I can't update my CS5 because I loaded Yosemite on my iMac. you will need to update the files camera raw.

    I can't update my CS5 because I loaded Yosemite on my iMac.  You will need to update the raw files.

    Please try and reinstall CS5: stalling-yosemite-version-10-10-on-imac http://feedback.photoshop.com/photoshop_family/topics/problems-with-photoshop-cs5-after-in it seems that the update of the OS is corrupt PS CS5 if it was installed before the upgrade to Yosemite. Let me know if that will fix it for you.

    With the permission of Jeffrey Tranberry

  • How to update the table when change list item in the classic report

    Hello
    I worked with apex 4.2 and I create normal classic report with list (named loved) select a column, now I want to update the table when the user changes the list with the new value, I can't create a dynamic action to do this, I create checkbox with the primary key and the loop for check point to update the table but I can not get the value of the list item. and for more speed, the user want to do it when changing the value from the list.

    My question
    1. how to do it in javascript and get the value of the list item and update the table with the new value
    2. do I have to use the API to create the list item so I can get the value of the report item or what.





    Thank you

    Ahmed

    You can find a lot of information in this forum (and outside in google) when you search for AJAX processes and demand. However, the tutorial in the link below should be useful:
    http://www.Oracle.com/WebFolder/technetwork/tutorials/OBE/DB/hol08/apexweb20/ajax_otn.htm

    BTW, if we answer your question, don't forget to mark the appropriate post as correct. It will help all of us in the forum.

Maybe you are looking for

  • 4385 all in one

    Finally, I thought that my installation problems are a thing of the past, as I have tried 3 printers, install a lot of software cd.  Now I find a copy of the 4385 in the Printers folder and it wants to be the default printer, but has no path in the p

  • Deleting email

    After adding my pop account, I can't delete or find a way to delete the read messages. Any ideas?

  • get the 641 and 80070641 error code during the installation of Windows updates

    Original title : not able to have windows updates installed on the pc have vista and get code error 641 and 80070641 - what it means and how can I solve this problem please? Not able to install updates windows for my pc with the vista system. I keep

  • Error every time I try to add an MP3 song to Movie Maker, I bought from Amazon.

    I try to add a song to a movie maker slideshow.  Whenever I have add the song, the program crashes and says that I can't see a preview.  How can I add an MP3 song, I bought from Amazon.  I use Windows 7.  Thank you

  • Vista will not connect to WiFi automatically (but my iPhone works well!)

    After re-installing Vista window by the backup of my laptop LG drive, it is now impossible to automatically connect to the WiFi at home. Every time when I start the laptop (even of mode "sleep"), the network went & I have to choose WiFi home network