A question on FORALL and Collections

It's hard to find a difinitive answer to this question via online docs. I'm doing a FORALL without a BULK COLLECT.
Givin the following;
In Package Header:
TYPE scalarArray1 is varray(500) of varchar2(50);
TYPE scalarArray2 is varray(500) of varchar2(50);
In package Body
...populate the 2 arrays
FORALL i in 1..N
EXECUTE IMMEDIATE
'UPDATE table_name SET column1 = :1
WHERE column2 = :2'
USING scalarArray1(i), scalarArray1(i);
This will give me the following error:
PLS-00430: FORALL iteration variable is not allowed in this context
PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL
I'm begining to think that you can't have for FORALL statment without at BULK COLLECT statement.
I'm I correct?

You defined VARRAY types, now you need to declare variables of those types and use the variables.
SQL> create table t (
  2    column1  varchar2(30),
  3    column2  varchar2(30) );
Table created.
SQL>
SQL> insert into t
  2  select 'a' column1, 'y'||level column2
  3    from dual
  4  connect by level <= 12;
12 rows created.
SQL>
SQL> commit;
Commit complete.
SQL> select * from t;
COLUMN1                        COLUMN2
a                              y1
a                              y2
a                              y3
a                              y4
a                              y5
a                              y6
a                              y7
a                              y8
a                              y9
a                              y10
a                              y11
a                              y12
12 rows selected.
SQL> DECLARE
  2    TYPE scalararray1 IS VARRAY (500) OF VARCHAR2 (50);
  3    TYPE scalararray2 IS VARRAY (500) OF VARCHAR2 (50);
  4    --
  5    sa1   scalararray1;
  6    sa2   scalararray2;
  7  BEGIN
  8    sa1 := scalararray1 ();
  9    sa2 := scalararray2 ();
10    --
11    FOR i IN 1 .. 10
12    LOOP
13      sa1.EXTEND ();
14      sa1 (i) := 'x' || i;
15      sa2.EXTEND ();
16      sa2 (i) := 'y' || i;
17    END LOOP;
18    --
19    FORALL i IN 1 .. sa1.COUNT ()
20      EXECUTE IMMEDIATE 'UPDATE t SET column1 = :1 WHERE column2 = :2'
21                  USING sa1 (i), sa2 (i);
22  END;
23  /
PL/SQL procedure successfully completed.
SQL> select * from t;
COLUMN1                        COLUMN2
x1                             y1
x2                             y2
x3                             y3
x4                             y4
x5                             y5
x6                             y6
x7                             y7
x8                             y8
x9                             y9
x10                            y10
a                              y11
a                              y12
12 rows selected.
SQL> commit;
Commit complete.
SQL>

Similar Messages

  • Question regarding generics and collections

    Hi,
    I am stuying the Sierra and Bates book for SCJP.
    One particular answer to a question in it is puzzling me at the moment:
    Given a method as
    public static <E extends Number> List<E> process(List<E> nums)
    A programmer wants to use this method like this:
    //INSERT DECLARATION HERE
    output = process(input)
    which pairs of delcarations could be placed at //INSERT DECLARATION HERE to allow this to compile.
    Correct answers given as :
    ArrayList<integer> input = null;
    List<Integer> output = null;
    List<Number> input = null;
    List<Number> output = null;
    List<Integer> input = null;
    List<Integer> output = null;
    My main problem is understanding what this line means:
    public static <E extends Number> List<E> process(List<E> nums)
    How do I read this? I assume <E extends Number>List<E> all relates to the return type?
    If it just said List<E> I would read it as saying the return type must be a List than can only accept objects of type E but I'm confused by the extra
    part before it.
    Hope someone can help.
    Thanks

    Have you seen generics before? E is a type variable. If the method had the simpler definition:
    <E> List<E> process(List<E> nums)This would mean that E could be replaced by any type, like you had an unbounded number of definitions:
    List<A> process(List<A> nums)
    List<B> process(List<B> nums)
    List<C> process(List<C> nums)
    ...For every possible type: A, B, C, ...
    But E has the bound "extends Number" which mean that this is like have the definitions:
    List<Number> process(List<Number> nums)
    List<Integer> process(List<Integer> nums)
    List<Long> process(List<Long> nums)
    ...For Number and every subclass of Number.

  • Question regarding Records and Collection

    HI All,
    I have a record/Collection say rec_t
    For i in rec_t.FIRST..rec_t.Last
    Loop
    -- i need to have a condition with which i can find out, if in the loop i am at the last record
    if rec_t.last is true --I know this is not working but do we have something to get t
    END LOOP;

    padders wrote:
    Well at least we're all consistent :-DYeah, I saw that.. :-)
    But I would have posted:
    if i = rec_t.Count then ...Cannot recall ever using the +.last()+ and +.first()+ methods for normal array processing. Using
    for i in 1..array.Count loop .... is a lot safer as it deals with array variables with no value (null) just fine. No need for additional code to check for a null state prior to entering the FOR loop.

  • Dunning by dunning procedure and collection strategy

    Hi All,
    Have some questions around dunning.
    1. Can dunning by dunning procedure and collection strategy coexist in the same company code - if this cannot be achieved by config can it be achieved by development - can we have something like account determination IDs of X to use dunning procedure, account determination IDs of Y to use collection strategy?
    2. If the answer to 1. is no, can one company code use dunning procedure and another company code use collection strategy?
    3. What is SAP's (or any other proven) recommended approach to migrate a production system utilising dunning by dunning procedure to dunning by collection strategy?
    Cheers.

    Have a look
    SAP-ISU will be used to carry out initial collection activities. Initial 1 or 2 reminder letters (based on the customer type, Live or Closed) will generated from SAP-ISU. Thereafter, the account will be managed in Tallyman. Thus, all the subsequent activities, such as sending further reminder letters, sending debt to collection agencies, carry out warrant activities and taking customers to court will be carried out in Tallyman system. During the time, the account is in Tallyman, no dunning activities will be carried out in SAP.
    There will be daily interfaces from SAP-ISU to Tallyman to update Tallyman of Accounts that have passed a certain dunning level in SAP-ISU and any changes to the account that are currently being managed in Tallyman. Similarly there will be interfaces from Tallyman to SAP to update SAP of Accounts, that have been marked for write off in Tallyman. Fees and Charges that have been applied in Tallyman, for example court fees, warrant fees etc.
    Regards
    Shashi
    Edited by: shashi jha on Mar 31, 2010 8:10 AM

  • How the freight cost are transferred from condition type of shipment cost document to service entry sheet and collected in service PO item

    Dear Experts:
    could you please share with me the knowledge for below topic:
    How the freight cost are transferred from condition type of shipment cost document to service entry sheet and collected in service PO item, because these three objects use three different pricing procedures, and different condition type.
    how did the condition type of service entry sheet know to copy the value of whcih condition type in the pricing procedure of shipment cost document?
    Is this SAP standard function OR there need an enhancement to do that?
    I didn’t find related condition value copy setting in background, could you please share related setting with me? Thank you very much for your kind help!
    Best regards,
    Andy

    Hi, Gopi,
    Glad to see your feedback, but i still have question on your feedback:
    which condition type in the pricing procedure of service entry sheet should know to capture the net value of shipment cost doc? becasue there are so many condition types,
    And i have checked the corresponding condition type (PRSX) of service entry sheet pricing procedure in my SAP system, this is a self-defined condition type, but NO any calculation routine maintained for the condition type (PRSX), how did the condition type (PRSX) know to copy the total cost of shipment cost document?
    Below is the example and another question:
    what the relationship between the pricing procedures at service PO item level and service line item level?
    1. The freight cost in shipment cost document—including used condition type and pricing procedure
    The pricing procedure of shipment cost document
    2. The freight cost in service entry sheet—including used condition type and pricing procedure
    The pricing procedure of service entry sheet--the pricing procedure at service line item level
    3. The freight cost in service PO item—including used condition type and pricing procedure:

  • Where to put the commit in the FORALL BULK COLLECT LOOP

    Hi,
    Have the following LOOP code using FORALL and bulk collect, but didnt know where to put the
    'commit' :
    open f_viewed;
    LOOP
    fetch f_viewed bulk collect into f_viewed_rec LIMIT 2000;
    forall i in 1..f_viewed_rec.count
    insert into jwoodman.jw_job_history_112300
    values f_viewed_rec(i);
    --commit; [Can I put this 'commit' here? - Jenny]
    EXIT when f_viewed%NOTFOUND;
    END LOOP;
    commit;
    Thanks,
    - Jenny

    mc**** wrote:
    Bulk collect normally used with large data sets. If you have less dataset such as 1000-2000 records then you canot get such a performance improvent using bulk collect.(Please see oracle documents for this)
    When you update records Oracle acquire exclusive lock for that. So if you use commit inside the loop then it will process number of records defined by limit parameter at ones and then commit those changes.
    That will release all locks acquired by Oracle and also teh memory used to keep those uncommited transactions.
    If you use commit outside the loop,
    Just assume that you insert 100,000 records, all those records will store in oracle memory and it will affect all other users performance as well.
    Further more if you update 100,000 records then it will hold exclusive lock for all 100,000 records addtion to the usage of the oracle memory.
    I am using this for telco application which we process over 30 million complex records (one row has 234 columns).
    When we work with large data sets we do not depends with the oracle basic rollback function. because when you keep records without commit itb uses oracle memory and badly slowdown all other processes.Hi mc****,
    What a load of dangerous and inaccurate rubbish to be telling a new Oracle developer. Commit processing should be driven by the logical unit of a transaction. This should hold true whether that transaction involves a few rows or millions. If, and only if, the transaction is so large that it affects the size constraints of the database resources, in particular, rollback or redo space, then you can consider breaking that transaction up to smaller transactions.
    Why is frequent committing undesirable I hear you ask?
    First of all it is hugely wasteful of rollback or redo space. This is because while the database is capable of locking at a row level, redo is written at a block level, which means that if you update, delete or insert a million rows and commit after each individual statement, then that is a million blocks that need to go into redo. As many of these rows will be in the same block, if you instead do these as one transaction, then the same block in redo can be transacted upon, making the operation more efficient. True, locks will be held for longer, but if this is new data being done in batches then users will rarely be inconvenienced. If locking is a problem then I would suggest that you should be looking at how you are doing your processing.
    Secondly, committing brings into play one of the major serialization points in the database, log sync. When a transaction is committed, the log buffer needs to be written to disc. This occurs serially for multiple commits. Each commit has to wait until the commit before has completed. This becomes even more of a bottleneck if you are using Data Guard in SYNC mode, as the commit cycle does not complete until the remote log is notified as written.
    This then brings us two rules of thumb that will always lead a developer in the right direction.
    1. Commit as infrequently as possible, usually at the logical unit of a transaction
    2. When building transactions, first of all seek to do it using straight SQL (CTAS, insert select, update where etc). If this can't be easily achieved, then use PL/SQL bulk operations.
    Regards
    Andre

  • Object and reference accessing for primitives, objects and collections

    Hi,
    I have questions re objects, primitives and collection accessing and references
    I made a simple class
    public class SampleClass {
         private String attribute = "default";
         public SampleClass()
         public SampleClass(SampleClass psampleClass)
              this.setAttribute(psampleClass.getAttribute());
              if (this.getAttribute() == psampleClass.getAttribute())
                   System.out.println("INSIDE CONSTRUCTOR : same object");
              if (this.getAttribute().equals(psampleClass.getAttribute()))
                   System.out.println("INSIDE CONSTRUCTOR : equal values");
         public void setAttribute(String pattribute)
              this.attribute = pattribute;
              if (this.attribute == pattribute)
                   System.out.println("INSIDE SETTER : same object");
              if (this.attribute.equals(pattribute))
                   System.out.println("INSIDE SETTER : equal values");
         public String getAttribute()
              return this.attribute;
         public static void main(String[] args) {
    ...and another...
    public class SampleClassUser {
         public static void main(String[] args) {
              SampleClass sc1 = new SampleClass();
              String test = "test";
              sc1.setAttribute(new String(test));
              if (sc1.getAttribute() == test)
                   System.out.println("SampleClassUser MAIN : same object");
              if (sc1.getAttribute().equals(test))
                   System.out.println("SampleClassUser MAIN : equal values");
              SampleClass sc2 = new SampleClass(sc1);
              sc1.setAttribute("test");
              if (sc2.getAttribute() == sc1.getAttribute())
                   System.out.println("sc1 and sc2 : same object");
              if (sc2.getAttribute().equals(sc1.getAttribute()))
                   System.out.println("sc1 and sc2 : equal values");
    }the second class uses the first class. running the second class outputs the following...
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    SampleClassUser MAIN : equal values
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    INSIDE CONSTRUCTOR : same object
    INSIDE CONSTRUCTOR : equal values
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    sc1 and sc2 : equal values
    ...i'm just curios why the last 3 lines are the way they are.
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    sc1 and sc2 : equal values
    how come while inside the setter method, the objects are the same object, and after leaving the setter method are not the same objects?
    Can anyone point a good book that shows in detail how objects, primitives and collections are referenced, especially when passed to methods. Online reference is preferred since the availability of books can be a problem for me.
    Thanks very much

    You are confusing references with objects.
    This compares two object references:
    if( obj1 == obj2 ) { // ...Whereas this compares two objects:
    if( obj1.equals(obj2) ) { // ...A reference is a special value which indicates where in memory two objects happen to be. If you create two strings with the same value they won't be in the same place in memory:
    String s1 = new String("MATCHING");
    String s2 = new String("MATCHING");
    System.out.println( s1 == s2 ); // false.But they do match:
    System.out.println( s1.equals(s2) ); // trueIf you're using a primitive then you're comparing the value that you're interested in. E.g.
    int x = 42;
    int y = 42;
    System.out.println(x == y); // trueBut if you're comparing references you're usually more interested in the objects that they represent that the references themselves.
    Does that clarify matters?
    Dave.

  • Question: about accessing Nik collection through Lightroom

    I have recently purchased and installed Nik collection. I have no problem reaching the plug-ins in Photoshopbut can't in Lightroom (except for HDR)

    Thanks!  Technology senses my fear and always makes it difficult for me! Ha! I can use the Nik programs so if I have to, I'll work on them there.
    Date: Sat, 13 Apr 2013 16:27:45 -0700
    From: [email protected]
    To: [email protected]
    Subject: question: about accessing Nik collection through Lightroom
        Re: question: about accessing Nik collection through Lightroom
        created by trihelm2 in Photoshop Lightroom - View the full discussion
    I suspect there are potential issues on some systems with the Google "combined" version, when I installed it I had recieved a copy of the Google complete version free because of my purchase history. I was advised that I could install over the Individual Plugins I had. I never got as far as trying it with Lightroom, only in Elements. The plugins appeared but the load times were abysmal and I mean realy bad , far longer than the Nik individual Installs, so I dumped it and reverted to the originals. Pity cos I wanted the Sharpen Plugin that I have'nt got. After reverting all was back to normal The Nik individual Plugins load very quickly. It was this that convinced me there is a difference in the Google setup.There are people on here with far more knowledge than me, hopefully one of them can help you, alternatively you might try asking Google for help with this.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5232723#5232723
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5232723#5232723
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5232723#5232723. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Lightroom by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Catalogs and Collections

    Windows 7 and CS4 Production Premium, LR3 and Acrobat X I have just received LR3.3 so this application is new to me. I currently use a non-Adobe application for my image database management. My images are primarily associated with genealogy work saved as uncompressed TIFF. At this time I have 5716 files in 68 folders. It is organized as follows: The highest level is by family surname (6 folders). Each of these folders contain 9 other sub-folders which represents image content; such as, individuals, siblings, family, etc. One of the highest level folders is used to contain images that have multiple family surname people in the image. In addition to these genealogy folders, there are other folders that contain images sorted by characteristics, such as, trips, scenic, trains, planes, etc. Using the current application terms, I maintain a catalog for each sub-folder. It is a thumbnail of each image in that folder with the file name and IPTC caption "headline" description. I make extensive use of IPTC metadata for each image: Headline, Description, Title, Keywords and Instructions. I want to fully understand the LR3 catalog(s) and collection(s) and smart collection(s) before I begin the changeover to LR3. Q1: Whenever I add a new image to my hard file storage folder, do I have to manually add it to the LR catalog? With my current application, when a folder is selected in that application, it looks for changes in the folder and new thumbnails are generated for the new files. Q2: A smart collection appears to built by keywords from the LR3 catalog and the non-smart collection must be manually built from the LR3 catalog...Correct? Q3: When I build a collection by "keywords" can portions of the file name structure be included (not placed in the keyword metadata) in the build criteria? Q4: Been thinking of using one LR3 catalog for my genealogy images and one for my non-genealogy images. Then use collections  (smart or non-smart to be determined) for each of my sub-folders. Sound reasonable? Q5: Can I do a search on the catalog via keywords without requiring a collection name defined? This would be a temporary assemblage of images only. Q6: Can I print the catalog or a collection with the file name and IPTC data (e.g., Headline) under each thumbnail?

    Di_paige, thanks for your response.
    As noted in my previous response, I took the word "keyword" too literally. That confusion is now cleared up.
    A clarification to your question on multiple surname handling. Currently, I have a set of hard drive folders for specific surnames and one other set for images having multiple surname content. I think that if I have one catalog for genealogy that a search by surname will turn up the applicable images in all the hard disk folders (assuming they have been cataloged).
    The thought process of a collection per hard disk folders is mostly governed by the desire for printing a document (want to avoid the term catalog) for each such hard disk folder when a person requests such information. Doing so at this level reduces the print size of the document. Now as I get into this with LR maybe it is not necessary if I can simply print a set of images based on file names (with wild cards) and IPTC keyword content.
    Thanks again for your helpful answers.

  • What is difference between Iterator and Collection Wrapper?

    Hi all,
                  I dont understand the actual difference between Iterator and Collection Wrapper. I observed both are used for the same purpose. Could any one please let me know when to use Collection Wrapper and when to use Iterator??
    Thanks,
    Chinnu.

    L_Kiryl is right.
    Collections support global iteration (through collection->get_next( )) and local iteration (through iterator->get_next( )).
    Each collection has a focus object. Initially, the first object has the focus.
    Any global iteration moves the focus, which is published by the event FOCUS_CHANGED of the collection.
    If you want to iterate on the collection without moving the focus (and without triggering timeconsuming follow-up processes) you can use local iteration. To do so, request an iterator object from the collection and use this to iterate.
    And one more advantage of using iterator: it takes care of deleted entities. If you use global iteration then when you reach deleted entity it will be an exception. But there is no exception with iterator in the same situation.

  • Question regarding battery and warranty

    Hi all! I have a quick question about how and if my warranty applies to my battery. After about a year and a half of ownership (I have the three-year extended warranty), my battery has gone completely down the toilet. It wasn't a problem before, but this year I have to lug my T61p around a lot for lab work. My battery is now rated at... 39.75Wh when it shipped at 84.24Wh. This is a pretty drastic difference. In any case, I don't think that this is covered by warranty, but figured that I'd ask before I drop $180 on a new battery (ouch). And, speaking of, if my suspicions are correct, does anybody know where I might find a 9-cell battery for the T61p? All I'm seeing on Lenovo's website is the one for the N100... which doesn't... match very well. Yaknow.
    Thanks a lot!
    ThinkPad T61p [June 2008]: 2.5Ghz Penryn Core 2 Duo, 4GB DDR2 RAM, NVidia Quadro FX 570m 256MB, 160GB 7200RPM Fujitsu HDD, 1920x1200 WUXGA Matte LCD, Windows 7 RC1

    Is either of these appropriate? I'm wary of the one on Amazon, as there are other (off-brand) batteries that are advertised as being Lenovo ones (though those generally sell for  a lower price). The other one just looks like I'll have to call up to buy it.
    http://www.amazon.com/Lenovo-43R9255-ThinkPad-Notebook-Battery/dp/B001DX9EKA
    http://affordablepcsupply.com/products/IBM/REF/42T4511.html
    Thoughts?
    ThinkPad T61p [June 2008]: 2.5Ghz Penryn Core 2 Duo, 4GB DDR2 RAM, NVidia Quadro FX 570m 256MB, 160GB 7200RPM Fujitsu HDD, 1920x1200 WUXGA Matte LCD, Windows 7 RC1

  • Question regarding roaming and data usage

    I am currently out of my main country of service, and as such I have a question regarding roaming and data usage.
    I am told that the airplane mode is sufficient from keeping the phone off from roaming, but does this apply to any background data usage for applications and such?
    If the phone is in airplane mode, are all use of the phone including wifi and application use through the wifi outside of all extra charges from roaming?

    Ann154 wrote:
    If you are getting charged to use the wifi, then it is possible.  Otherwise no
    Just to elaborate here, Ann154 is referring to access charges for wifi, which is nothing to do with Verizon, so if you are using it in a plane, hotel, an internet cafe etc that charges for Wifi rather than being free .   Verizon does not charge you (or indeed know about!) wifi usage, or any other usage that is not on their cellular network (such as using a foreign SIM for example in global phones)  So these charges, if any, will not show up on the verizon bill app.  Having it in airplane mode prevents all cellular data traffic so you should be fine

  • Question regarding MM and FI integration

    Hi Experts
    I have a question regarding MM and FI integration
    Is the transaction Key in OMJJ is same as OBYC transaction key?
    If yes, then why canu2019t I see transaction Key BSX in Movement type 101?
    Thanks

    No, they are not the same.  The movement type transaction (OMJJ) links the account key and account modifier to a specific movement types.  Transaction code (OBYC) contains the account assignments for all material document postings, whether they are movement type dependent or not.  Account key BSX is not movement type dependent.  Instead, BSX is dependent on the valuation class of the material, so it won't show in OMJJ.
    thanks,

  • **question regarding 3G and wif**.

    I have a question regarding 3G and wifi. I have #G activated as well as wifi, when I go to retrieve mail for example I get a pop up asking me if I want to connect to a wifi network…should I have wifi and 3G activated at the same time, and why am I getting the pop up…
    Thanks

    You can have them on at the same time, but they will not be used at the same time for data. The order of preference for data is WiFi > 3G > EDGE > GPRS. You're getting the pop up, most likely, because you have Settings > Wi-Fi > Ask to Join Networks set to ON. You can set that to OFF, and the iPhone will still join known (i.e. previously used) WiFi networks automatically.

  • Question regarding Dashboard and column prompt

    My question regarding Dashboard and column prompt:
    1) Dashboard prompt usually work with only for columns which are in subject area. In my report I've created some of the columns which are based on other columns. Like I've daysNumber column that is based on two other columns, as it calculates the difference of two dates. When I create dashboard prompt I can't find this column there. I need to make a prompt on this column.
    2)For one of the column I've only two values 1 and 0. When I create prompt for this column, is it possible that in drop down list It shows 'Yes' for 1 and 'No' for 0 and still filter the request??

    Hi Toony,...
    I think there was another way of doing this...
    In the dashboard prompt go to Show option > select SQL Results from dropdown.
    There you need to write your Logical SQL like...
    SELECT CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END FROM SubjectAreaName
    Here.. Periods.Year is the column which is already exists in repository's presentation layer..
    and difference of date functionality is the code or formula of column which you want to show in drop-down...
    Also write the CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END code in fx of that prompt.
    I think it helps you in doing this..
    Just check and inform me if it works...
    Thanks & Regards
    Kishore Guggilla
    Edited by: Kishore Guggilla on Oct 31, 2008 9:35 AM

Maybe you are looking for