Avoiding writing same function twice

Hello,
I want to avoid writing XMLSocket.prototype.onData = function(msg) twice.
The msg static data are sent only at the first time.  It includes data for populating combo.  Depening on the combo selection, different set of data from msg are displayed.
mySocket = new XMLSocket();
mySocket.connect("127.0.0.1", 9999);
System.security.loadPolicyFile("http://localhost/sockets/flash_policy.php");
mySocket.onConnect = function(success) {
    if (success) {
        msgArea.htmlText += "<b>Server connection established!</b>";
        mySocket.send("connected"+"\n");
    } else {
        msgArea.htmlText += "<b>Not Connected</b>";
mySocket.onClose = function() {
    msgArea.htmlText += "<b>Server connection lost</b>";
//for displaying static data
XMLSocket.prototype.onData = function(msg) {
    //trace(msg);
    arr = msg.split("&");
    textHeadline.htmlText += arr[0];
        comboBox(arr);   
function displayData(combo_id)
XMLSocket.prototype.onData = function(msg) {
    arr = msg.split("&");
    textA.htmlText += arr[1];   
    textB.htmlText += arr[2];
function comboBox(arr)
  //combo code
  //selected combo id is sent to displayData
   displayData(combo_id);
Thanks

I have been thinking along the lines of what Wayne said.
Can I initialise the Assistant by calling it outside the loop, but with a True constant on the 'stop' input, and then run the rest of the function as normal? Would I not get the error about 'resource is reserved ' or in use or whatever it is?
Stephen : I have tried troubleshooting by stepping through the execution, but I find it doesn't run accurately. Since the function stops recording when a succession of near-identical points are detected (when the piston stops), if I run it in 'highlight execution' mode it will get 5000 points each for retract and extend (assistant is set to 1k buffer size, 5 successive similar points stops the execution). 
I will fool around with setting up the function before the loop, until someone gives more suggestions.

Similar Messages

  • Calling a js function twice on the same event

    hello all,
    I am a new HTML programmer and I have a simple question...
    I am using a small js script to play .wav files on my website, and I want to play multiple files in sequencial order by calling the same function twice, with a different argument both times. I am using this code:
    Code:
    <div id="apDiv44" onclick="EvalSound('ColorTop');EvalSound('Globe');EvalSound('Blue')"></div>
    I think i've got the separators correct, but for some reason, when I click my image, all of the .wav files are playing at the same time. could i please get some assistance? thank you very much...
    (i have gotten some previous feedback regarding breaks between calls, and even a sound playlist option, but those are out of my reach in terms of my knowledge for the moment)...

    It did not work in firefox because it requires object  and not embed try -
    <object classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"
                 type="application/x-oleobject" width="280" height="67"
    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
                 standby="Loading Microsoft Windows Media Player components...">
            <param name="url" value="test.m3u">
            <param name="autostart" value="false">
            <param name="ShowStatusBar" value="true">
            <param name="volume" value="100">
            <!-- For other browsers * Default M3U plugin -->
            <!--[if !IE]> <-->
         <object data="test.m3u" type="audio/x-mpegurl" height="16" width="240">
           <param name="autostart" value="false">
         </object>
    You will have to change the two references to test.m3u to your m3u file.
    PZ

  • Avoid Math.random() from looping the same number twice?

    I'm trying to play a random gallary image by making it stops at different frame every few seconds, and the actions is completely random.
    The problem is, since there are only 5 different images(5 frames) I'm displaying, there is a high probability that it stays at the same frame, how do I avoid that? Like avoid staying at the same page twice, if not run the function again....?
    setInterval(createItems,throwItems);
    var RandomImg:randomImg =new randomImg();
    RandomImg.y=100;
    RandomImg.x=180;
    RandomImg.gotoAndStop(Math.floor(Math.random()*(1+5-1))+1);//generate random value between 1-5
    addChild(RandomImg);
    Thanks

    How do I keep track of the random value, like what value should I put within the if to compare?
    I try modify it a little, and wrap it within an if(), and use preValue to track down the previous frame, am I doing it right?
    setInterval(createItems,throwItems);
    var preValue:Number;
    function createItems():void
         var RandomImg:randomImg =new randomImg();
         var randomFrame= Math.floor(Math.random()*(1+5-1))+1; //generate random value between 1-5
         RandomImg.y=100;
         RandomImg.x=180;
         RandomImg.gotoAndStop(randomFrame);
         if(preValue == randomFrame)
              RandomImg.gotoAndStop(Math.floor(Math.random()*(1+5-1))+1);
              addChild(RandomImg);
              preValue = randomFrame;
         }else
                        addChild(RandomImg);
                        preValue = randomFrame;

  • I want to buy Production Premium CS6, but I already own Flash Professional.  Is there a way I can avoid paying for the same product twice?

    I have a feeling I already know the answer to this question, but I figured it was worth asking anyway.
    Just under a year ago, I purchased Flash Professional CS6 for school.  Now that I am expanding my practices, I am interested in purchasing the Production Premium bundle of programs.  However, it already comes with Flash CS6, and if I can avoid paying for the same product twice, I'd like to do so.
    Is it possible for me to either get some kind of discount on the suite since I already own one of the programs?

    I have a feeling I already know the answer to this question, but I figured it was worth asking anyway.
    Just under a year ago, I purchased Flash Professional CS6 for school.  Now that I am expanding my practices, I am interested in purchasing the Production Premium bundle of programs.  However, it already comes with Flash CS6, and if I can avoid paying for the same product twice, I'd like to do so.
    Is it possible for me to either get some kind of discount on the suite since I already own one of the programs?

  • How to Avoid Printing the data twice when the sub report has drill down?

    Hello,
    I have a sub report that has drill down which is placed in report footer.When i run the report sub report displays the data but when i tried to drill down it displays the same data again.After that i can able to drill down on sub report.Is there any way to avoid
    printing the same data twice.
    Thanks in advance.

    Hi,
    If the subreport you're referring to does not grow in size and it does not span multiple pages and you know the size of it, here's what you can do to stop drilling into subreports :
    1) Create a text object as large as the subreport (perhaps bigger than it) and fill it with spaces or new lines
    2) Place it 'over' the subreport such that it covers the entire area occupied by the subreport
    3) The subreport at all times should be smaller than the text object in all dimensions
    Now, when you hover the mouse over the subreport, there isn't any magnifying glass for you to drill down into.
    If the subreport has further drill-down functionality, then this isn't for you! Because, it just wouldn't allow you click on any objects in the subreport because of the text object eclipsing it. This is the only workaround I know at this point in time and I know a lot of users are looking for this.
    I would suggest that you log this as an Enhancement Request at http://ideas.sap.com for our developers to have a look into this.
    And finally, I also found an old forum post where Jamie has suggested a way to get this working on the Business Objects Environment. Give it a shot, if that's where the reports are eventually run.
    How to disable subreport view
    Hope this helps!
    -Abhilash

  • Can I use the same SSI twice in same page?

    Hey all,
    i'm having a problem whereby several SSI's are not showing on my page.
    I'm wondering if it's because the instances that are not showing are the ones called the second time round.
    Before i start posting code etc, i just wondered if it was actually not possible to call the same SSi more than one time on a page.
    I can't seem to find documentation stating this anywhere.
    Thanks in advance,
    Katrina
    Edit 1: I tested using a new unique SSI (i.e. one that wasn't called anywhere else on teh page, and it doesn't show either... so I've started a new thread where i post my code here: http://forums.adobe.com/message/5345250#5345250
    Edit 2: I guess i didn't test properly initially. It seems it is NOT possible to use the same SSI twice on a page...   What a bummer!!!

    This issue was resolved in a different thread where s member supplied the following information...
    t's certainly possible depending on the PHP command which you use as the include directive.
    <?php require_once('includes/include-address.php'); ?> will only include the file once
    <?php require('includes/include-address.php'); ?>  will include the file more than once
    <?php include('includes/include-address.php'); ?>  will include the file more than once
    Each has its own rules and quirks.
    http://php.net/manual/en/function.require-once.php
    http://www.php.net/manual/en/function.include.php
    http://www.w3schools.com/php/php_includes.asp

  • Same function gathers different number of points in different calls?

    I am running an automated test program, testing moving pistons. The test will extend the piston, and gather position data via some pots, and current data, while its moving. It will then retract the piston, and do the same data gathering. It then does some other tests.The data is written to some files, and is then retrieved for post-test processing later on.
    I use the same function for extending and retracting, and I am noticing that the number of data points gathered during the extend is always much less than the number of points gathered during the retract.
    This is the 3rd version of function I have used to gather data from the test apparatus, and this issue has stuck with all 3 versions . I have attached the function to this post. The top-level VI is large and contains many lower-level VIs, so I can't include the whole thing. I am using a USB 6008, LV8.5, Daqmx 8.5.
    Any ideas why this would run differently each call? 
     Explanation of the function:
    The gray box VI with 'NI' is a subvi that communicates with a controller for the tester. It sends the position to move the piston to. In the loop, the daq assistant grabs data from the 6008, and looks at pot values. If the values are close enough together, several times, it stops the loop and the data gathering (the piston has reached the end of its stroke). After the data gathering loop, the rest of the function is for writing data to a file.
    NOTE that only the 'true' case inside the while loop matters here, as thats where the problem lies.
    PS. sorry the front panel looks like crap, because this is a subvi so its front panel is never seen.
    Solved!
    Go to Solution.
    Attachments:
    move_actuator_rev3.vi ‏341 KB

    I have been thinking along the lines of what Wayne said.
    Can I initialise the Assistant by calling it outside the loop, but with a True constant on the 'stop' input, and then run the rest of the function as normal? Would I not get the error about 'resource is reserved ' or in use or whatever it is?
    Stephen : I have tried troubleshooting by stepping through the execution, but I find it doesn't run accurately. Since the function stops recording when a succession of near-identical points are detected (when the piston stops), if I run it in 'highlight execution' mode it will get 5000 points each for retract and extend (assistant is set to 1k buffer size, 5 successive similar points stops the execution). 
    I will fool around with setting up the function before the loop, until someone gives more suggestions.

  • End user receving same mail , twice in a day .

    Hi,
    Throu this report , i am sending mail to a user. I the scheuld this program as background job.
    But My problem is end user receving same mail twice a day.I am sure , Program is executed onces in day.
    Plz help me to solve the problem
    REPORT  zplm008_tdr_mail_alert        .
    *DATA DECLARATION.
    DATA: it_ztdr TYPE TABLE OF ztdr WITH HEADER LINE.
    DATA  wa_maktx TYPE makt-maktx..
    *SELECTION SCREEN
    PARAMETER: p_date TYPE sy-datum DEFAULT sy-datum MODIF ID dat .
    *START-OF-SELECTION
    START-OF-SELECTION.
      SELECT * FROM  ztdr INTO TABLE it_ztdr
             WHERE  rlddt  = p_date.
      IF it_ztdr[] IS NOT INITIAL.
        LOOP AT it_ztdr.
          PERFORM send_mail.
        ENDLOOP.
      ENDIF.
    *&      Form  SEND_MAIL
          text
    -->  p1        text
    <--  p2        text
    FORM send_mail .
      DATA: lt_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                       WITH HEADER LINE.
      DATA:   ls_message TYPE char255.
      DATA: lt_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            lt_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            lt_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            lt_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            gf_cnt TYPE i,
            gf_sent_all(1) TYPE c,
            gs_doc_data LIKE sodocchgi1,
            gf_error TYPE sy-subrc.
          Adds text to email text table
      lt_message = 'Hi,'.
      APPEND lt_message.CLEAR lt_message.APPEND lt_message.
      lt_message = 'Requested design is released. Pls raise the TPR (If required to be ordered).'.
      APPEND lt_message.CLEAR: lt_message.APPEND lt_message.
      lt_message = 'Details of the released design:'. APPEND lt_message.
      lt_message = '*******************************'.APPEND lt_message.CLEAR: lt_message.APPEND lt_message.
      MOVE : 'TDR No '  TO lt_message.
      lt_message+21(1) = ':'.
      lt_message+22(40) = it_ztdr-tdrid   .APPEND lt_message.
      MOVE  : 'PED Part no '  TO lt_message.
      lt_message+21(1) = ':'.
      lt_message+22(40) = it_ztdr-matnr.
      APPEND lt_message.
      CLEAR: wa_maktx.
      SELECT SINGLE maktx FROM makt INTO  wa_maktx WHERE matnr = it_ztdr-matnr.
      MOVE 'PED Part Description' TO lt_message.
      lt_message+21(1) = ':'.
      lt_message+22(40) = wa_maktx   .APPEND lt_message.
      MOVE : 'PED Part Rev no' TO lt_message .
      lt_message+21(1) = ':'.
      lt_message+22(40) = it_ztdr-matnr_rv .APPEND lt_message.
      MOVE: 'Rnd part No  ' TO lt_message .
      lt_message+21(1) = ':'.
      lt_message+22(40) = it_ztdr-ref_matnr . APPEND lt_message.
      MOVE : 'Rnd Part Rev '  TO lt_message .
      lt_message+21(1) = ':'.
      lt_message+22(40) = it_ztdr-ref_matnr_rv .APPEND lt_message.
      CLEAR: lt_message.
      APPEND lt_message.
      APPEND lt_message.
      lt_message = 'To View the Design:'.
      APPEND lt_message.
      lt_message = '*******************'.APPEND lt_message.
      CLEAR: lt_message.
      APPEND lt_message.
      lt_message ='For Standard gauge, use Transaction: ZPED_TOOLPRINT'.
      APPEND lt_message.
      lt_message ='For Non-Standard gauge, use Transaction:  ZCV04N or CV04N'.
      APPEND lt_message.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    Fill the document data.
      gs_doc_data-doc_size = 1.
      DATA subject TYPE string.
      CONCATENATE 'Design Released for'  it_ztdr-tdrid  'of'  it_ztdr-ref_matnr
            INTO subject SEPARATED BY space.
    Populate the subject/generic message attributes
      gs_doc_data-obj_langu = sy-langu.
      gs_doc_data-obj_name  = 'TDREQ'.
      gs_doc_data-obj_descr = subject .
      gs_doc_data-sensitivty = 'O'.
    Describe the body of the message
      CLEAR lt_packing_list.
      REFRESH lt_packing_list.
      lt_packing_list-transf_bin = space.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num = 0.
      lt_packing_list-body_start = 1.
      DESCRIBE TABLE lt_message LINES lt_packing_list-body_num.
      lt_packing_list-doc_type = 'RAW'.
      APPEND lt_packing_list.
      CLEAR lt_receivers.
      REFRESH lt_receivers.
    Add the recipients email address
    For SAP mail
    IF NOT GSCR_UNAME IS INITIAL.
      lt_receivers-receiver = it_ztdr-reqnm.
      lt_receivers-rec_type = 'U'.
      APPEND lt_receivers.
    ENDIF.
    For external mail
    IF NOT gs_outtab-reqnm IS INITIAL.
       lt_receivers-receiver = gs_outtab-reqnm.
       lt_receivers-rec_type = 'U'.
       APPEND lt_receivers.
    ENDIF.
    Call the FM to post the message to SAPMAIL
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = gs_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = gf_sent_all
        TABLES
          packing_list               = lt_packing_list
          contents_txt               = lt_message
          receivers                  = lt_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    Store function module return code
      gf_error = sy-subrc.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Get lt_receivers return code
      LOOP AT lt_receivers.
      ENDLOOP.
      PERFORM initiate_mail_execute_program.
        CLEAR:lt_message[] , lt_message , gs_doc_data ,gf_sent_all,lt_packing_list[]
        ,lt_packing_list ,lt_receivers[], lt_receivers.
    ENDFORM.                    " SEND_MAIL
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          text
    -->  p1        text
    <--  p2        text
    FORM initiate_mail_execute_program .
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM

    Hi,
    In your code
    You are looping the perform in which you are calling below FM.
    LOOP AT it_ztdr.
       PERFORM send_mail.
    ENDLOOP.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = gs_doc_data
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = gf_sent_all
    TABLES
    packing_list = lt_packing_list
    contents_txt = lt_message
    receivers = lt_receivers
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    So keep your FM after the loop.
    Pls. reward if useful...

  • Doubt regarding avoiding group by function

    i just came to know about a query which will avoid group by function,
    select sum(column_name) over ( partition by <coulmns> order by <solumns> )
    from <table_name>
    now columns specified in the partition by clause, are the one which will be specified under group by clause, i know this works, but can anyone expalain the meaning and significance of over keyword and is it a function, i mean with respect to SQL language that syntax seems to be very much different isn't it???
    cheere

    Hi
    Analytic functions are not alternative for group by.
    Analytic functions are the last set of operations performed in a query except for the
    final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause.
    And regarding your question,
    see this example from oracle documentation
    The following example calculates, for each manager in the sample table
    hr.employees, a cumulative total of salaries of employees who answer to that
    manager that are equal to or less than the current salary. You can see that Raphaely and Cambrault have the same cumulative total. This is because Raphaely and Cambrault have the identical salaries, so Oracle adds together their salary values and applies the same cumulative total to both rows.
    SELECT manager_id, last_name, salary,
    SUM(salary) OVER (PARTITION BY manager_id ORDER BY salary
    RANGE UNBOUNDED PRECEDING) l_csum
    FROM employees;
    MANAGER_ID LAST_NAME SALARY L_CSUM
    100 Mourgos 5800 5800
    100 Vollman 6500 12300
    100 Kaufling 7900 20200
    100 Weiss 8000 28200
    100 Fripp 8200 36400
    100 Zlotkey 10500 46900
    100 Raphaely 11000 68900
    100 Cambrault 11000 68900
    100 Errazuriz 12000 80900
    149 Taylor 8600 30200
    149 Hutton 8800 39000
    149 Abel 11000 50000
    201 Fay 6000 6000
    205 Gietz 8300 8300
    King 24000 24000
    For clear understanding read the following point:
    Whenever the order_by_clause results in identical
    values for multiple rows, the function returns the same result for
    each of those rows
    ITS THE CUMULATIVE SUM HERE.
    SO,IF TRY GIVING SAME NAME FOR ALL EMPLOYESS AND see the same result as you were getting with (partition by dept).
    so , sum function which u are using here is analytic function and so results in cumulative sum. and when identical values are identified, same result is displayed.
    Hope you got it!
    Cheers,
    Kishore KVR

  • With out using Weblogic libraries to maintain the same functionality

    Hi,
    Please tell the solution of my problem.Here application developed in Weblogic,now we are migrating that applicationin jboss.Here one java servlet program is there which is using Weblogic libraries to get the connection pool .
    How can change the code without using Weblogic libraries to maintain the same funtionality. Is there any alternate method to get the connection pools in Jboss.
    Here I am attaching the code ,please go througth the code and provide me the correct solution.
    package gsk.servlets;
    import java.io.*;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import javax.management.*;
    import javax.management.InstanceNotFoundException;
    import javax.management.InvalidAttributeValueException;
    import javax.management.Notification;
    import javax.servlet.*;
    import javax.servlet.http.*;
    //Below lines are commnented by Anupama on 29-09-05 to avoid using Weblogic libraries.
    //import weblogic.jndi.Environment;
    //import weblogic.management.MBeanHome;
    //import weblogic.management.MBeanCreationException;
    //import weblogic.management.*;
    //import weblogic.management.runtime.*;
    //import weblogic.management.configuration.*;
    //import weblogic.management.RemoteNotificationListener;
    //import weblogic.management.logging.WebLogicLogNotification;
    //import javax.management.Notification.*;
    //below lines are added by Anupama T on 29-09-05 to run the same functionality without using Weblogic libraries
    import org.jboss.management.*;
    import org.jboss.jdbc.*;
    import org.jboss.naming.*;
    import org.jboss.management.j2ee.MBean;
    import javax.management.AttributeChangeNotification;
    import javax.management.JMException;
    import javax.management.MalformedObjectNameException;
    import javax.management.MBeanServer;
    import javax.management.NotificationListener;
    import javax.management.ObjectName;
    import org.jboss.logging.Logger;
    import org.jboss.system.ServiceMBean;
    import gsk.adip.portal.GKMProperties;
    import gsk.adip.dbconnectionservice.DatabaseConnector;
    * @author jjc18400
    * The ConnectionsManager class acts as a Servlet that listens and
    * responds to events that are thrown by WebLogic MBeans. In particular,
    * it listens for failures in WebLogic connection pools, and attempts to
    * restore these pools.
    public class ConnectionsManager extends HttpServlet implements NotificationListener {
         private static Context ctx;
         private static MBean managedHome;
         private static MBean adminHome;
         private static String SERVER_NAME;
         private static String DOMAIN_NAME;
         private static MBeanServer myServer;
         private JDBCConnectionPoolRuntimeMBean connectionPoolMBean;
         private JDBCConnectionPoolMBean jdbcConnPoolMBean;
         private JDBCConnectionPoolMBean myPool;
         private static ResultSet rset = null;
         public void init(ServletConfig config) throws ServletException {
              super.init(config);
              System.out.println("Initializing the ConnectionsManager servlet.");
              SERVER_NAME = GKMProperties.getProperty("GKM_SERVER_NAME");
              DOMAIN_NAME = GKMProperties.getProperty("DOMAIN_NAME");
              findMBeans();
              testConnectionPool("GENNETConnectionPool");
              try {
                   //findConnPool("GENNETConnectionPool").addNotificationListener(this, null, null);
                   RemoteMBeanServer rmbs = adminHome.getMBeanServer();
                   WebLogicObjectName oname =
                        new WebLogicObjectName("TheLogBroadcaster", "LogBroadcasterRuntime", DOMAIN_NAME, SERVER_NAME);
                   rmbs.addNotificationListener(oname, this, null, null);
              catch (IllegalArgumentException e) {}
              catch (MalformedObjectNameException e) {}
              catch (InstanceNotFoundException e) {}          
         public void handleNotification(Notification notification, Object obj) {
              WebLogicLogNotification wln = (WebLogicLogNotification)notification;
              System.out.println("\nWebLogicLogNotification");
              System.out.println(" type = " + wln.getType());
              System.out.println(" message id = " + wln.getMessageId());
              System.out.println(" server name = " + wln.getServername());
              System.out.println(" timestamp = " + wln.getTimeStamp());
              System.out.println(" message = " + wln.getMessage() + "\n");
         private void testConnectionPool(String poolName) {
              JDBCConnectionPoolMBean aPool = findConnPool(poolName);
              JDBCConnectionPoolRuntimeMBean aRuntimeMBean = findRuntimeMBean(poolName);
              /*while(aRuntimeMBean.getPoolState()) {
                   try {
                        Thread.sleep(6000);
                        System.out.println("Thread is sleeping.");
                   catch (InterruptedException ie) {
              retargetConnPool(aPool);
         private JDBCConnectionPoolRuntimeMBean findRuntimeMBean(String aPoolName) {
              JDBCConnectionPoolRuntimeMBean aRuntimeMBean = null;
              if (managedHome != null) {
                   try {
                        aRuntimeMBean = (JDBCConnectionPoolRuntimeMBean)managedHome.
                                  getRuntimeMBean(aPoolName, "JDBCConnectionPoolRuntime");
                   catch (InstanceNotFoundException e) {
                        System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
                        aRuntimeMBean = null;
              return aRuntimeMBean;
         private JDBCConnectionPoolMBean findConnPool(String poolName) {
              if (adminHome != null) {
                   try {
                        myPool = (JDBCConnectionPoolMBean)adminHome.getMBean(poolName, JDBCConnectionPoolMBean.class);
                   catch (InstanceNotFoundException e) {
                        System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
                        myPool = null;
              return myPool;
         private void retargetConnPool(JDBCConnectionPoolMBean aPool) {
              //System.out.println("The connection pool: " + aPool.toString() + " is not responding.\nAttempting to retarget the pool...");
              try {
                   System.out.println("Attempting to remove " + myServer.toString() + " from the connection pool target list.");
                   aPool.removeTarget(myServer);
                   System.out.println("Removal successful: " + aPool.getTargets().toString());
                   aPool.addTarget(myServer);
                   System.out.println("Addition successful: " + aPool.getTargets().toString());
              catch (InvalidAttributeValueException e) {
                   System.out.println(e.toString());
              catch (DistributedManagementException e) {
                   System.out.println(e.toString());
         public void doPost(HttpServletRequest req, HttpServletResponse resp)
                   throws ServletException, IOException {
              String poolName = (String)req.getParameter("poolName");
              String dataSource = (String)req.getParameter("dataSource");
              //System.out.println("req.getAttribute(poolName) is: " + poolName);
              //System.out.println("req.getAttribute(dataSource) is: " + dataSource);
              String message = runTestQuery(dataSource);
              getConnectionPoolMBean(poolName);
              resp.setContentType("text/html");
              PrintWriter out = resp.getWriter();
              out.println("<html>");
              out.println(" <head><title>The ConnectionsManager Responds:</title></head>");
              out.println(" <body>");
              out.println(" <h1>" + message + "</h1>");
              out.println(" </body>");
              out.println("</html>");
         public void destroy() {
              System.out.println("Destroying the ConnectionsManager servlet.");
         public String getServletInfo() {
              return "This servlet monitors and corrects errors in WebLogic connection pools.";
         /**private void runTests() {
              while (false) {
                   rset = testConnection();
                   if (rset == null) {
                        resetConnectionPool();                    
                   try {
                        wait();
                   catch (InterruptedException e) {}
         private String runTestQuery(String dataSource) {
              String statusMessage = "";
              Connection conn = null;
              Statement stmt = null;
              ResultSet rset = null;
              //String aPoolName = "GENNETConnectionPool";
              String aSql = "select * from dual where 1 = 1";
              try {
                   conn = DatabaseConnector.getDatabaseConnection(dataSource);
                   System.out.println("Established database connection.");
                   if (conn != null) {
                        conn.setAutoCommit(false);
                        stmt = conn.createStatement();
                        rset = stmt.executeQuery(aSql);
                        statusMessage = "The connection \'" + dataSource + "\' is OK.";
              catch (Exception e) {
                   try {
                        conn.rollback();
                   catch (Exception e1) {}
                   e.printStackTrace();
                   statusMessage = "The connection \'" + dataSource + "\' has failed.\n" + e.toString();
              finally {
                   try {
                        if (stmt != null) stmt.close();
                        if (conn != null) conn.close();
                   catch (Exception e) {
                        e.printStackTrace();
                   return statusMessage;
         public void resetConnectionPool() {
         private void findConnPoolRuntimeMBean(String poolName) {
              try {
                   connectionPoolMBean = (JDBCConnectionPoolRuntimeMBean)managedHome.getRuntimeMBean(poolName, "JDBCConnectionPoolRuntime");
              catch (InstanceNotFoundException e) {
                   System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
         private void findMBeans() {
              Environment env = new Environment();
              try {
                   ctx = env.getInitialContext();
                   managedHome = (MBeanHome)ctx.lookup(MBeanHome.JNDI_NAME + "." + SERVER_NAME);
                   System.out.println(MBeanHome.JNDI_NAME + "." + SERVER_NAME + " -- managedHome found successfully.");
                   adminHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
                   System.out.println(MBeanHome.ADMIN_JNDI_NAME + " -- adminHome found successfully.");
                   myServer = (ServerMBean)adminHome.getMBean(SERVER_NAME, ServerMBean.class );
                   System.out.println(MBeanHome.ADMIN_JNDI_NAME + " -- " + SERVER_NAME + " instance found successfully.");
                   ctx.close();
              catch (NamingException e) {
                   System.out.println("Naming Exception: " + e);
                   managedHome = null;
                   adminHome = null;
              catch (InstanceNotFoundException e) {
                   System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
         public String displayHomeName() {
              getConnectionPoolMBean("GENNETConnectionPool");
              if (managedHome != null) {
                   return new String("MBeanHome found successfully.");
              else return new String("MBeanHome not found.\nSee WL Console for error.");
         private void getConnectionPoolMBean(String poolName) {
              String thisPoolName = poolName;
              connectionPoolMBean = null;
              if (managedHome != null) {
                   try {
                        connectionPoolMBean =
                             (JDBCConnectionPoolRuntimeMBean)managedHome.getRuntimeMBean(thisPoolName, "JDBCConnectionPoolRuntime");
                        if (connectionPoolMBean != null) {
                             System.out.println("JDBCConnectionPoolRuntime found successfully.");
                             System.out.println("connectionPoolMBean.toString() is: " + connectionPoolMBean.toString());
                             System.out.println("connectionPoolMBean.getFailuresToReconnectCount() is: " + connectionPoolMBean.getFailuresToReconnectCount());
                             System.out.println("connectionPoolMBean.getPoolState() is: " + connectionPoolMBean.getPoolState());
                   catch (InstanceNotFoundException e) {
                        System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
                        connectionPoolMBean = null;
              // Obtain MBeanHome for the administration server.
              /*JDBCConnectionPoolMBean mbean = (JDBCConnectionPoolMBean)home.
                        getConfigurationMBean(poolName, "JDBCConnectionPoolConfig");
              mbean.setConnLeakProfilingEnabled(true);
              mbean.setSqlStmtParamLoggingEnabled(true);
              mbean.setSqlStmtMaxParamLength(maxLen);*/
              /*try {
                   mypool = (JDBCConnectionPoolMBean)mbh.getMBean( "mypool",
                   JDBCConnectionPoolMBean.class );
              catch( javax.management.InstanceNotFoundException e ) {
                   mypool = (JDBCConnectionPoolMBean) mbh.createAdminMBean( "mypool",
                        "JDBCConnectionPool", "mydomain" );
                   mypool.addTarget( myserver );
                   mypool.setDriverName( "org.gjt.mm.mysql.Driver" );*/
              if (adminHome != null) {
                   try {
                        myPool = (JDBCConnectionPoolMBean)adminHome.getMBean(poolName, JDBCConnectionPoolMBean.class);
                   catch (InstanceNotFoundException e) {
                        System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
              if (myPool != null) {
                   //System.out.println("myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
                   try {
                        myPool.setMaxCapacity(10);
                        System.out.println("Before: myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
                        myPool.setMaxCapacity(100);
                        System.out.println("After: myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
                   catch (InvalidAttributeValueException e) {
                        System.out.println("Max Capacity is an invalid value.");
                   //System.out.println("myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
    }

    Hy, i've got the same problem as you. Did you find out a solution.
    If so, please contact me. Thanks a lot.
    Lorenzo

  • Need to reduce no of calling same  function  in update statment

      update tab1 set
        col1  =  FN1(a),
        col2  =  FN2(a),
        col3  =  FN3( FN1(a), FN2(a) , c )
    here  FN1 and FN2 is called two time .. or only once ,, ??
    if 2 time then how to make it once call only ...
    can we change it like this
         update tab1 set
        col1  =  FN1(a),
        col2  =  FN2(a),
        col3  =  FN3( col1  , col2   , c )
    both r same or differnt ..??Edited by: user12108669 on Dec 11, 2009 4:31 AM

    Hi,
    Those are very good questions.
    Riedelme has told you who is the best person to answer thiose questions: you.
    To see how ofte a function is called, you can have it display something (using dmbs_output) or increment a sequence, package variable or SYS_CONTEXT attribute.
    CREATE TABLE tab1
    (        a      NUMBER
    ,        col1    NUMBER
    ,            col2      NUMBER
    ,      col3      NUMBER
    ,      c      NUMBER
    INSERT INTO tab1 (a) VALUES (1);
    INSERT INTO tab1 (a) VALUES (2);
    INSERT INTO tab1 (a) VALUES (3);
    CREATE SEQUENCE      fn1_seq    START WITH 1;
    CREATE SEQUENCE      fn2_seq    START WITH 1001;
    CREATE OR REPLACE FUNCTION      fn1
    (      in_num       IN        NUMBER
    RETURN NUMBER
    IS
         seq_val     NUMBER;
    BEGIN
         SELECT  fn1_seq.NEXTVAL
         INTO     seq_val
         FROM     dual;
         RETURN     seq_val;
    END     fn1;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION     fn2
    (      in_num       IN        NUMBER
    RETURN NUMBER
    IS
         seq_val     NUMBER;
    BEGIN
         SELECT  fn2_seq.NEXTVAL
         INTO     seq_val
         FROM     dual;
         RETURN     seq_val;
    END     fn2;
    SHOW ERRORS
    CREATE OR REPLACE FUNCTION     fn3
    (      in_x       NUMBER
    ,      in_y       NUMBER
    ,      in_z       NUMBER
    RETURN     NUMBER
    IS
    BEGIN
         RETURN  in_x + in_y;
    END     fn3;
    SHOW ERRORSTo avoid calling the functions repeatedly, you can use MERGE instead of UPDATE, like this:
    MERGE INTO  tab1    dst
    USING  (
           SELECT  a
           ,       fn1 (a)     AS fn1_a
           ,       fn2 (1)     AS fn2_a
           ,       c
           FROM    tab1
           )         src
    ON     (src.a         = dst.a)
    WHEN MATCHED THEN UPDATE
    SET  dst.col1       = src.fn1_a
    ,    dst.col2       = src.fn2_a
    ,    dst.col3       = fn3 (src.fn1_a, src.fn2_a, src.c)
    SELECT       *
    FROM       tab1
    ORDER BY  a;Output:
    .        A       COL1       COL2       COL3          C
             1          1       1001       1002
             2          2       1002       1004
             3          3       1003       1006

  • Avoid procedure or function calls between a SQL operation and an implicit cursor test

    when i analyse this code with code expert

    atpidgeon wrote:
    when i analyse this code with code expert
                            UPDATE P_PM_CONTROL_COUNT
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = vrectab(1)
                            AND USAGE_DATE = vrectab(2)
                            AND SEGMENT_CODE = vrectab(5)
                            AND ALLOCATION - UNITS_RESERVED > 0;
                            IF sql%rowcount = 0 then --Added block and exception to prevent invetory going negative when placing multi units in same unit type out of service.
                                vErrMsg := 'Could not process your out of service request because your selection for unit '|| vrectab(3) || ' at ' || pvPropertyId || ' for ' || vrectab(2) || ' would cause segment ' || vrectab(5) || ' to be over allocated.';
                                RAISE SegOverAllocated;
                            END IF;
    i get "Avoid procedure or function calls between a SQL operation and an implicit cursor test.",as far has i know
    iff you're doing a sql%rowcount    after an update.. trying to see how many rows were updated...  you dont want procedure or function calls between the update and the sql% line
    correct me if im wrong and how would i fix it?or maybe i shouldnt
    You correct it by NOT executing function calls as part of the UPDATE statement.
    1. Issue the function calls BEFORE the update statement
    2. save the function results into variables
    3. use those variables in the UPDATE statement.
    v_rectab1 := vrectab(1);
    v_rectab2 := vrectab(21);
    v_rectab5 := vrectab(5);
    UPDATE P_PM_CONTROL_COUNT 
                            SET AVAIL_SEG = AVAIL_SEG -1,
                                ALLOCATION = ALLOCATION -1
                            WHERE PM_UNIT_TYPE_ID = v_rectab1
                            AND USAGE_DATE = v_rectab2
                            AND SEGMENT_CODE = v_rectab5
                            AND ALLOCATION - UNITS_RESERVED > 0;

  • Why does my iPhone 4 play same song twice?

    why does my iPhone 4 play same song twice?

    I had the same issue in my 2012 Nissan Altima.  It was a function in my car's stero settings.  I had to go to the car's iPhone/iPod settings when the iPhone was plugged into the USB.  My settings come up automatically when I plug in and I can scroll through the commands to "Shuffle" songs.  Hope this helps.

  • How to enter the same cell twice in a formula

    I am studying environmental engineering. we have a lot of complicated formulas that are long chains. In these formulas I need to reference the same cell many times , the problem is when I click on the cell again all it does is rehighlight that cell earlier in the equation. When I do this in excell it works fine. If i type the cell in it works but this can be a hassle. I like working in Iwork because the charts and graphs are nicer but I seem to be finding that some items like this, goal seek, and the fact that you can not extend a polynomiel function forward and back excell is much better than Iwork.

    Same question twice in one day. Hold down the command key when selecting it the second time.

  • Prevent push the same button twice

    Hi all! I have a button that performs a specific function .All I would like to do is prevent the user to push the same button twice. I tried already to include a 'disable button' built in function but it can't work from within.
    Any ideas?

    I would set the button to be disabled before you call your function, but I suppose it doesn't matter. You need to change those navigable properties on the button to NO. You cannot change the Enabled status of the button if it is the current item. Keyboard Navigable and Mouse Navigate should both be set to NO.

Maybe you are looking for

  • I have given up on BB & Mac

    When I got my Curve last May I was told that it was 100% compatible with Macs. Wrong, wrong, wrong. I have tried PocketMac and basically just given up. They have tried to help me and RIM has tried to help me but have been unable to fix the problem. I

  • Edit in Photoshop issue

    I just upgraded to LR4 and CS6 on a MAC running 10.7.  When I edit the image in LR and click Edit in Photoshop, Photoshop opens but never actually opens the image.  Please help. 

  • PLEASE help me settle this question....

    does BlazeDS support data real-time data synchronization? My manager says it does, but i thought that at the last MAX i specifically asked that question and was told that it is only supported under LiveCycle. Example: I have a textInput synchronized

  • ' Landscape in XI '

    Hi All    Can any one explain me what is land scape of XI in real time projects?    What it contains ? Any information on this is most welcome ! Adv..thanks and regards ---  Rakesh

  • Javax.mail jar compilation error

    Dear friends, I have created a DC which manages emails to users which uses the following import statements import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mai