How to call procedure from javascript?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: How to call procedure from javascript?

  1. #1
    Join Date
    Jan 2000
    Posts
    387

    How to call procedure from javascript?

    Hi

    I have created a procedure to pass in a value (eg: student ID) and an OUT variable from the procedure storing Yes/No to indicate if the student ID exist in the database or not.

    I want to use this procedure in a javascript event handler (onChange) so that the user cannot update the student ID if it is already exists in the database.

    I have written the following codes for the onChange javascript event handler in the portal form but it is not working! Any help pelase? Thanks!

    for (i=0;i {
    if (document.forms[0].elements[i].name ==
    'FORM_EDIT_STUDENT.DEFAULT.STUDENTID.01')
    {
    var v_student_id;
    var v_valid;
    v_student_id = document.forms[0].elements[i].value;
    orcl.check_studentid(v_student_id, v_valid);
    alert(v_student_id ||' '|| v_valid);
    }
    }

  2. #2
    Join Date
    Jan 2001
    Posts
    2,828
    Hi Mooks

    Dont think so that javascript can actually call a pl/sql procedure that way.

    One alternative way would be calling through a html form.

    form's action field specifies the procedure to execute, and the named input elements on the HTML form pass parameters

    Code:
    form action=my_plsql_proc
    and then the pl/sql procedure is run.

    Javascript runs on the client webbrowser pl/sql runs on the server so i would be surprised if somebody here posts the code to call pl/sql procedures from somethin like java script :-)

    regards
    Hrishy
    Last edited by hrishy; 08-24-2005 at 05:30 AM.

  3. #3
    Join Date
    Jan 2000
    Posts
    387
    Hi

    Thanks for your reply! I have been searching in the net but could nto find any answers to this issue!

    Anyway, is there any alternatives that you would suggest?

    How to write a javascript to verify that the value in the form does not exist in the database before update?

  4. #4
    Join Date
    Jan 2001
    Posts
    2,828
    Hi

    You cna do that in the stored procedure and if the value already exists then the stored proc can actually write out a html page back to the client saying there is a error.

    Javascript cannot on its own validate it.Straegy is javascript directs the user to a URL through its forms action item.That url contains a like to the stored procedure which takes the parameters and validates and executes against the database

    You get the idea ?

    regards
    Hrishy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width