Results 1 to 5 of 5
  1. #1
    JsShivalik is offline Member
    Join Date
    Nov 2015
    Posts
    5
    Rep Power
    0

    Default Pass Parameter to Stored Procedute

    Hi

    I have created 1 stored procedure for Insert,Update,Delete. If value 1 is passed Insert is done , If Value is 2 then Update
    How can i pass value to Stored Procedure . I have written the below code

    CallableStatement pstmt = null;
    pstmt = con.prepareCall("{call sp_Party(?,?,?,?)}");
    pstmt.setString(1, txtid.getText());
    pstmt.setString(2, txtname.getText());
    pstmt.setString(3, txtaddress.getText());
    pstmt.setString(4, txtcity.getText());
    pstmt.executeUpdate();
    pstmt.close();
    Thanks

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Pass Parameter to Stored Procedute

    What happens when you try it?

    And please, when posting code wrap it in code tags.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    JsShivalik is offline Member
    Join Date
    Nov 2015
    Posts
    5
    Rep Power
    0

    Default Re: Pass Parameter to Stored Procedute

    Hi

    How to wrap it in code tags.[/QUOTE]. Secondly no doubt above code inserts record . How to pass a parameter to stored procedure , i don't know. Currently i have only Insert Code in Procedure but i will add Modify/Delete Code also in same stored procedure.

    Thanks

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Pass Parameter to Stored Procedute

    [code] your code here [/code]

    You're passing parameters to the stored procedure in your example already.
    That's what the setString method calls are doing.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    878
    Rep Power
    12

    Default Re: Pass Parameter to Stored Procedute

    you have to write different stored procedures for each u operation and perform the steps what you showed here.
    Ramya:cool:

Similar Threads

  1. Pass a superclass as a parameter?
    By kkid in forum New To Java
    Replies: 4
    Last Post: 11-29-2013, 02:55 PM
  2. Stored procedure OUT parameter is rounded
    By diamonddragon in forum JDBC
    Replies: 0
    Last Post: 02-10-2012, 09:03 PM
  3. Replies: 1
    Last Post: 03-11-2011, 01:55 PM
  4. how to pass parameter from one jsp to another jsp
    By kader_sit in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-10-2010, 02:04 PM
  5. I can't seem to pass a file through a parameter
    By daletron3030 in forum New To Java
    Replies: 5
    Last Post: 01-15-2009, 06:07 AM

Posting Permissions

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