3 Replies Latest reply: Feb 14, 2013 3:21 AM by mathieu.d RSS

    BPEL 2.0 how to do looping record by record over the data collection (selec

    user8611954
      BPEL 2.0 how to do looping record by record over the data collection (select query ...........) ???


      Following is a sample for BPEL 1.1 how to do looping record by record over collection. .............................

      *<assign name="InitializeWhileLoop">*
      *<copy>*
      *<from expression="count(bpws:getVariableData('InvokeGetOrdersFromCOM_OutputVariable','GetOrderDetailsFromCOMOutputCollection','/ns26:GetOrderDetailsFromCOMOutputCollection/ns26:GetOrderDetailsFromCOMOutput'))"/>*
      *<to variable="OrderCount"/>*
      *</copy>*
      *<copy>*
      *<from expression="1"/>*
      *<to variable="WhileCount"/>*
      *</copy>*
      *</assign>*


      *<while name="While_GetOrders"*
      condition="bpws:getVariableData('WhileCount') &lt;= bpws:getVariableData('OrderCount')">


      I hear in BPEL 2.0 you do not have to code such to get the data collection records one by one. Is it true ?

      Can some one show me snippet how loop over collections done in BPEL 2.0 ??

      thx
        • 1. Re: BPEL 2.0 how to do looping record by record over the data collection (selec
          mathieu.d
          Hi,

          In the Assign activity if you make a right clic on an expression you can change the expression type from copy to copyList.
          This should be what you're searching for ?
          Also, don't forget to select "InsertToMissingData" for creating extra node in the target variable.

          regards,
          mathieu
          • 2. Re: BPEL 2.0 how to do looping record by record over the data collection (selec
            user8611954
            Mathieu,

            That is not my question.

            My question is what is the way in BPEL 2.0 for looping the collection.

            so instead of follwoing (which is BPEL 1.1 way), what could be BPEL 2.0 way for looping collection. ?

            expression="count(bpws:getVariableData('InvokeGetOrdersFromCOM_OutputVariable','GetOrderDetailsFromCOMOutputCollection','/ns26:GetOrderDetailsFromCOMOutputCollection/ns26:GetOrderDetailsFromCOMOutput'))"/> ------------ this BPEL 1.1 way

            thx
            • 3. Re: BPEL 2.0 how to do looping record by record over the data collection (selec
              mathieu.d
              Sorry, I did not understand your case correctly.

              Then maybe you're talking about the "for-each" BPEL 2.0 activity which enable you to make that kind of loop.
              The overall logic is the same.

              You set the start counter to 1
              You set the end counter to "count('your collection')"
              And you name the counter in order to get the current element of the loop using the counter.

              But be careful, if you set the start counter to 1 and your collection is empty then your loop will not end correctly.
              mathieu.d wrote:

              <forEach parallel="yes" counterName="index" name="ForEach_FilteredSubs">
              <bpelx:skipCondition>ora:countNodes('SubscriptionsList','FilteredSubscriptions') = 0</bpelx:skipCondition>
              <startCounterValue>1</startCounterValue>
              <finalCounterValue>ora:countNodes('SubscriptionsList','FilteredSubscriptions')</finalCounterValue>
              [...]
              </forEach>
              regards,
              mathieu

              Edited by: mathieu.d on Feb 14, 2013 1:19 AM