5 Replies Latest reply: Feb 1, 2013 2:47 AM by fac586 RSS

    Run PLSQL code by click on button usin javascript

    972094
      Hi
      I want to run plsql code
      on click button using javascript


      javascript is ok but code of plsql is not run
      suggest me

      thanks in advance

      bUTTON CODE IN PLSQL CODE AND SEND_RMNDE IS PROCEDURE
      '<button type="button" name="button1" onclick="send_rmndr('
      ||NO_DUES_MASTER.CERT_ID
      ||');" value ='
      ||NO_DUES_MASTER.CERT_ID
      ||'> '
      ||'Remind'
      ||'</button>'

      JAVASCRIPT
      <script type="text/javascript">
      function send_rmndr(pThis)
      {
      var params='x= '+pThis;

      var get=new htmldb_Get(null,null,null,&APP_PAGE_ID.,null,'send_reminder',params);



      gReturn = get.get();
      //alert(gReturn);
      alert ('inside script ' +params);

      //get=null;

      }
      </script>

      Edited by: 969091 on Jan 31, 2013 7:52 PM
        • 1. Re: Run PLSQL code by click on button usin javascript
          sb92075
          969091 wrote:
          Hi
          I want to run plsql code
          on click button using javascript


          javascript is ok but code of plsql is not run
          suggest me

          thanks in advance
          EndUser<=>browser<=>WebServer<=>ApplicationServer<=>DatabaseServer

          EndUser clicking button in Browser is a long ways from running PL/SQL inside DBServer.

          You need to get the cooperation of both the WebServer & ApplicationServer to do what you desire.
          • 2. Re: Run PLSQL code by click on button usin javascript
            Billy~Verreynne
            969091 wrote:

            I want to run plsql code
            on click button using javascript
            Something like Apache with mod_plsql is needed for a web browser to make a PL/SQL call. The URL format will be:
             http://<your-web-server:port>/<data-access-descriptor>/<schema>.<procedure>?<name-value-parameters> 
            • 4. Re: Run PLSQL code by click on button usin javascript
              ranit B
              969091 wrote:
              Hi
              I want to run plsql code
              on click button using javascript


              javascript is ok but code of plsql is not run
              suggest me
              One way I can guess of now is using AJAX in Javascript code and calling the PL/SQL procedure.
              function fn_onClick1(){
                          var str = "";
                          var reg = ""; 
                          var xmlhttp;    
                          var item = new Array;
                          
                          for (var  v_iCount = 0; v_iCount < document.getElementById("lstRegion1").length ; v_iCount++){
                              if(document.getElementById("lstRegion1").item(v_iCount).selected == true ){
                                  str= document.getElementById("lstRegion1").item(v_iCount).value + "-" + str;
                              } 
                          }
                          
                          if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                              xmlhttp=new XMLHttpRequest();
                          }else{// code for IE6, IE5
                              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                          }
                          
                          xmlhttp.onreadystatechange=function(){
                              if (xmlhttp.readyState==4 && xmlhttp.status==200){
                                  if(xmlhttp.responseText.search(/option/i)<0){
                                      
                                      --- "code"
                                  }else{
                                      
                                      --- "code"
                                  }
                                  
                              }
                          }
                          --- "INTERIM_REPORT is a package and INTERIM_LEAD_ML2 is a proc in it"
                          xmlhttp.open("POST","interim_report.interim_lead_ml2?pv_input="+str+"&pv_num=2",true); ---"the packaged proc is called as an URL"
              
                          xmlhttp.send();
                       }
              Edited by: ranit B on Feb 1, 2013 10:47 AM
              -- added sample code
              • 5. Re: Run PLSQL code by click on button usin javascript
                fac586
                969091 wrote:
                Hi
                I want to run plsql code
                on click button using javascript


                javascript is ok but code of plsql is not run
                suggest me

                thanks in advance

                bUTTON CODE IN PLSQL CODE AND SEND_RMNDE IS PROCEDURE
                  '<button type="button" name="button1" onclick="send_rmndr('
                ||NO_DUES_MASTER.CERT_ID
                ||');" value ='
                ||NO_DUES_MASTER.CERT_ID
                ||'> '
                ||'Remind'
                ||'</button>'
                
                JAVASCRIPT
                <script type="text/javascript">
                function send_rmndr(pThis)
                { 
                var params='x= '+pThis;
                
                var get=new htmldb_Get(null,null,null,&APP_PAGE_ID.,null,'send_reminder',params);
                
                
                
                gReturn = get.get();
                //alert(gReturn);
                alert ('inside script ' +params);
                
                //get=null;
                
                }
                </script>
                This question appears to be APEX-related and is therefore more appropriate to the {forum:id=137} forum.

                Close this thread and repost it on the APEX forum, including the following information:

                <li>Full APEX version
                <li>Full DB/version/edition/host OS
                <li>Web server architecture (EPG, OHS or APEX listener/host OS)
                <li>Browser(s) and version(s) used
                <li>Theme
                <li>Template(s)
                <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)

                and posting code using <tt>\
                ...\
                </tt> tags as described in the FAQ.