Bulk Select and FOR ALL update not working

Hi
I am trying to run this but it does not work. I get this error
PLS-00430: FORALL iteration variable I is not allowed in this context
declare
cursor c is
select employee_number, national_identifier,
last_name, first_name
from per_all_people_f;
type en_tab is table of per_all_people_f.employee_number%type;
type ni_tab is table of per_all_people_f.national_identifier%type;
type ln_tab is table of per_all_people_f.last_name%type;
type fn_tab is table of per_all_people_f.first_name%type;
en en_tab;
ni ni_tab;
ln ln_tab;
fn fn_tab;
begin
open c;
loop
fetch c bulk collect into en, ni, ln,fn;
forall i in 1..en.count
update xxdl_hr_people_interface
set first_name = fn(i),last_name = ln(i),national_identifier = ni(i)
where employee_number = en(i);
exit when c%notfound;
end loop;
close c;
end;
But if I dont try to update first_name ,last_name, national_identifer at the same time and modify the block to be like this, it runs
declare
cursor c is
select employee_number, national_identifier,
last_name, first_name
from per_all_people_f;
type en_tab is table of per_all_people_f.employee_number%type;
type ni_tab is table of per_all_people_f.national_identifier%type;
type ln_tab is table of per_all_people_f.last_name%type;
type fn_tab is table of per_all_people_f.first_name%type;
en en_tab;
ni ni_tab;
ln ln_tab;
fn fn_tab;
begin
open c;
loop
fetch c bulk collect into en, ni, ln,fn;
forall i in 1..en.count
update xxdl_hr_people_interface
set first_name = fn(i)
where employee_number = en(i);
exit when c%notfound;
end loop;
close c;
end;
Any pointers on why this does not work?
Thank you
Kumar

If per_all_people_f has a PK or unique index on employee_number, then you can do:
UPDATE (SELECT pi.first_name, pi.last_name, pi.national_identifier,
               pf.first_name pffirst, pf.last_name pflast,
               pf.national_identifier pfnat
        FROM xxdl_hr_people_interface pi, per_all_people_f pf
        WHERE pf.employee_number = pi.employee_number)
SET first_name = pffirst,
    last_name = pflast,
    national_identifeir = pfnatIf not, you can do:
UPDATE xxdl_hr_people_interface pi
SET (first_name, last_name, national_identifier) =
            (SELECT first_name, last_name, national_identifier
             FROM per_all_people_f pf
             WHERE pf.employee_number = pi.employee_number)
WHERE EXISTS (SELECT 1
              FROM per_all_people_f pf
              WHERE pf.employee_number = pi.employee_number)Note that if there might be more than one row in per_all_people_f for an employee_id, then you need to modify the select sub-query to add a predicate to make sure it only returns one row for each employee_number.
John

Similar Messages

  • Using bulk collect and for all to solve a problem

    Hi All
    I have a following problem.
    Please forgive me if its a stupid question :-) im learning.
    1: Data in a staging table xx_staging_table
    2: two Target table t1, t2 where some columns from xx_staging_table are inserted into
    Some of the columns from the staging table data are checked for valid entries and then some columns from that row will be loaded into the two target tables.
    The two target tables use different set of columns from the staging table
    When I had a thousand records there was no problem with a direct insert but it seems we will now have half a million records.
    This has slowed down the process considerably.
    My question is
    Can I use the bulk collect and for all functionality to get specific columns from a staging table, then validate the row using those columns
    and then use a bulk insert to load the data into a specific table.?
    So code would be like
    get_staging_data cursor will have all the columns i need from the staging table
    cursor get_staging_data
    is select * from xx_staging_table (about 500000) records
    Use bulk collect to load about 10000 or so records into a plsql table
    and then do a bulk insert like this
    CREATE TABLE t1 AS SELECT * FROM all_objects WHERE 1 = 2;
    CREATE OR REPLACE PROCEDURE test_proc (p_array_size IN PLS_INTEGER DEFAULT 100)
    IS
    TYPE ARRAY IS TABLE OF all_objects%ROWTYPE;
    l_data ARRAY;
    CURSOR c IS SELECT * FROM all_objects;
    BEGIN
    OPEN c;
    LOOP
    FETCH c BULK COLLECT INTO l_data LIMIT p_array_size;
    FORALL i IN 1..l_data.COUNT
    INSERT INTO t1 VALUES l_data(i);
    EXIT WHEN c%NOTFOUND;
    END LOOP;
    CLOSE c;
    END test_proc;
    In the above example t1 and the cursor have the same number of columns
    In my case the columns in the cursor loop are a small subset of the columns of table t1
    so can i use a forall to load that subset into the table t1? How does that work?
    Thanks
    J

    user7348303 wrote:
    checking if the value is valid and theres also some conditional processing rules ( such as if the value is a certain value no inserts are needed)
    which are a little more complex than I can put in a simpleWell, if the processing is too complex (and conditional) to be done in SQL, then doing that in PL/SQL is justified... but will be slower as you are now introducing an additional layer. Data now needs to travel between the SQL layer and PL/SQL layer. This is slower.
    PL/SQL is inherently serialised - and this also effects performance and scalability. PL/SQL cannot be parallelised by Oracle in an automated fashion. SQL processes can.
    To put in in simple terms. You create PL/SQL procedure Foo that processes SQL cursor and you execute that proc. Oracle cannot run multiple parallel copies of Foo. It perhaps can parallelise that SQL cursor that Foo uses - but not Foo itself.
    However, if Foo is called by the SQL engine it can run in parallel - as the SQL process calling Foo is running in parallel. So if you make Foo a pipeline table function (written in PL/SQL), and you design and code it as a thread-safe/parallel enabled function, it can be callled and used and executed in parallel, by the SQL engine.
    So moving your PL/SQL code into a parallel enabled pipeline function written in PL/SQL, and using that function via parallel SQL, can increase performance over running that same basic PL/SQL processing as a serialised process.
    This is of course assuming that the processing that needs to be done using PL/SQL code, can be designed and coded for parallel processing in this fashion.

  • Save for all users not working

    I created a query in the rich client and selected "save for all users", but still cannot open it on another server.  Has anyone else experienced this?  I am on version 12.3.1 build 684.

    I just did a Save As and checked the "Save for all users" box.  I think I have to check "Remove document security", but that's grayed out); Deski only had the one option and it worked fine.  There error I received is:
    The document has been secured on another cluster. You cannot open this document on the current cluster. To open it, log on the right cluster and save it as unsecured. If the cluster is not reachable, try to connect to the following system : '<server>'. If this system is not reachable or not online, try the previous offline session with the connection ''. (WIS 30910)

  • Selecting and moving many messages not working - try sorting by message classes

    I posted this a while back, and have an update now.
    I file my sent items.  Call me crazy, but I like to at the end of every quarter, move sent items from that quarter into sub folders.  It's usually 2-4000 items, and ever since I installed OL2010, I have had weird issues when trying to clean my Sent items.
    Example:  Select 2000 items, sorted by date from Sent Items.  Drag and drop to my 2009Q4 folder.  It then prompts me "Creating a new item from the selected items could take some time. Are you sure you want to create a new item from these 2000 items?"
    So I figured possible Ctrl is stuck down or something, so I right click, Move, select the folder.  Same issue.
    I start selecting smaller data sets.  I got to about 50-60 items at a time that I was able to move and not get that message.  I got frustrated and stopped working on it.
    This morning, I decided to re-test this.  Same issue presents itself.  So instead, I sorted by message class.  I was able to select 3800 message items.  The remaining items were messages with attachments, text/mobile messages, and calendar invite responses.
    It appears that some combination of selecting multiple message classes was triggering my issue.  I suspect the newest of them, the mobile messages to be the issue, so I deleted them, and retried, nope, same error, even selecting only the show message class types.   Would like to see this fixed, of course, and will be sending a frown with the link to this thread as well.
    Chris

    I had this problem too.  For me, simply sorting by message class, then finding all the calendar items and moving them first, then going back and doing the rest, allowed me to move them as I liked.   However, its not clear to me that I have
    all message classes (not sure what they all are), so it could be there are other message classes that cause problems when you move "mixed classes".   I do think this is an MS Outlook bug, but not clear anyone has reported it to MS.  ;-<
    You can prove this by simply selecting a calendar item and a msg, and try moving the two.  You will have this issue.
    However, you'd think that MS itself would be a vast user of MS Outlook and if we're discovering this, you'd think MS internal folks are too, so I'm deferring to them to self-resolve.   Until then, I'll just use this workaround.
    Definition of "Message classes" for others reading this...  You may have already inferred, but two examples of "classes" are a normal email (.msg) and a calendar item.  You can sort these by clicking on the "icon" field at the top of your email
    folder, just to the right of the "bell" (Reminders).   Not sure how to put a .JPG in this posting, since a picture would explain this much better than I can using words.

  • New update for Itunes update not working

    I am having the same problem that lots of people are having, i have looked at the thread and i did everything that was sugguested but i still get the flowing error
    runtime error
    Program:C\Programfiles\itunes\itunes.exe
    R6034
    An applocation has made an attempt to load the C runtime Library inncorrectly
    please help

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall move on to the next item)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

  • Unable to download OSX Mountain Lion, and iTunes 11 update not working.

    Hi there,
    I paid for OSX Mountain Lion and was ubale to download, keeps given error or something similar. Now I can't seem to update iTunes. Please advice.

    What is the error code/message?
    Try resetting the App Store.
    Reset       Learned from Old Toad
    There is a contact link.
    Support

  • I DON'T WANT TO UPGRADE OR HAVE AN ADD ON EVER, DISABLING UPDATES DOES NOT WORK, HOW DO I KILL ALL MEASAGES FOR UP GRADES AND ADD ON'S FOR EVER, ONCE AND FOR ALL, COMPLETELY, THE END AND NEVER BE BOTHERED AGAIN EVER!

    I DON'T WANT TO UPGRADE OR HAVE AN ADD ON EVER, DISABLING UPDATES DOES NOT WORK, HOW DO I KILL ALL MESSAGES FOR UP GRADES AND ADD ON'S FOR EVER, ONCE AND FOR ALL, COMPLETELY, THE END AND NEVER BE BOTHERED AGAIN EVER! ALSO IF I KILL MYSELF I WILL HOLD YOU PERSONALTY RESPONSIBLE.edit

    There is a world of information in these forums if you use the search function near the top right of this page. Just type in NAS for example and you get many threads on the subject (marked with a green checkmark if it solved the question) another example would be Airport Exterme and sound system. Once you formulate your ideas better then specific questions can be addressed one at a time. You may find that a less expensive choice for a server might be a mac mini. Good luck with your project, ask more specific questions and update you systems profile.

  • TS1702 I did all of the above recommendations and still Biblexpress is not working. Should not the developer have an update to care for the problem?

    I did all of the above recommendations and still Biblexpress is not working. Should not the developer have an update to care for the problem?

    You should contact the developer directly to inform them of any issues.
    There should be links in the App and if not, there should be links
    to the developer's site and support in their presentation in the App Store.

  • HT1349 Actually, my iphone was hanged and its screen was not working at all .So, I updated its software from market but for reactivation it require icloud account but i didn't know how exactly it is and i was caught in big trouble . But i have its box and

    Actually, my iphone was hanged and its screen was not working at all .So, I updated its software from market but for reactivation it require icloud account but i didn't know how exactly it is and i was caught in big trouble . But i have its box and all other accessories .So , kindly help me as early as possible .Thankyou    and tell me about its solution
    <Email Edited by Host>

    Basic troubleshooting steps outline in the manual are restart, reset, restore from backup, restore as new.  Try each of these in order until the problem is resolved.  If you've been through all these steps and the trouble persists, you'll need to bring your phone to Apple for evaluation.  Be sure to make an appointment first at the Genius Bar so you won't have a long wait.
    Best
    GDG

  • I have bought  three iPhone 6  one for me and one each for my two kids  we have just done the update iOS 8.01 now all phone  do not connect to service provider and touch id is not working ,  APPLE HELP !!!!

    i phones  updated iso 8.01 all three phones  will not connect to service provider and touch id
    will not work  APPLE HELP !!!!!!!!!
    anyone know  i fix as  i have spent over 2000 pound on three phones that won't work
    all three where working fine until the 8.01 update

    Apple just pulled the update because it is a major fubar! You will have to rollback your iPhone to the base iOS 8 using iTunes and Apple needs to seriously test its patches!
    Update:
    Simply connect your phone to iTunes and back up your data. Then, click the “Restore iPhone” button and follow the on-screen instructions. It’s a huge pain, but at least it’s better than having your shiny new iPhone turned into a big expensive iPod touch.

  • Transaction SE16: Field selection (User-Specific Settings) is NOT working for ALL tables

    Hi Guru’s,
    I have an issue in Transaction SE16, Field selection (User-Specific Settings) is NOT working in Tables (ALL tables).
    Following is the screenshot attached for your kind reference,
    That is in the initial screen of transaction SE16 if I choose Filed Name or Filed Label only the technical details (Field Names) are appearing and not the descriptions like Client, Purchasing Doc, and Company Code Doc. Category Document Type etc…
    Right now I am using ECC6 and EHP7 SAP system.
    Please help me to resolve this issue by implementing any OSS note or User Role creations or any technical changes required in system.
    Hope the requirement is clear and in case need any clarification please revert back.
    NOTE: Right now in Development System we don’t have any successful user to compare the settings.
    Regards,
    Kumar.S

    Thanks Patra.
    Even I searched in SAP portal and couldn't able to find the relevant OSS note.
    Following is my BASIS team response,
    "Only you can view Table Field values from higher release"
    Can you suggest / guide on this comment as well.
    Looking forward to your speedy response.
    Regards,
    Kumar.S

  • Site list update not working with TED and Zenworks for Servers

    Product: Zenworks for Desktops 7Sp1 and Zenworks For Server/TED 7Sp1HP5
    Subject: Site list update not working with TED and Zenworks for Servers ,
    all on Linux
    Description: We have an exiting environment with 6 ZfS Servers and now we
    brought up a new Server for another location. I configured all same as on
    the other Server and the new one created all NAL-Apps at the new location.
    But in the Application Site list on the golden App is this Application
    missing. So I clicked on the Link up site list on the Distribution Screen
    in C1. On ApplicationSite list the App from the new location is missing.
    So I removed all and added the new from the new location and now i see all
    in the application site list.When I install an app on the client on the
    new location NAL is connecting alway th the same (wrong location-server
    and i get an msi error 1612 or id=53272 with path=\Wrong serverpath to
    file.
    I looked on the other tab on C1 at the golden app an I see the backlinks
    are going to all other servers without the new one. Software installation
    on other locations are ok
    Regards

    Andreas,
    I forgot to mention that you can also set the loging level on the Distributor and the Subscriber to 6. to do this at the Zenworks Server Management prompt type "setconsolelevel 6" if you want to capture this to the log file ted.log then use "setfilelevel 6"
    Next delete the Distribution from the Subscriber and then re-push the channel.
    What we are looking for here in the log is the creation of the object and the linking information about the gold object. it should look like this (not the failure part ;-))) )
    In this excerpt you will see the entry
    Golden App =
    This should be were the link is to
    You can check this both ways in the Golden App and in the Distributed Application.
    Here is a log from me that shows this info as an example of what you should be looking for.
    2008.05.29 03:35:41 [TED:Work Order In(yourserver.yes.com)] Receiving distribution: Creating new application failed,
    Subscriber Tree Name= YOUR-TREE,
    Subscriber DN = SUBSCRIBER_YOURSERVER.BRN.FL.SUBS.SUBSCRIBERS.ZSM. GRS.CBH,
    Golden App = SCRIPT-MS-HOTFIX.APP.BRN.ZENGOLD.GRS.CBH,
    Attempted AppName = SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH,
    error message: Failed creating SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH. With error message: Setting the trustee for BRN.HAVERHI.PALM.FL.CBH on the file "VOL1:\ZEN\UTILS" failed. Look in subscriber log file for more details..
    2008.05.29 03:35:41 [TED:Event Processing] Handle Event: Work order IN completed... Creating new application failed,
    Subscriber Tree Name= YOUR-TREE,
    Subscriber DN = SUBSCRIBER_HAVERHI-FLBRN1.BRN.FL.SUBS.SUBSCRIBERS.ZSM.GRS.CBH,
    Golden App = SCRIPT-MS-HOTFIX.APP.BRN.ZENGOLD.GRS.CBH,
    Attempted AppName = SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH,
    error message: Failed creating SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH. With error message: Setting the trustee for BRN.HAVERHI.PALM.FL.CBH on the file "VOL1:\ZEN\UTILS" failed. Look in subscriber log file for more details..
    2008.05.29 03:35:41 [TED:Event Processing] Received (from haverhi-flbrn1.yesbank.com) Creating new application failed,
    Subscriber Tree Name= YOUR-TREE,
    Subscriber DN = SUBSCRIBER_HAVERHI-FLBRN1.BRN.FL.SUBS.SUBSCRIBERS.ZSM.GRS.CBH,
    Golden App = SCRIPT-MS-HOTFIX.APP.BRN.ZENGOLD.GRS.CBH,
    Attempted AppName = SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH,
    error message: Failed creating SCRIPT-MS-HOTFIX.APP.BRN.HAVERHI.PALM.FL.CBH. With error message: Setting the trustee for BRN.HAVERHI.PALM.FL.CBH on the file "VOL1:\ZEN\UTILS" failed. Look in subscriber log file for more details..

  • 7.1.2 update failed. Now my iPhone 5 is in recovery mode and hard resetting does not work for me. iTunes also will not detect my phone now

    I did my 7.1.2 update via iTunes. Half way through it stopped working saying it does not detect my phone. Now my iPhone 5 is in recovery mode and hard resetting does not work for me. iTunes also will not detect my phone now

    Thank you SO very much for posting this. I had the exact issue with my iPad Mini after the same upgrade. Hard reset failed, computer would not recognize iPad. I had read all the other instructions and nothing worked.... YOUR SOLUTION WORKED FOR ME - with a slight variation.
    I followed your lead and connected my iPad Mini to another computer, fired up iTunes, it saw the iPad Mini in Restore Mode and allowed me to go into Restore (yes, it wiped all of the data but I have a back up on the other computer that would not see it after the failed update). It installed the latest iOS 7.1.2 as well. I then disconnected it from that computer, reconnected it to the computer that would not see it prior and it then saw it as a new iPad and allowed me to Restore my backup and now it's all good!
    I detailed my steps only because you downloaded the previous version - 7.1.1 whereas I downloaded the latest version (7.1.2) and then restored my back up.

  • Thanks for responding.  Since I upgraded ITUNES to IOS 6, my IPOD Touch no longer works at all.  I had numerous apps, music and videos on this touch.  It made me restore to factory reset and it still does not work!!! Nothing I do will work on this touch n

    Thanks for responding. Since I upgraded ITUNES to IOS 6, my IPOD Touch no longer works at all. I had numerous apps, music and videos on this touch. It made me restore to factory reset and it still does not work!!! Nothing I do will work on this touch now. I have so much data on this, I don't want to loose or have to restore!
    Can you help me?
    Thanks

    If you restored to factory settings/new iPod and still have the problem that indicates a hardware problem.
    Make an appointment at the Genius Bar of an Apple store..
    Apple Retail Store - Genius Bar

  • TS3367 I cannot get my iPhone 4S to connect to iMessage n FaceTime have tried all the tips online and it's still not working ? It's just saying  waiting for activation

    I cannot get my iPhone 4S to connect to iMessage n FaceTime have tried all the tips online and it's still not working ? It's just saying  waiting for activation

    What tips have you tried so far?   Just so we don't waste our time telling you things you've already done.
    When you respond, also indicate which country and carrier you're using.   Also, is your phone brand new?  can you make a phone call / access the internet while on cellular?

Maybe you are looking for

  • ITunes Updates Keeps Modifying the Library

    The last two iTunes updates I have allowed to run (9.1x and today, version 10) have mangled my library. The 9.1x download wiped about 2 hours of user-input cover art. The Apple cover art function is awful, to be kind. When I spend hours updating the

  • Apple TV deletes sync'd content (photos)

    My ATV setup is demonstrating a variant of what seems to be a frequently reported problem - erratic sync behavior. In general, the sync process will often (but not always) delete (all) previously sync'd photos from the ATV, despite the fact that the

  • License Key Error

    Trying to enter the new license key to Siebel Tools I've got this mistake: "You are not currently licensed to use Siebel Tools. (SBL-DEV-00133)" There is no place to enter the license key any more, only this message. How to fix it?

  • Visual feedback in quiz?

    I'm creating a multiple choice quiz in Captivate (not graded). Feedback messages appear when a user makes a correct or incorrect choice. I'd like to provide some visual feedback, too -- perhaps a check mark next to the correct choice, or perhaps dimm

  • How do I de-install Garage Band?

    I have recently installed iLife05, but I have no interest in using Garage Band. How do i de-install it, so that I can reclaim the space?