Calling a Stored Procedure in a Database
2009-04-14 12:24
543 查看
This example demonstrates how to call stored procedures with IN, OUT,
and IN/OUT parameters.
and IN/OUT parameters.
CallableStatement cs; try { // Call a procedure with no parameters cs = connection.prepareCall("{call myproc}"); cs.execute(); // Call a procedure with one IN parameter cs = connection.prepareCall("{call myprocin(?)}"); // Set the value for the IN parameter cs.setString(1, "a string"); // Execute the stored procedure cs.execute(); // Call a procedure with one OUT parameter cs = connection.prepareCall("{call myprocout(?)}"); // Register the type of the OUT parameter cs.registerOutParameter(1, Types.VARCHAR); // Execute the stored procedure and retrieve the OUT value cs.execute(); String outParam = cs.getString(1); // OUT parameter // Call a procedure with one IN/OUT parameter cs = connection.prepareCall("{call myprocinout(?)}"); // Register the type of the IN/OUT parameter cs.registerOutParameter(1, Types.VARCHAR); // Set the value for the IN/OUT parameter cs.setString(1, "a string"); // Execute the stored procedure and retrieve the IN/OUT value cs.execute(); outParam = cs.getString(1); // OUT parameter } catch (SQLException e) { }
相关文章推荐
- Calling a Stored Procedure in a Database
- Creating a Stored Procedure or Function in an Oracle Database
- charindex VS like in stored procedure on to improve the performance
- Forward:Stale statistics on a newly created temporary table in a stored procedure can lead to poor performance
- How to detect a rollback in MySQL stored procedure?
- Get Dataset from Stored Procedure in Oracle
- How To Use a DataReader Against an Oracle Stored Procedure in Visual C# .NET
- Microsoft SQL Server 2005 Stored Procedure Programming in T-SQL & .NET
- Home / Python MySQL Tutorial / Calling MySQL Stored Procedures in Python Calling MySQL Stored Procedures in Python
- XPO – (Gary's post)Stored Procedure Support Coming in V2010 Vol 2 Part1
- Calling a PL/SQL procedure in ODI
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- XPO - (Gary's post)Stored Procedure Support coming in V2010 Vol 2 (Part 2)
- What you should know about Stored Procedure Universe in BI 4.0 ?
- A Stored Procedure To Count Numbers Of Rows In Table
- Sql server database stored procedure reference 01
- How to call stored procedure in Hibernate
- Stored procedure 'zhanghouying' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the curr
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- Nested transactions in stored procedure of SQLServer