Multiple HTTP Requests in for loop response handling

i am working on stock market portfolio. a user saves his stock name , buy price ,etc .i've added this details in database.but while viewing his portfolio he should even get the current price of d stocks he has added. while retrieving i fetch all data from database set them in a bean and for each stock i make a HTTP Request. in result handler i event set the current price into the bean. Problem is my entire application is displayed with all the CurrentPrice fields with null.
private function selectContacts():void
    trace("select before");
    stmt.sqlConnection = this.isDbConnected(conn);
    stmt.text = "SELECT * FROM stocks_t";
    stmt.addEventListener(SQLErrorEvent.ERROR, sqlError);
    stmt.addEventListener(SQLEvent.RESULT, sqlResult);
    stmt.execute();
    trace("select after");
private function sqlResult(res:SQLEvent):void{
    httpServ = new HTTPService();
    data1 = stmt.getResult().data;
    stockList = new ArrayCollection();   
    for(var d:int=0;d<=data1.length-1;d++)
        myPortfolioBean = new MyProtfolioBean();
        httpServ.url = 'http://quote.yahoo.com/d/quotes.csv?s='+data1[d].stockName+'&f=snl1a';
        httpServ.method = 'GET';
        httpServ.addEventListener(ResultEvent.RESULT,yDataResult);
        httpServ.addEventListener(FaultEvent.FAULT,yDataFault);
        httpServ.showBusyCursor= true;
        httpServ.send();
        myPortfolioBean.stockNameB = data1[d].stockName;
        myPortfolioBean.buyB = data1[d].buy;
        myPortfolioBean.quantityB = data1[d].quantity;
        myPortfolioBean.totalQuantityAmountB = data1[d].totalQuantityAmount;
        myPortfolioBean.profitB = data1[d].profit;
        stockList.addItem(myPortfolioBean);
public function yDataResult(evt:ResultEvent):void
    var s:String = evt.result as String;
    var a:Array = s.split(",");
    //To add to a form or individual fields
    lastTraded =  a[2].toString();
    lastTradedFloat = parseFloat(lastTraded);
    myPortfolioBean.currentB = lastTradedFloat;
    stockList.addItem(myPortfolioBean);
    //stockList.addItem({current:lastTradedFloat});
the yDataResult() is called after the entire datagrid is displayed on screen as a result of which the CurrentPrice in datagrid column in null. Eg: user has added google ,yahoo,apple( CurrentPrice  is null for all three values) after some time three more rows (as a result of call to yDataResult) with CurrentPrice xx.xx displayed. I want merged results.

hello ,
"CurrentPrice" is "lastTradedFloat" sorry for the ambiguity.
and u got my problem but there is an issue ..
all the results are set using "sqlResult" except the "lastTradedFloat" which is set in "ydataResult".
but i confused with HTTP ResultEvent Execution.
first "sqlResult" method is called arrayCollection is populated. then result is displayed on screen.( lastTraded value is null then)
then "ydataResult" executes again manipulating data in arraycollection.
what i want is data in "sqlResult" and "ydataResult" to be set sequentially then callin my display page . such that display is correct.

Similar Messages

  • How best to make a transaction span multiple HTTP requests?

    Hi, all. What is the best way to implement a transaction that spans multiple
    HTTP requests? Many J2EE applications must solve this problem, but I can't
    any guidelines for an implementation.
    Consider an application that implements a multi-step wizard. Each step
    gathers data from the user; step one gets the user's name, and step two gets
    his dog's name. When the user completes the wizard, the application saves
    the user & dog in two entity beans. Conceptually, the application treats
    this wizard like a single, long-running transaction. The transaction begins
    when the user launches the wizard. Submitting the JSP for step one adds the
    Boy bean to the transaction, and submitting step two adds the Dog bean.
    Finishing the wizard commits the transaction. Exiting the wizard or timing
    out causes the transaction to rollback.
    Although the wizard looks like a transaction, the entire sequence of user
    interactions can't be captured in a single JTA UserTransaction. A
    UserTransaction must be associated with a single thread, but each wizard
    step is handled asynchronously by its own execution thread. It's impossible
    to funnel the conversation through one thread that can demarcate the
    transaction. (This would be a pretty dumb solution for other reasons, but I
    don't want to get lost in details.)
    I think the standard way to solve this problem is to store conversation
    state in a stateful session bean (or the http session) and create / update
    both entity beans in a transactional EJB method after the wizard completes.
    Unfortunately, this solution prevents me from leveraging a lot of great
    transaction management features provided by the app server. For example, I
    can't use optimistic concurrency to make sure that the dog object hasn't
    changed in the database between the start and end of the wizard. Also, I'm
    forced to keep track of changes to the dog object in the conversation state,
    then replicate these changes to an entity bean at the end of the wizard.
    Keeping track of state in a stateful bean is pretty straightforward, but it
    seems like there must be an existing solution that leverages the appserver's
    concurrency and state management features. Am I missing something? Is there
    code, a pattern, or an article that describes the best way to implement a
    multi-step process that looks transactional? I suppose WLI does what I want,
    but that feels like killing a roach with a SCUD missle. Thanks for any
    advice.
    Dave

    Dave Smith wrote:
    Without a transaction, will the app server manage the version column
    automatically, assuming of course that <concurrency-strategy> is
    "Optimistic" and <verify-columns> is set to "Version"? Of course, I'll have
    to expose the version as a cmp-field, which is fine with me.Yes
    >
    Do you know offhand, so that I don't have to get off my lazy ass and write a
    test, whether the CMP service will create the version column when it
    generates db tables? (I realize it's not good to let WLS generate the tables
    in a production system.)No, I don't think it does.
    >
    I assume from your answer that I'm on my own for implementing stuff like and
    transaction inheritance and tracking object modifications? Well, we'll give you a bit of help on the object modifications. The
    usual pattern is when you're pushing the JavaBean back to the CMP you
    call all the setXXX methods on the CMP bean. Our CMP container will
    check if the value you are setting is the same as read from the db. If
    so, it will not update that column.
    -- Rob
    If so, no big
    deal. I was just hoping somebody would say, "Oh, you want the Jakarta
    SuperBeans project" or something.
    Thanks,
    Dave
    "Rob Woollen" <[email protected]> wrote in message
    news:[email protected]...
    I'd recommend that you include a separate version or timestamp column in
    your db schema.
    Then do something like this:
    Client Server
    1) First HTTP Request
    2) Read current Dog and Boy Entity Beans
    (if any) and copy their values into a JavaBean.
    You want to include the version
    column(s) in the JavaBean(s) along with the data values.
    You probably also want to store the JavaBeans in
    your HTTP Session.
    3) Client proceeds through wizard interacting with JavaBeans
    4) Finish with Wizard, copy JavaBean values (including
    version columns) to CMP 2.0 Entity Beans.
    The version column will give you the optimistic concurrency protection
    that you desire without opening a JTA transaction to span user input.
    -- Rob
    Dave Smith wrote:
    Hi, all. What is the best way to implement a transaction that spans
    multiple
    HTTP requests? Many J2EE applications must solve this problem, but Ican't
    any guidelines for an implementation.
    Consider an application that implements a multi-step wizard. Each step
    gathers data from the user; step one gets the user's name, and step twogets
    his dog's name. When the user completes the wizard, the applicationsaves
    the user & dog in two entity beans. Conceptually, the application treats
    this wizard like a single, long-running transaction. The transactionbegins
    when the user launches the wizard. Submitting the JSP for step one addsthe
    Boy bean to the transaction, and submitting step two adds the Dog bean.
    Finishing the wizard commits the transaction. Exiting the wizard ortiming
    out causes the transaction to rollback.
    Although the wizard looks like a transaction, the entire sequence ofuser
    interactions can't be captured in a single JTA UserTransaction. A
    UserTransaction must be associated with a single thread, but each wizard
    step is handled asynchronously by its own execution thread. It'simpossible
    to funnel the conversation through one thread that can demarcate the
    transaction. (This would be a pretty dumb solution for other reasons,but I
    don't want to get lost in details.)
    I think the standard way to solve this problem is to store conversation
    state in a stateful session bean (or the http session) and create /update
    both entity beans in a transactional EJB method after the wizardcompletes.
    Unfortunately, this solution prevents me from leveraging a lot of great
    transaction management features provided by the app server. For example,I
    can't use optimistic concurrency to make sure that the dog object hasn't
    changed in the database between the start and end of the wizard. Also,I'm
    forced to keep track of changes to the dog object in the conversationstate,
    then replicate these changes to an entity bean at the end of the wizard.
    Keeping track of state in a stateful bean is pretty straightforward, butit
    seems like there must be an existing solution that leverages theappserver's
    concurrency and state management features. Am I missing something? Isthere
    code, a pattern, or an article that describes the best way to implementa
    multi-step process that looks transactional? I suppose WLI does what Iwant,
    but that feels like killing a roach with a SCUD missle. Thanks for any
    advice.
    Dave

  • How to post multiple http requests using a single http connection in java

    I am using the httpurlconnection class and it allows only to post one request on a connection. I require to post multiple http requests by opening a single connection. Code examples please. Thanx in advance.

    Hi
    I found this article through Google. I hope it helps a little
    http://www.developer.com/tech/article.php/761521
    D

  • Multiple HTTP requests using single HTTPService component

    Hi,
    I am having one requirement, I need to use a single HTTPService component to send request to a same and single ASP.net multiple times.
    How can I acheive that..? I know that I can acheive this by sending one request at a time and after the "result" event is called for the first request then sending the second request and so on...
    But if I do so then it will be delayed response as I need to wait until the result handler for the previous request is called...
    So how do I do this..?
    Any help greatly appreciated....:)
    Thanks in advance..
    Thanks,
    Bhasker Chari

    yep, the setting works when set to 10. Seemed to not work when set to 20. Anyways, summary is "long polling" and Flex
    or Flash are not good compatriates. So, you will need to work out your own mechanism on the server or client
    side to limit the sockets used/wasted. Painful but true.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    import com.util.HTTPServiceProxy; 
    import mx.rpc.events.FaultEvent; 
    import mx.rpc.events.ResultEvent; 
    import mx.rpc.http.HTTPService; 
    private var urlOpenTasksDefault:String = HTTPServiceProxy.servercontext + "/blahblah?something=somethign";  
    private var waitRequestPart:String = "&wait=5000&lastUpdate=" // long polling period for now for testing
    private var iResponses:int; 
    private function runTest(urlString:String):void{ 
    var service:HTTPService = new HTTPService();service.url= urlString;
    service.resultFormat =
    "e4x";service.method =
    "get";service.contentType=
    "application/xml";service.addEventListener(
    "result", httpResult);service.addEventListener(
    "fault", httpFault);service.send();
    public function httpResult(event:ResultEvent):void { 
    trace("httpResult " + iResponses++ );}
    public function httpFault(event:FaultEvent):void { 
    trace("httpFault " + (iResponses++) + event.fault.faultString);}
    private function test1(evt:Event):void {iResponses=0;
    var reqs:int = parseInt(requests.text); 
    for( var i:int=0; i<reqs; i++ ){runTest(urlOpenTasksDefault);
    private function test2(evt:Event):void {iResponses=0;
    var reqs:int = parseInt(requests.text); 
    for( var i:int=0; i<reqs; i++ ){runTest(urlOpenTasksDefault+waitRequestPart+
    "0");}
    ]]>
    </mx:Script> 
     <mx:Label text="Requests"/>
     <mx:TextInput id="requests"/>
     <mx:Button label="Test Requests-Responses" click="test1(event)"/>
     <mx:Button label="Test Long Polling" click="test2(event)"/></mx:Application>

  • ICF service with Multiple HTTP request handlers.

    Hi ,
    I have created a ICF service with "One HTTP request handler" using SICF transaction.
    it's working fine.
    After that  i have added anther "HTTP request handler".
    i have put  two External Break Points in two HTTP request handler classes.
    and i have debugged it.
    My problem is:
    The request is cached by first HTTP request handler.
    at the end it returns the response.
    it does not reached the second HTTP request handler.
    how can i forward my request to second HTTP request handler.
    please help me.
    lakshman

    Hi,
    Frankly I dont know too much on this topic but following links may help you:
    http://help.sap.com/saphelp_nw04/helpdata/en/25/dda73e5b7a424de10000000a114084/frameset.htm
    Troubleshooting ICF: http://help.sap.com/saphelp_nw04/helpdata/en/80/b2dd3a6dac703be10000000a11405a/content.htm
    Possibly experts in this forum will be able to help you:  Application Server->Internet Transaction Server (ITS)
    Regards,
    Gourav

  • BPM: IDoc to multiple HTTP-Requests

    Hello!
    I'm currently working on a scenario which is described as followed:
    My XI-System is receiving an IDoc from an SAP R/3-System.
    This IDoc contains a list of numbers together with the respective name of the customer an our internal customer number.
    Structure:
    IDoc
    |
    area01
       |
       |-NUMBER01
       |
       area02
         |
         |-NUMBER02
         |-CUSTNAME
         |-CUSTNUMBER
    This IDoc has to be split up in HTTP-Request to a server in the WWW. Each HTTP-Request consists of an URL together with two specific parameters (eg: http://www.xyz.com?param1=P1&param2=P2, where param1 is NUMBER01 from the IDoc and param2 is NUMBER02)
    I have two different problems:
    First one is that my BPM is showing errors with the transformation step (IDoc to single HTTP-Requests). It shows the "Expression must return the interface type xxxx"-error. I have mapped the incomming-IDoc into a abstract interface IDoc, as described in other topics.
    What is to be done, to convert the incooming IDoc into several HTTP-Requests? How can i solve this issue?
    Second one is the HTTP-Request itself.
    I've read the hints about the adapter specific settings and tried the HTTP-Request in a little "extra"-scenario. But it didn't work very well...I other words: It did nothing. How to map the two parameters to my specific HTTP-parameters?
    If I have to describe something more detailed, please let me now. I appreciate any suggestions!
    Many many thanks in advance,
    Roman Scholz

    Hi Roman,
    >"Expression must return the interface type xxxx"-error.
    The target of your interface mapping has to be the abstr interface used for BP container.
    >What is to be done, to convert the incooming IDoc into several HTTP-Requests?
    <a href="/people/sudharshan.aravamudan/blog/2005/12/01/illustration-of-multi-mapping-and-message-split-using-bpm-in-sap-exchange-infrastructure of Multi-Mapping and Message Split using BPM in SAP Exchange Infrastructure</a>
    >How to map the two parameters to my specific HTTP-parameters?
    <a href="http://help.sap.com/saphelp_nw04/helpdata/de/43/64dbb0af9f30b4e10000000a11466f/frameset.htm">Configuring the Receiver Plain HTTP Adapter</a>
    Regards,
    Udo

  • Business Service with multiple HTTP Request Methods

    hi all -
    I'm new to OSB and trying to prototype a solution. I have a service provider that exposes a number of HTTP operations (GET/PUT/POST/DELETE). It's a JAX-RS implementation.
    I was looking to create 1 proxy service and 1 business service for that service provider. But, within my business service, I must chose a 'HTTP Request Method' and it allows only 1 type (either GET, PUT, POST, DELETE). So, I have something working, but only for a single type (POST in my prototype). I figure I could create more proxy and business services for the other HTTP Request Methods, but I'm not sure if this is the correct approach (design/architecture).
    My other thought was to create a proxy service to front the service provider, but looking at the documentation, it looks like there should be a business service for each proxy service. If it's possible to use a proxy service without a business service to mediate the service provider, where would I add my URLs for the service provider in the proxy service.
    My apologies on the 2 part architecture/design question. I thought the group would help with getting me started.
    thanks jim

    Hi,
    Frankly I dont know too much on this topic but following links may help you:
    http://help.sap.com/saphelp_nw04/helpdata/en/25/dda73e5b7a424de10000000a114084/frameset.htm
    Troubleshooting ICF: http://help.sap.com/saphelp_nw04/helpdata/en/80/b2dd3a6dac703be10000000a11405a/content.htm
    Possibly experts in this forum will be able to help you:  Application Server->Internet Transaction Server (ITS)
    Regards,
    Gourav

  • Create multiple VIs using a for loop

    Hi,
    I'm still pretty new to LabVIEW, so this question might be easy for you guys here..
    I'll simplify what I'm trying to do.
    I've got two numeric controllers that act as the rows and columns of a matrix.
    I'd like to take those numbers from these two controllers and use them to create a matrix of a certain picture.
    Example:
    The rows controller is given 3, and the columns controller is given 4.
    Using these numbers I would like the end result to show a certain image (let's say, a cube) multiplied on a 3 by 4 matrix.
    Let's say the picture is an X, then the end result should be:
    XXXX
    XXXX
    XXXX 
    I think I should be using a double for loop (one inside the other obviously), and I should also create the "position" property in order to display each picture of the cube in it's right place.
    The problem is that I don't know how to CREATE the pictures over and over again, while being able to control each one's position property.
    Any help would be GREATLY appreciated!
    Solved!
    Go to Solution.

    1) By "multiple VIs" I meant that I think that I need to create express VIs on the fly while running the for loop. I might be totally wrong here.
    2) Yes, by "numeric controllers" I meant numeric controls in the front panel.
    3) The matrix I'm referring too isn't an object nor a VI in LabVIEW but a virtual matrix that is the end result. I used the term "matrix" because the end result is actually a matrix (of rows and columns) of pictures..
    I'll try to elaborate and even simplify it more:
    Let's say I want to display one picture. That's easy, no problem there.
    Now let's say that I'd like to display n pictures on a one dimensional array. Just one row.
    What I think I need to do is to read from the numeric control in the front panel the number (n) of pictures, and then create them in a for loop, while using the "position" property to set the distance between each picture (using coordinates).
    My original question was just like the above, but for a two dimensional matrix/array. So I guess we can even simplify it even more, by saying it's only one dimensional.
    My way of action here might be totally wrong, and there might be an easier way or another way to go about this...
    Thanks for the quick answer!!  

  • Returning multiple values with SELECT FOR LOOP

    Oracle EE 11gR1
    PL/SQL
    OEL 5.8
    ===========
    Would like to know how to do the following?
    for x, y in (select name, street
    from employees
    where hire_date < sysdate - 100)
    loop
    In other words, is there a way to handle 2 (or more) values in a SELECT FOR LOOP structure? If not, then how to accomplish the same task.
    The above does not work of course. :-)
    Appreciate any and all advice.

    Yes, just have one name in your for loop and that becomes the equivalent of a table name and reference the columns as that name.column name
    for t in (select name, street
       from employees
      where hire_date < sysdate - 100)
    loop
      dbms_output.put_line('name = '||t.name);
      dbms_output.put_line('street = '||t.street);
    end loop;

  • Multiple HTTP requests through same connection

    Hi...
    I am writing an application which connect to its server through HTTP protocol and the server is basicaly a bunch of servlets hosted somewhere (Right not it in the tomcat running in my PC)
    I know that with Connection Keep-Alive header you can keep the connection alive and do multiple requests from the same server.
    Can some one point me to where can I find some sample code which shows how to send multiple requests through same URL conection or URL object. What i cant figure out is how to reset the URL connection or its streams a and make them send anotehr request message to the serverso server can respond.
    Or do I have to do this manualy (using sockets)

    You SHOULD be able to do a HttpUrlConnection method. However, I have hand-coded HTTP server and client apps and the keep-alive is rarely enabled in servers.
    This is due to better handling of millions of unique hosts requesting, unlike a network os, which is made the other way around.

  • In ActionScript 2.0 , How can I send HTTP request and get the response in JSON format.

    I am using ActionScript 2.0 for my app development. I have checked XML and LoadVars class. These classes by default send/receive data either in XML or name/value pair format. I want to send data in JSON format and receive the response in JSON format. How can I achieve this behavior using AS2.0. I have noticed that AS3.0 has the capabilities to do so. My client platform doesn't support AS3.0. Can anybody suggest a way to achieve this?
    Thanks in Advance.

    Atlast I am able to find the solution for this problem. In the end solutioin is very simple.
    Following steps will help in sending request in JSON format.
    1. extend LoadVars class
    2. override toString method. (It should return JSON format )
    3. Use subclass to send the request.

  • How to call two variable which are hold multiple value  in to for loop

    hi,
    i have 4 item ,Two Select List And Two Check Box .Class id And Section are select list and student id and subject id are check box .i want to insert More then one subject id in to table corresponding to more then one student id .
    eg. when i select class id 1 and section A then student id of class 1 and section A comes into Student id(check box item ) and all subject corresponding to class 1 comes into subject id( check box item).
    now i want to insert multiple selected subjects with respect to selected multiple student id in to table when i press submit Button.
    My table is
    CREATE TABLE "STUDENT_SUBJECT_DETAIL"
    (     "S_NO" NUMBER,
         "STUDENT_ID" NUMBER,
         "SUBJECT_ID" VARCHAR2(50),
         "SESION" VARCHAR2(50)
    i am using this Code
    DECLARE
    STU wwv_flow_global.vc_arr2;
    SUB wwv_flow_global.vc_arr2;
    begin
    STU:= wwv_flow_utilities.string_to_table(:P57_STUDENT_ID);
    SUB := wwv_flow_utilities.string_to_table(:P57_SUBJECT_ID);
    for i in 1..STU.count loop
    for i in 1..SUB.count loop
    insert into STUDENT_SUBJECT_DETAIL
    values(CLA_SUB_ID_SEQ.nextval,STU(i),SUB(i),:p57_SESION);
    end loop;
    end loop;
    END;
    Edited by: Manoj Kaushik on Nov 20, 2009 10:10 PM

    DECLARE
        STU wwv_flow_global.vc_arr2;
        SUB wwv_flow_global.vc_arr2;
    BEGIN
        STU:= wwv_flow_utilities.string_to_table(:P57_STUDENT_ID);
        SUB := wwv_flow_utilities.string_to_table(:P57_SUBJECT_ID);
        FOR i in 1..STU.count LOOP
            FOR i in 1..SUB.count LOOP
                insert into STUDENT_SUBJECT_DETAIL
                values(CLA_SUB_ID_SEQ.nextval,STU(i),SUB(i),:p57_SESION);
            end loop;
        end loop;
    END;This doesn't look right to me:
    1. You have 2 loops, and they are both using the variable i as a counter.
    2. Your insert needs to be in the form: insert into table (column names) values (values to insert)
    3. Why not use a trigger to get the nextval from the sequence?
    Trent
    Edited by: tr3nton on Nov 21, 2009 4:16 PM

  • Multiple shift registers in For loop

    I'm using multiple shift registers to find the number of different string in a string array. However, the shift register got refreshed every time it finds a different string and returns back to 0. How can I have the register remember its previous value after it encounters a new string value?
    Solved!
    Go to Solution.
    Attachments:
    count.vi ‏19 KB

    You should think about making your code scalable. At the moment, you need to re-architect the VI from scratch whenever the sensor names or their number changes. If you suddenly have 1000 sensor names, the code would be unmamangeable because the sheer number of cases and shift registers!
    Attached is an simple alternative. As you can see, the code remains the same, even if the number of sensors or their names changes in the future. See if it makes sense. (You can easily modify it to also count unrecognized names, for example).
    Modify as needed.
    Some other possible bugs in your VI:
    You should initialize the shift register with zero, not one. Right now the results are one too high.
    Case "B" is actually "B." and the count is only accidentally correct because it is also the default case and there are no other sensor names (e.g. F) in the input array.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CountMOD.png ‏19 KB
    countMOD.vi ‏19 KB

  • Multiple HTTP Servers, 1 for HTTP and other for HTTPS

    I am trying to install 9ias 1.0.2.2.2 on 2 machines both running solaris. 1st machine hosts the database (8.1.7.4) and the other hosts the App server (9ias), what i am tryin to achive is have 2 listeneres. One for HTTP traffic and other for HTTPS traffic. Have anyone configured this and could shed some light and enlighten me.
    With all the notes i have read i have understood that i need to basically install 2 instance of Apache in 2 different Oracle Homes. but my question is how can i just have one portal repository. or rather i should say if somebody could guide me from installing the 2 instance of Apache.
    Thanks
    Mir

    You left out Twixl.
    Bob

  • FOR Loop Exception Handling

    Given the following code:
    for x in my_cursor loop
        begin
            <<stmt_1>>
            <<stmt_2>>
        exception
            when others then
                <<log_error>>
        end;
    end loop;Say there are 5 x's in my_cursor. On element x3, stmt_1 works fine but stmt_2 throws an exception. I'd like to rollback ONLY the work done on x3 (in this case, stmt_1), then continue the loop from the next element, x4. Can this be achieved with some combination of savepoint/rollback?

    As I said, you can put the increment operation at the end of the block when you know no more exceptions could be raised, i.e.
    declare
        cnt number;
        ex  exception;
    begin
        cnt := 0;
        for x in 1..5 loop
            begin
                savepoint s;
                insert into test_tbl values(1/(3-x));
                cnt := cnt+1;
            exception
                when others then
                    rollback to savepoint s;
            end;
        end loop;
        dbms_output.put_line('cnt='||cnt);
    end;You could also increment the counter outside of the PL/SQL block, i.e.
    declare
        cnt number;
        ex  exception;
        num_success number;
    begin
        cnt := 0;
        for x in 1..5 loop
            begin
                num_success := 0;
                savepoint s;
                insert into test_tbl values(1/(3-x));
                num_success := sql%rowcount;
            exception
                when others then
                    rollback to savepoint s;
            end;
            cnt := cnt + num_success;
        end loop;
        dbms_output.put_line('cnt='||cnt);
    end;And you can refactor your code so that the components to hide some of this complexity, i.e.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure try_insert_test_tbl(
      2    p_val in number,
      3    p_num_success out number )
      4  as
      5    divide_by_zero exception;
      6    pragma exception_init( divide_by_zero, -1476 );
      7  begin
      8    savepoint s;
      9    insert into test_tbl values( 1/(3-p_val ) );
    10    p_num_success := sql%rowcount;
    11  exception
    12    when divide_by_zero
    13    then
    14      p_num_success := 0;
    15* end;
    SQL> /
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2      cnt number;
      3      ex  exception;
      4      num_success number;
      5  begin
      6      cnt := 0;
      7      for x in 1..5 loop
      8          try_insert_test_tbl( x, num_success );
      9          cnt := cnt + num_success;
    10      end loop;
    11      dbms_output.put_line('cnt='||cnt);
    12* end;
    SQL> /
    cnt=4
    PL/SQL procedure successfully completed.There is no way for DCL statements to affect the state of PL/SQL variables. But you can generally structure your code in such a way that this is unnecessary.
    Justin

Maybe you are looking for

  • Change of cost amount in service order

    Dear Guru's when we create the cost in KP26 Transaction code by giving the fields version,period,fiscal year,cost center,activity type  after that we will maintain the Fixed or Variable price maintained. Now i want to change the price. kindly help me

  • IExplorer open xml as read only

    Hi! We have two problem... When we save an excel file, as an XML file... it doesn't save <?xml version="1.0" encoding="windows-1250" ?> to the first line.. So we get error when we provide UTF-8.. Second.. (the worst problem) When we open xml files fr

  • Low Battery rejected IOS 7 upgrade at the end of the upgrade

    Attempted to upgrade the Ipad 4 after it gave me a warning that battery is low (was at 37%). Do you want to continue? I answered YES. The install continued for about 20 minutes. When it was "done" the error message popped up that install was unsucces

  • Fmt:formatDate with incoming parameter

    I have a bean that has a set method that takes in a java.sql.Date object. public void setStartDate(java.sql.Date newValue){      startDate= newValue; }This is used in a PreparedStatement to retrieve data from the database. I am pulling the value from

  • ADOBE WONT INITIALIZE FROM ANOTHER USER THAT SENDS DOCS TO OPEN USING ADOBE

    ADOBE WONT INITIALIZE SENDING DOCS FROM ANOTHER (ie_ BANKS SENDING TRANS DATA) TO OPEN USING ADOBE 11. NO ONE HAS SOLUTION...