Best way to update a table with separate values

Hi, I would really appreciate some advise:

I need to regularly perform a task where I update 1 table with all the new data that has been entered in another table. I cannot perform a complete insert because this will create data duplicated each time it works, so the only way I can think of is the use of cursors in the script below:


CREATE OR REPLACE PROCEDURE update_new_mem IS
tmpVar NUMBER;

CURSOR c_mem IS
SELECT nom_membre, member_id
OF gym.members;
CREC c_mem % ROWTYPE;


BEGIN
OPEN c_mem.
LOOP
SEEK c_mem INTO crec;
EXIT WHEN c_mem % NOTFOUND;
BEGIN
UPDATE gym.lifts
Name = crec.member_name
WHERE member_id = crec.member_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
IF SQL % NOTFOUND THEN
BEGIN
INSERT INTO gym.lifts
(name, member_id)
VALUES (crec.member_name, crec.member_id);
END;
END IF;
END LOOP;
CLOSE C_mem;

END update_new_mem;



This method works, but y at - it a (faster) easier way to update another table with new data only?

Thank you very much

>
This method works, but y at - it a (faster) easier way to update another table with new data only?
>
Almost anything would be better than this treatment of slow-by-slow loop.

You don't need a procedure, you should just use MERGE for this. See the examples in the section of the MERGER of the doc of the SQL language
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htm

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
     DELETE WHERE (S.salary > 8000)
   WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
     VALUES (S.employee_id, S.salary*.01)
     WHERE (S.salary <= 8000);

Tags: Database

Similar Questions

  • BlackBerry Smartphones getting a new torch, best way to update people with my PIN?

    I just got a new torch, my old one was broken!  What is the best way to update my contacts with my new PIN?  What I do need to update or will they automatically updated?  Please notify

    Ash

    If you have a backup, you can restore the BBM part backup files or e-mail and broadcast a message to all.

  • Update of table with invalid identifiers

    Hello!

    I use a third-party plug-in and that comparisons of chemical structures. I want to update a table with the values of the other when the plugin matches two rows. However, I'm a problem invalid identifier.

    Two tables:
    PLATES: a VARCHAR2 columns of PLATE_SMILES, IN_DB
    INVEST: a VARCHAR2 columns of SMILES

    The operator is a binary: jc_compare (PLATE_SMILES, SMILES) = 1 (or 0 if they do not match)

    I want my query to say: "If comparison SMILES, PLATE_SMILES = 1, define IN_DB = 1 for row" - effectively asking if PLATE_SMILES exists in the table INVEST.

    I tried a number of "renditions", all identifiers not valid donations. Here is an example:

    Update (select plate. PLATE_SMILES, plate. IN_DB, invest. SMILES
    plate PLATES
    INVEST invest
    WHERE jc_compare (PLATE_SMILES, SMILES) = 1)
    set plate. IN_DB = 1;


    ORA-00904: "FLAT". "" IN_DB ": invalid identifier


    I hope that this should be an easy fix, and any help is greatly appreciated!

    Hello

    You have

    UPDATE (SELECT plate.plate_smiles,
                   plate.in_db,
                   invest.smiles
            FROM   plates plate, invest invest
            WHERE  jc_compare ( plate_smiles, smiles) = 1)
    SET    plate.in_db = 1;   -- Error here
    

    PLATE is not known outside the display online. Just remove it.

    Concerning
    Peter

  • Best way to update the individual rows of a Table?

    I took a quick glance at a few examples, but did not get a clarification on this.  I am looking to have something close to a listbox control or the table to where I can update just one column of values to line a 1 time per second pace.  I'm looking to display our acquisition of data values in a table or a listbox control.  The single list box seemed to work well for that, but I couldn't use the row headers to list the names of channel beside the channel values.  I thought to link the values of cursor in two areas of list to do this, but did not find any info on it for the single list box.

    I have a few questions:

    (1) I have a 1 d table to where I want to use this data to constantly update the first column (with a multitude of lines) of a table.  I'm looking for the best route to not take too much time for treatment by doing this.

    What is the best way to update the individual rows of a table?   Invoke the node "Value of the cell value"... or is there another method?

    (2) why is that, after each iteration else, row values are deleted?

    Also, for adding additional channels originally arrray... it is better to use the 'Array' subset then the function "Construct the table" or function "Subset of the table" and "insert table"?

    See the attached example.

    Thank you.

    Jeff· Þ· Bohrer says:

    (2) why is that, after each iteration else, row values are deleted?

    Classic race condition.  dump the loop and node-p and just wire the 2D table on the terminal Board. !

    I don't see the race condition.  What I see is the table once the last element has been written for it all run the oil.  I saw looked it with point culminating performance on.

    But I agree entirely with writing to the Terminal.  It is a 1 d array, so you will need to use an array of generation and convert a 2D array in order so that he could write correctly.

  • Best way to update GUI

    Hi, I have a class of "business model" that contains all of my variables that are displayed on my GUI which is a separate category. As these variables change very frequently during execution of the program I need some advice on the best way to update my GUI as needed. I use a controller with actionListeners to cope with the changes in the opposite direction. Then I can manipulate the this approach based on my needs or should I implement Observable I read somewhere else?

    I don't see why not. But it depends on how abstract you want to get.

    Remember that an "event" is simply the source calling a method specified in advance of the target. In other words, there is a framework in order to hide the details, but in the end, it is simply the JButton calling the actionPerformed method in your controller.

    If even you can configure the controller with some methods specified in advance, cause the GUI change somehow and the model call these methods pré-spécifié whenever it was necessary. It would be the easiest way.

    But notice that in your interactions view controller, the controller is really interacting with a variety of components from the view. Maybe your model is broken down into a number of components also, and perhaps it would be beneficial for the controller to directly interact with these components. In this case you might want to formalize these interactions, possibly using the observer model events.

  • What is the best way to refresh the table after autosubmit (10.1.3.4)

    What is the best way to refresh the table after autosubmit?

    I have a page that contains a table where if one of the fields is changed it autosubmitted where the view object changes some attributes, based on the field having been changed. I need these modified attributes that appear in the table. But without doing anything, the only way to see these values is to cause the iterator updated table.

    I've been refreshing the table is having a method in a grain of beacking called "getSystemSettingIter.getCurrentRow ();". This seems to be a bit of a hack for me and I was wondering if there is a better way to get the table to update.

    Thanks in advance!

    Have you tried setting between the two partial page refresh?
    http://www.Oracle.com/pls/as111120/lookup?ID=ADFUI385

    http://download.Oracle.com/docs/CD/E15523_01/Web.1111/b31974/web_form.htm#CACEIEEI

  • What is the best way to update coming 8 Pro?

    I'm a little confused about the best way to update my V8P. The app My Dell seems to be looking for updates, but it is also linked to a page on the Dell site that checks the latest downloads for the device. The link is provided through the tile from drivers and downloads . This page of the Web site, incidentally, trying to install a program to check my V8P, but the facility apparently never works. I always get an error message that says (and I entered here exactly as it appears, the police blue and all):

    "We're sorry, we were able to scan your system. "Please return to the drivers home to return to.

    Because of the link to the site I don't know if My Dell app is all I need. The app has an area of notification, which seems to be to talk about new drivers and such available, although drivers and downloads of tiles wonder is if there is more, I might have need. Why have the drivers and downloads of tiles if the application checks and warns me on drivers and downloads?

    Bottom line, is that I'm confused. So, what is the best way to ensure that my V8P is up-to-date?

    Manually, I downloaded and installed Dell system detect. After doing this I have re-tried the system analyze the updates of the Web page and it worked. I now have a lot of updates available.

  • AS3 best way to clear a table

    What is the best way to clear a table? (performance and resources)

    Array.Length = 0;

    array = [];

    array.splice(0);


    Array.Length = 0;

  • Update of table with 14 million records

    good day, I'm updating a table with 14 million documents column. using the data from another table.
    This takes terrible time just updated to 500,000 over the weekend, which is unacceptable.
    ideas to improve my code and get the fastest update is much appreciated.

    DECLARE
    TYPE vc_type is table of index varchar2 (20) by pls_integer;
    type tabtype_rowid is table of pls_integer rowid indexes;
    my_cur sys_refcursor;
    cur_limit integer: = 10000;

    tab_rowid tabtype_rowid;

    Start
    OPEN FOR My_cur
    SELECT value, rowid
    TABLE 1A

    where the value IS NOT NULL
    and id is null;


    loop
    collect the fetch my_cur in bulk in tab_value, cur_limit limit tab_rowid;

    FORALL k IN 1.tab_npi.count

    UPDATE table 1A
    A.ID = (select id SET
    in Table 2b
    where value = tab_value (k)
    and rownum = 1
    )
    WHERE a.rowid = tab_rowid (k);

    COMMIT;

    When the output tab_value.count < cur_limit;.
    end loop;

    END;


    Thank you

    903537 wrote:
    I tried to update basic training, as a first step and it crashed...

    He didn't fail, it failed.

  • What is the best way for a J2EE developer with oracle?

    Hello

    I am a J2EE developer, for the moment I'm working in a commercial bank as an enterprise application developer. Java, I learned when I was following a degree of local COMPUTER and with the help of books, work at my place of work and the internet, today I develop applications with JSP, Servlets, JSF2.0, EJB3.0 and third-party J2EE part libraries JSF etc (I also develop software using other programming languages such as Asp.net, c# .net, etc. WPF, but I prefer to be in the path of java). Other than that, I also work as the designer of the user interface of most of our applications.

    I have the skills and practice after having worked for 4 years as a developer of web/enterprise applications & UI designer, but now I have to focus on some grades of paper and so I do BCS.

    Now, I want to be a professional in the Oracle java path, and I need to know what is the best way, I choose to go with Oracle. I finished my SCJP courses, but did not take the exams, because there were rumors that Oracle will clear these reviews in the future. I am interested in Oracle university, but I'm unable to even think about it as I live in Sri Lanka and is not only a large part of the wealth to go to the USA and join.

    So I really appreciate if any professional Oracle could suggest me the best educational path based on what I mentioned about my technical and professional training. Because I have a dream to join Oracle a day as an employee and be a good contributor on the same forum, which I get help today!

    :-)

    Thank you!!!

    As you can see on our Web site, Oracle did not retire Java certifications. You can browse through the available certifications and I hope to help determine your path.
    http://education.Oracle.com/pls/web_prod-PLQ-dad/db_pages.GetPage?page_id=140

    SCJP became Oracle Certified Professional Java Programmer. You can find more information on these reviews on our site here: http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=320.

    Concerning training, virtual training live might be an option for you. You can find more information at http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=233.

    Kind regards
    Brandye Barrington
    Certification Forum Moderator

  • How to build a list or a table with fixed values?

    Is it possible to create a list or a table with fixed values, but with a variable length?

    for example:

    var columns = "name, age, function;

    var insertParams = generateList ( listLen (columns), ',','.) » ); *

    fact: insertParams = ',?,??


    * (this function does not exist. This is just to illustrate what I need)

    I know that this feature is easily created by creating a loop, but I was wondering if it was possible with a single line of code.

    Thank you

    If he can generate a table in the same way, which would be as well.

    Our messages have clashed. But I think that repeatString() would do the trick. You could cut the rear comma with left() or convert it to a table. By default, ListToArray() will silently ignore the trailing comma.

  • Fill the table with random values

    Another thing I've come across is this:
    the table name is LOR, who has 3 fields NUMBER, DATA, TEXT with number, date and varchar2 data type.
    On a page, I have a text field where if I write 3, then it would add 3 lines to the table with predefined values ("number, something like 2222, for 12 January 09, and for text, something like" Lorem ipsum dolor sit amet, 195kgs adipisicing elit"). So basically, with the number that I give, it populates the table with lines... How can I do this? Thanks for helping me
    INSERT INTO LOR
    SELECT 222
    , sysdate
    , 'you string'
    FROM dual
    CONNECT BY level <= :Pxx_
    
  • Best way to update table attribute with one value calculated from another table JDeveloper

    I have a simple chart. Payment: Payment_Product = Master: detail.

    So first of all, I have to insert in payment, then in Payment_Product. TotalSum default value is null. After validation, I want TotalSum must be calculated according to Product.Price and Payment_Product.Quantity.

    What is the best way to do this in JDeveloper (12.1)?

    payment_product.jpg

    The best way to do that will not do.

    Don't store calculates the basic values unless you have checked, it improves the speed. Otherwise, this will cause almost always more trublen that she enjoys.

    Calculate this total when you do the report. At this point, you have several aggregate function build SQL where sum() is one of them...

    Good bye

    DPT

  • Best way to update all the lines of a huge table

    Hi all

    I'm on Oracle 11.2 Enterprise edition.

    I asked a question, "assumes that there is a large table, say 3 GB size.» We need to update all rows in this table (e.g. col3 = col3 * 2), what is the best way to do this? »

    My answer was, there are 2 possible ways, depending on the number of indexes on the table

    (1) if there is a lot (or wholesale) index on the table OR the database is in FORCE LOGGING mode (due to log shipping), I just run an UPDATE command on the table and update all records. This will generate a lot of redo and undo, but we cannot do anything for indexes

    (2) if there is not a lot of clues, I'll create an empty table of the same structure (create table t2 nologging in select * from t1 where 1 = 2). Then, using an INSERT... AS SELECT... command, with the ' col3 * 2 "instead of col3, I insert any data into the new table with APPEND tip. Then create all indexes on the new table and finally, rename T2 T1

    In case the first solution, I can avoid the recreation of the index and save this I/O. In the case of newspapers, first solution makes more sense anyway.

    Second solution is logical, if we have the freedom of creating objects in NOLOGGING mode.

    What do you experts? I think in the right direction? or what?

    Thanks in advance

    Hello

    This should probably help you.

    Kind regards

    Suntrupth

  • Best way to update an OLTP table?

    Hello
    We have an OLTP table with huge data.
    We need to update a column of the status of "n" 'Y' for nearly 70% of the rows based on certain conditions.
    This table is accessed by hundreds of sessions at a time.
    So, what is the best way to do the same.

    Rgds,
    ORS

    Then, find some interruptions of service and do the update...
    or simply do it. It might take awhile, but if to do... to do.

Maybe you are looking for

  • Qosmio F20 speakers making hissing noise

    Hello My Qosmio F20 has a strange problem. After turning on the laptop, the speakers start making a whistling noise. You can clearly hear it all the time. Toshiba has just replaced the motherboard but tis whistle is still there. Is it normal for the

  • Placement of module problem

    Why, without real reason, sometimes modules not go where you want them to go on the worksheet?  Its like there is an invisible module there and can be placed here.  I find it rather annoying that I am trying to clean up a spreadsheet... Thanks for an

  • I can't open regional and language option

    Hi, I can't open regional and language option and and when I turn on any program I have to press fn and ctrl 4 times to set lathin letters, what can I do?

  • How to restore a theme that has been accidentally deleted?

    XP - I accidentally hit apply in the control panel-> display and my photo theme and background got changed - how do I restore it?  Where these files are stored on the hard drive? G

  • Mouse Microsoft bluetooth arc (grey), questions about the reconnection

    Hi all I recently bought mouse arc Microsoft Bluetooth (new ERM one) to use with mobile society. I have a Lenovo T430s laptop, with windows 7 Professional. I have properly matched and works very well, however, when I turn off the mouse, when I turn o