massive many update column of the cursor?

I have the problem of finding how to make an update of several columns using the update statement block (if possible). I know how to do it using merge or correleated update, I just want to know how to write using features in bulk by pl/sql. Here's the code for the sample tables:
create table emp_tmp as select empno, job, sal, comm from emp where deptno = 30;
update emp_tmp set sal=1000, comm=200, job='CLERK';
commit;
Now, I want to update original emp table with job, sal, comm emp_tmp table for some empnos. So I write:
declare
  cursor c is ( select e.empno, t.job, t.sal, t.comm
                from emp e, emp_tmp t
                where e.empno = t.empno
                and e.empno > 7700 );
begin
  -- ... here I would like to use bulk feature for update statement on emp
end;
I can't understand the syntax above idea in bulk using statements. Could you give me some advice about this? How it should be written?

Thank you

A sample:

declare
  cursor csr is ( select t.empno, t.job, t.sal, t.comm
                from emp_tmp t
                where t.empno > 7700 );
 type t_emp is table of csr%rowtype;
 t_emp1 t_emp;
begin
  open csr;
  loop
    fetch csr bulk collect into t_emp1 limit 100;
    forall i in 1..t_emp1.count
      update emp
      set sal = t_emp1(i).sal
      where empno = t_emp1(i).empno;
    exit when csr%notfound;
  end loop;
  close csr;
end;

Tags: Database

Similar Questions

  • email accounts + updated column on the page of the options not available

    Hello, sorry to ask this, but I can't find a similar problem on the community forum:

    I tried to change the look of my Thunderbird and switched in Vertical mode, now all the options in the view > page layout are empty, no way to change it back...

    Second question: while I was managing the columns in layout with the cursor, the one on the left with all accounts, now gone, there seems to be no way to recover it. It appears when I run Thunderbird for a fraction of a second, then nothing.

    I even removed Thunderbird and installed it again, but it opens with the same layout.

    Is there anyway that I can change to the default layout?

    Thanks for any help.

    Are you using a Add ons? If so restart with Add ons disabled in order to see if it works better. Helps in the menu.

  • You will need to insert update column with the username?

    Hi all

    I'm new to this forum of the apex. New to apex as well.

    My question is do we have a form and a single column is editable by the user. whenever an update to this column, I need to write their name in the update column.

    I heard that we can do with trigger using the variable app_user. But in our project, they made authentication ldap for this form and when an employee login with their company login id they can see only this form of apex. no other option.

    In the same form, they were able to show the user name. I checked how they did it. they used * & user * variable for this. , It makes sense for you gentlemen?

    all I have to do is insert this & user in the column value.

    How to do this. I'm started working in the apex for the past four days alone. willing to bare with me if im a very stupid question.

    Thank you
    knani

    PS: I know that what im asking is the user name for the Web page the user name of the apex.

    Published by: kart on May 26, 2010 11:45

    Hello

    You can use: APP_USER substitution string.
    If you like to use that in the syntax of database trigger is v('APP_USER') for example

    :NEW.CHANGED_BY := NVL(v('APP_USER'), user);
    

    BR, Jari

  • Extract a column of the cursor to type set

    Hello
    I have a procedure that returns a complex cursor (all columns are known) - I need to enter my type defined a single column of a cursor (number table - I use it later in the SQL statement) - what is the best way to get it? Or is it possible to use received cursor (column) directly in sql? (I would avoid if possible iteration)
    Concerning
    BartlomiejD

    How can I load m_cCursor in retNA (TNUMBERARRAY) colNum?

    Here's a simple way

    SQL>  CREATE OR REPLACE PACKAGE pkg
    AS
       TYPE tcursor IS REF CURSOR;
    
       TYPE tnumberarray IS TABLE OF NUMBER;
    
       PROCEDURE retcursor (retcursor OUT tcursor);
    
       PROCEDURE retnumberarray (retna IN OUT tnumberarray);
    END pkg;
    /
    Package created.
    
    SQL>  CREATE OR REPLACE PACKAGE BODY pkg
    AS
       PROCEDURE retcursor (retcursor OUT tcursor)
       AS
       BEGIN
          OPEN retcursor FOR
                 SELECT 'A' cola, 'B' colb, 'C' colc,
                        CURRENT_TIMESTAMP cold, LEVEL colnum
                   FROM DUAL
             CONNECT BY LEVEL <= 20;
       END retcursor;
    
       PROCEDURE retnumberarray (retna IN OUT tnumberarray)
       AS
          m_ccursor   tcursor;
       BEGIN
          retcursor (m_ccursor);
    
          SELECT x.COLUMN_VALUE.EXTRACT ('ROW/COLNUM/text()').getnumberval ()
            BULK COLLECT
            INTO retna
            FROM table (XMLSEQUENCE (m_ccursor)) x;
    
          FOR i IN 1 .. retna.COUNT
          LOOP
             dbms_output.put_line (retna (i));
          END LOOP;
       /*
    
       How Can I load colNum from m_cCursor into retNA(TNUMBERARRAY)?
    
       I would like to use it later in statment like
       Select * from SOMETABLE ST, Table(retNA) NA
       WHERE ST.ID = NA.ID and ...
    
       */
    
       END retnumberarray;
    END pkg;
    /
    Package body created.
    
    SQL>  DECLARE
       x   pkg.tnumberarray;
    BEGIN
       pkg.retnumberarray (x);
    END;
    /
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    PL/SQL procedure successfully completed.
    

    I would use it later in the statement as
    Select * from SOMETABLE ST, Table (retNA) NA
    WHERE ST.ID = NA.ID and...

    Beware that you cannot SELECT collections defined in PLSQL. You must set them in SQL ;)

  • Procedure cannot be updated by using the cursor and loop

    Hi all

    I am creating the procedure below to update some columns, but when I try to start nothing happens, what I want, is that some data in table2 are updated.

    Help, please. Thank you.

       v_from            NVARCHAR2 (30);
       v_to              NVARCHAR2 (30);
       v_date            DATE;
       v_id         INT;
       v_id1        INT;
       v_id2        INT;
       
    CURSOR cur_a is
        SELECT from, to, startdt, pid FROM table1
            WHERE rownum <= 100
            ORDER BY startdt;
    
    
    BEGIN
    
    
    OPEN cur_a;
    
    
    LOOP
    
    
    FETCH cur_a into v_from, v_to, v_date, v_id;
    
    
    EXIT WHEN cur_a%NOTFOUND;
    
    
    BEGIN
    SELECT pid 
    INTO v_id1
    FROM
        (
            SELECT pid FROM table2
            WHERE (from = v_from OR to = v_from)
            AND startdt < v_date
            ORDER BY startdt DESC
        )
        WHERE rownum = 1;
    EXCEPTION
          WHEN no_data_found 
          THEN
            v_id1 := null;
    END;
    
    
    BEGIN
    SELECT pid
    INTO v_id2
    FROM
        (
            SELECT pid FROM table2
            WHERE (from = v_to OR to = v_to)
            AND startdt < v_date
            ORDER BY startdt DESC
        )
        WHERE rownum = 1;
    EXCEPTION
          WHEN no_data_found 
          THEN
            v_id2 := null;
    END;
        
    UPDATE table2
    SET trx1 = v_id1, trx2 = v_id2
    where pid = v_id;
    
    
    END LOOP;
    
    
    CLOSE cur_a;
    
    
    END;
    /
    

    You don't need a PL/SQL procedure to do this, you can do it in SQL:

    MERGE INTO table2 t2 USING

    (SELECT t1.pid,

    Max (TF. PID) KEEP (DENSE_RANK LAST ORDER BY tf.startdt) trx1,.

    Max (TT. PID) KEEP (DENSE_RANK LAST ORDER BY tt.startdt) trx2

    FROM table1 t1

    LEFT OUTER JOIN table2 tf

    WE (tf.from = t1.from OR tf.to = t1.from)

    AND tf.startdt<>

    LEFT OUTER JOIN table2 tt

    WE (tt.from = t1.to OR tt.to = t1.to)

    AND tt.startdt<>

    WHERE rownum<=>

    GROUP BY t1.pid) x

    WE (x.pid = t2.pid)

    WHEN MATCHED THEN UPDATE

    SET t2.trx1 = x.trx1,

    T2. TRX2 = x.trx2

  • How to update columns with the value of other lines in the same table

    Hello

    I use Oracle 11.2, I'd use SQL statements to update a column based on values in other rows in the same table. Here are the details:

    create table TB_test (number 4 myId, crtTs date, date of MDPU);

    insert into tb_test (1, to_date ('20110101', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110201', 'YYYYMMDD'), null);
    insert into tb_test (1, to_date ('20110301', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110901', 'YYYYMMDD'), null);
    insert into tb_test (2, to_date ('20110902', 'YYYYMMDD'), null);

    After you run the SQL code, I would like to have the following result:

    1, 20110101, 20110201
    1, 20110201, 20110301
    1, 20110301, null
    2, 20110901, 20110902
    2, 20110902, null

    Thanks for your suggestion.

    I guess you need this, otherwise please explain logic correctly:

    SQL> merge into tb_test t
      2  using (
      3    select rowid as rid
      4         , lead(crtts) over(partition by myid order by crtts) as updts
      5    from tb_test
      6  ) v
      7  on (t.rowid = v.rid)
      8  when matched then update
      9   set t.updts = v.updts
     10  ;
    
    5 rows merged.
    
    SQL> select * from tb_test order by 1,2;
    
          MYID CRTTS     UPDTS
    ---------- --------- ---------
             1 01-JAN-11 01-FEB-11
             1 01-FEB-11 01-MAR-11
             1 01-MAR-11
             2 01-SEP-11 02-SEP-11
             2 02-SEP-11
    
  • Updating column in the table using forms...

    Well Guyz I got my submission today... everything went well... .but yet they want to add IE more features want to donate this application at different times working in the company on different projects... .initailly told me that u have to create this application for just our project, now they use my work to give to other PMsss:(et prendre tout le crédit avec aucun faisait pour moi u n personnes m'a beaucoup aidé dans la construction de cette application...) Well, they want to create an application where they can change some columns... that is to say over write the existing value in a column with a new value.
    Now, suppose I have col1, col2 in the table paymast, how should I proceed to create trigger for when I press the button on the form is updated to the number of given employee (I want to say if enter the respective information for the particular EMP as soon as I press the button the old values shud b replaced by new values...)

    A method that I have noe is to use the wizard to create the form n, and then enter the value of the respective areas of the column to be updated n, then press F6 DB... .i do not want to use this function...

    I want to update the application by pressing the button

    soon :)

    Published by: Chase Suhail on Nov 15, 2009 12:26 AM

    Published by: Chase Suhail on Nov 15, 2009 12:29 AM

    Published by: Chase Suhail on Nov 15, 2009 12:30 AM

    Published by: Chase Suhail on 15 Nov 2009 02:05

    I don't know a lot of your application, but if you build it near standard forms (e.g. base your blocks on the tables), then its standard Frédérique you type the new value in the field and press save. the button... do you want to the "economy"? then put a DO_KEY ('COMMIT_FORM'); in it.

  • update columns in the return clause

    Hi gurus

    Need your new for my purpose of learning. I have the sample data.

    Examples of data

    DROP TABLE plch_parts;

    CREATE TABLE plch_parts

    (

    partNum NUMBER,

    partName VARCHAR2 (100),

    changed_on DATE

    );

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

    Insertion

    BEGIN
    INSERT INTO plch_parts (partnum, partname)
    VALUES (1, 'handle');

    INSERT INTO plch_parts (partnum, partname)
    VALUES (100, 'hinge');

    INSERT INTO plch_parts (partnum, partname)
    VALUES (500, 'lock');

    COMMIT;
    END;

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

    DECLARE

    TYPE parts_t

    IS

    RECORD

    (

    partNum NUMBER,

    partName VARCHAR2 (100));

    l_part parts_t;

    BEGIN

    UPDATE plch_parts

    PartName SET = UPPER (partname)

    -WHERE partnum = 1

    RETURN partnum,

    partName

    IN l_part;

    Dbms_output.put_line (' Changed: ' | l_part.partnum |) '-' || l_part.PartName);

    END;

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

    Error

    ORA-01422: exact fetch returns more than number of lines

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

    I know the above code to support only 1 sheet update, my question is that how to I print records of all updates, I tried to use bulk collect with return clause but as Miss me something.

    Please guide.

    Concerning

    Shu

    set serveroutput on size 2000
    declare
      --
      type parts_record is record (
        partnum  number,
        partname varchar2(100)
      );
      --
      type parts_table is table of parts_record index by pls_integer;
      changed_parts parts_table;
    begin
      --
      update plch_parts set partname  = upper (partname)
      returning partnum, partname bulk collect into changed_parts;
      --
      for i in changed_parts.first .. changed_parts.last
      loop
        dbms_output.put_line('Changed #' || changed_parts(i).partnum || ': ' || changed_parts(i).partname);
      end loop;
    end;
    /
    
    anonymous block completed
    Changed #1: DOORKNOB
    Changed #100: HINGE
    Changed #500: LOCK
    

    Please read http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005

  • See the column position of the cursor in the code view

    I realized this was requested in 2008...

    Is there a way to display the character column where the cursor was when in code view? And consider the size of the tabs (i.e., counts tabs as the number of characters)? I'm trying to make sure align various blocks of code in classic asp massively complex (and ugly) code...

    Thank you.

    The current version of Dreamweaver does not display the column number. However, the media don't.

    In parentheses is a free, open-source editor created by Adobe. It was announced last year that consoles will be integrated in the next major release of Dreamweaver, and that a public beta would be released sometime this year. You can either wait that the public beta version (should be pretty quickly), or you can download media immediately.

  • Check the syntax of the cursor

    Hi all,

    I'm no expert of PL/SQL. I have to do an update to a table using a cursor.
    I saw a guide on the internet and I have created this script:

    Set serveroutput on
    DECLARE
    REC NŒUD$ % ROWTYPE;
    cursor cur is select ID, NODE_ID OF THE NŒUD$;

    BEGIN
    Open the heart;
    loop
    News of FETCH in rec;
    When the output cur % NOTFOUND;
    UPDATE LINK$ SET a.END_NODE_ID = rec. Node_id WHERE a.T_JNCTID = rec.ID;
    dbms_output.put_line ('update 1': cur % ROWCOUNT);
    UPDATE LINK$ SET a.START_NODE_ID = rec. Node_id WHERE a.F_JNCTID = rec.ID;
    dbms_output.put_line ('update 2': cur % ROWCOUNT);
    end loop;
    close cur;
    end;
    /
    Set serveroutput off
    commit;

    I'm not sure that the bold line is correct. I don't understand what that means.
    Can you help me?

    Thank you in advance.

    Because the fetch statement fails when you try to store the cursor file in CDR which is ROWTYPE table NŒUD$.
    The number of columns in the ROWTYPE variable must be equal to the number of columns in the CURSOR. So if the NŒUD$ table has more than two columns your extraction will fail.

    See the example below:

    SQL> declare
      2  my_tab emp%rowtype;
      3  cursor c1 is select empid from emp; -- I select only one column here and it fails
      4  begin
      5  open c1;
      6  fetch c1 into my_tab;
      7  close c1;
      8  end;
      9  /
    fetch c1 into my_tab;
    *
    ERROR at line 6:
    ORA-06550: line 6, column 1:
    PLS-00394: wrong number of values in the INTO list of a FETCH statement
    ORA-06550: line 6, column 1:
    PL/SQL: SQL Statement ignored
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2  my_tab emp%rowtype;
      3  cursor c1 is select * from emp; -- I select all columns from emp table and it works fine
      4  begin
      5  open c1;
      6  fetch c1 into my_tab;
      7  close c1;
      8* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    Published by: AP on Oct 14, 2010 03:54

  • Windows Update crashes during the installation of update

    I was recently asked to restart my laptop (under Vista Home Premium) because Windows downloaded updates. I cut and updates began to install. The computer is now fixed as "Installing update 4 of 9» It has been more than an hour on the update 4 with the cursor turns but no progress.

    Any help would be greatly appreciated.

    Hi Charles1973a,

    1. what update has recently been installed on the computer?

    2. you receive an error message?

    3. do you have a security software on the computer?

     

    First, restart the computer and try to install the update one by one.

    See the Microsoft article below as well as try the steps mentioned so that you cannot start Windows after you restart the computer, check if it helps.

    The update is not installed successfully, you receive a message, and the computer restarts when you try to install an update in Windows Vista and Windows 7

    http://support.Microsoft.com/kb/949358

    I hope this helps!

    Halima S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • updating columns by using variables substitiution dataform

    Hi all

    I would like to know if there is any chance to update columns in the form of data using proxy.
    As if I need to create a form of data from jan to & currmonth. (June), so changing the value subvar say August, I'll be able to get the columns dynamically in the change of form of data until August. ?

    Thank you

    Hi, yes you can create a hierarchy of alternative for periods. For more information, see rolling forecast Web Form

    You can then use the descendants function of your other rollups

    Another way to define your period as sparse. Periods a link to an attribute fades with 1... 12 for the month and try to use fewer function selector Member dataform

    As you can see, none of them is easy

  • Position the cursor after update of String

    Hello

    I'd like to update a string by clicking on a button, which then concatenates the string existing with another, and then the cursor key move until the end of the string to update once it is brought into the home.

    Example;

    I have the existing with the cursor key string abcd as follows - abcd | When I click on the button 'a' I want abcda | No abcd | where ' |' represents the position of the cursor keys.  On another note, I do not want to have the added string pointed out, I am aware of how to y to achieve.

    I searched for the answer to this but I can not find it.

    Thank you.

    LabVIEW 8.5, if possible.  See you soon.

    It's a little complicated because it is not a specific property "cursor position. You need to get the length of the string and use the selection-> start-> end properties. You set them both to the same (length of string)

  • Windows Update shield on the Board keeps telling me to update, KB2656370 & KB2656353 try many time to update installed.

    Windows Update shield on the Board keeps telling me to update, KB2656370 & KB2656353 try many times to insyalled update.

    Tried to solve this LOL. This situation is only 2 or 3 DATS, old and looking at Google 3 days, that looks like an epidemic problem.

    Microsoft is so difficult to talk to a real person to help out you.

    Hello

    -Who 'Fix it' did you evoking?

    Follow the steps in this article and check if this problem persists.

    Troubleshooting Windows Update or Microsoft Update when you are repeatedly offered an update
    http://support.Microsoft.com/kb/910339

  • How to dynamically update the Position of the cursor?

    I have this Slider element:

    
    

    Sometimes I need to change the value for the user when they enter its screen. The way I do it is as follows:

    document.getElementById("slider").value = sliderValue;
    

    However, the cursor remains on the value 250. Although if I connect its value (console.log (document.getElementById("slider").value);), it shows that the value updated, but the UI is not updated or something. What should I do to solve this problem!

    The function that updates the slider is drawn to: ondomready: function (element, id, params) {...} to bb.init)

    Also, I am trying to manually change the Javascript Console of Chrome value, but this element is null. I guess it's because the ripple of load it as an iFrame internal? Any way to directly access these items in the Console?

    I don't know if it's similar, but I am facing a problem with a checkbox so where document.getElementById('myCheckBox').checked always returns false regarless of the State of the box! It makes me crazy!

    Are you using bbUI.js?  If so, it adds a setValue() function elements slider that "allows value to set and apply visual style."

    https://github.com/BlackBerry/bbUI.js/wiki/sliders

    You can see how this framework is hair of the range element dynamically looking at his source code on Github:

    https://github.com/BlackBerry/bbUI.js/BLOB/master/samples/BBUI.js#L8046-L8069

Maybe you are looking for