Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

update in bulk

Tony007Nov 14 2019 — edited Nov 14 2019

hi how can i update records within one am having 6 million records to update, i try this am in 12c database

DECLARE

       c_limit PLS_INTEGER := 100;

       CURSOR employees_cur

       IS

          SELECT employee_id

            FROM employees

           WHERE department_id = department_id_in;

       TYPE employee_ids_t IS TABLE OF  employees.employee_id%TYPE;

       l_employee_ids   employee_ids_t;

    BEGIN

       OPEN employees_cur;

       LOOP

          FETCH employees_cur

          BULK COLLECT INTO l_employee_ids

          LIMIT c_limit;      -- This will make sure that every iteration has 100 records selected

          EXIT WHEN l_employee_ids.COUNT = 0;          

        FORALL indx IN 1 .. l_employee_ids.COUNT SAVE EXCEPTIONS

          UPDATE employees emp  -- Updating 100 records at 1 go.

             SET emp.salary =

                    emp.salary + emp.salary * increase_pct_in

           WHERE emp.employee_id = l_employee_ids(indx);

commit;

FORALL indx IN 1 .. l_employee_ids.COUNT SAVE EXCEPTIONS

UPDATE employees_details emp  -- Updating 100 records at 1 go.

             SET emp.salary =

                    emp.salary + emp.salary * increase_pct_in

           WHERE emp.employee_id = l_employee_ids(indx);

      commit;   

      END LOOP;

    EXCEPTION

       WHEN OTHERS

       THEN

          IF SQLCODE = -24381

          THEN

             FOR indx IN 1 .. SQL%BULK_EXCEPTIONS.COUNT

             LOOP

                 -- Caputring errors occured during update

                DBMS_OUTPUT.put_line (

                      SQL%BULK_EXCEPTIONS (indx).ERROR_INDEX

                   || ‘: ‘

                   || SQL%BULK_EXCEPTIONS (indx).ERROR_CODE);

                 --<You can inset the error records to a table here>

             END LOOP;

          ELSE

             RAISE;

          END IF;

    END;

Comments

Shay Shmeltzer-Oracle

Also check the JDev project properties for the setting in the compiler section.

Kareem Wahba

thanks for your reply , i do that but it's not working

SanjeevChauhan

I think at runtime also your weblogic (jvm) should support UTF-8. Can you please set utf-8 encoding for JVM by modifying setDomainEnv.sh/setDomainEnv.cmd file present in you domain/bin directory.

You may need to add JAVA_OPTIONS="$JAVA_OPTIONS -Dfile.encoding=utf8"  in that file.


Thanks

Sanjeev

Kareem Wahba

thanks for your reply ... i searched for that file but i didn't find it

C:\Oracle\keemm\Middleware\Oracle_Home\wlserver\server\bin

is this the right path ?!

SanjeevChauhan

No. You need to check your domain location. If you are using Jdev to run application then domain will be under system directory. It is generally (if not changed by environment variable) is located under C:\Users\<yourusername>\AppData\Roaming\JDeveloper\<yoursystemdirectorybasedonjdev-version>/DefaultDomain/bin

Thanks

Sanjeev

Kareem Wahba

sorry i am too late to response and unfortuntly i faced serveral problems ,thanks for your reply but i am looking for that directory but i can't find it do you have any idea about how to find it?

Ajay Taneja

Hi Kareem,

If you are not able to find the path what you can do is that open jdeveloper and choose run-->start weblogic server.

Check your console window, it will show you your path where this file.

It should help you,

Cheers,Ajay

Kareem Wahba

thanks for your reply sir , i found it but it seems that folder "AppData" was hidden , but now i am trying to run this JAVA_OPTIONS="$JAVA_OPTIONS -Dfile.encoding=utf8"    but it didn't work what should i type in the cmd exactly ?

1 - 8

Post Details

Added on Nov 14 2019
9 comments
874 views