call stored procedure with parameter


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: call stored procedure with parameter

  1. #1
    tammy Guest

    call stored procedure with parameter


    Hi,
    everyone.
    Could you show me how can I pass a parameter to call a stored procedure
    ? I have been successfully to do it without any parameters as following:

    CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");

    but, what can I do with parameters passing?

    Thank you!






  2. #2
    Madhav Guest

    Re: call stored procedure with parameter


    "tammy" <yan.zhang@unitedchambers.com> wrote:
    >
    >Hi,
    > everyone.
    > Could you show me how can I pass a parameter to call a stored procedure
    >? I have been successfully to do it without any parameters as following:
    >
    >CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");
    >
    >but, what can I do with parameters passing?
    >
    > Thank you!


    Hi Tammy ,
    I'll give you an example to explain :

    String s = new String({?= call multiply[?,?]});

    CallableStatement cs = dbconn.prepareCall(s);
    cs.setInt(2, 10);
    cs.setInt(3, 30);

    cs.registerOutParameter(1 ,NUMBER); // NUMBER is a sqlType
    ResultSet rs = cs.executeUpdate;
    rs.getInt(1);

    this is how it goes.

    Thanks
    Madhav




    >
    >
    >



  3. #3
    syed Guest

    Re: call stored procedure with parameter


    Hi tommy,
    Read JDBC part of java tutorial. very good one.

    Cheers
    syed zulfiqar


    "Madhav" <djlintls@hotmail.com> wrote:
    >
    >"tammy" <yan.zhang@unitedchambers.com> wrote:
    >>
    >>Hi,
    >> everyone.
    >> Could you show me how can I pass a parameter to call a stored procedure
    >>? I have been successfully to do it without any parameters as following:
    >>
    >>CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");
    >>
    >>but, what can I do with parameters passing?
    >>
    >> Thank you!

    >
    >Hi Tammy ,
    >I'll give you an example to explain :
    >
    >String s = new String({?= call multiply[?,?]});
    >
    >CallableStatement cs = dbconn.prepareCall(s);
    >cs.setInt(2, 10);
    >cs.setInt(3, 30);
    >
    >cs.registerOutParameter(1 ,NUMBER); // NUMBER is a sqlType
    >ResultSet rs = cs.executeUpdate;
    >rs.getInt(1);
    >
    >this is how it goes.
    >
    >Thanks
    >Madhav
    >
    >
    >
    >
    >>
    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center