Calling a Function in a Database
来源:互联网 发布:刷赞软件 编辑:程序博客网 时间:2024/05/22 16:00
A function is essentially a stored procedure that returns a result.This example demonstrates how to call functions with IN, OUT, andIN/OUT parameters.
CallableStatement cs;
try {
// Call a function with no parameters; the function returns a VARCHAR
// Prepare the callable statement
cs = connection.prepareCall("{? = call myfunc}");
// Register the type of the return value
cs.registerOutParameter(1, i);
// Execute and retrieve the returned value
cs.execute();
String retValue = cs.getString(1);
// Call a function with one IN parameter; the function returns a VARCHAR
cs = connection.prepareCall("{? = call myfuncin(?)}");
// Register the type of the return value
cs.registerOutParameter(1, Types.VARCHAR);
// Set the value for the IN parameter
cs.setString(2, "a string");
// Execute and retrieve the returned value
cs.execute();
retValue = cs.getString(1);
// Call a function with one OUT parameter; the function returns a VARCHAR
cs = connection.prepareCall("{? = call myfuncout(?)}");
// Register the types of the return value and OUT parameter
cs.registerOutParameter(1, Types.VARCHAR);
cs.registerOutParameter(2, Types.VARCHAR);
// Execute and retrieve the returned values
cs.execute();
retValue = cs.getString(1); // return value
String outParam = cs.getString(2); // OUT parameter
// Call a function with one IN/OUT parameter; the function returns a VARCHAR
cs = connection.prepareCall("{? = call myfuncinout(?)}");
// Register the types of the return value and OUT parameter
cs.registerOutParameter(1, Types.VARCHAR);
cs.registerOutParameter(2, Types.VARCHAR);
// Set the value for the IN/OUT parameter
cs.setString(2, "a string");
// Execute and retrieve the returned values
cs.execute();
retValue = cs.getString(1); // return value
outParam = cs.getString(2); // IN/OUT parameter
} catch (SQLException e) {
}
- Calling a Function in a Database
- Calling a Stored Procedure in a Database
- Calling a Stored Procedure in a Database
- Dynamically Calling a Function
- Creating a Stored Procedure or Function in an Oracle Database
- Question 48: In C++, which of the following statements accurately describe a base class destructor calling a virtual function ov
- TypeError: $ is not a function when calling jQuery function
- Calling a PL/SQL procedure in ODI
- About relationships in a database
- Calling a v8 javascript function from c++ with an argument
- calling a host function from a __device__/__global__ function is not allowed
- calling a __host__ function("_wassert") from a __global__ function is not allowed错误
- calling a __host__ function("XXX") from a __global__ function is not allowed
- A problem in function PartitionMotionSearch()
- Invoke a function in computer
- Calling a Business Add-In in the Application Program
- a example for calling java code in javascript use dwr
- Calling JavaScript in a WebBrowser control from C#
- Effective C++ 读书笔记之implemenations(1)
- oracle cursor 学习小结
- 什么是IOCP?
- JAVA版的相册制作程序
- Windows 7:揭秘7大不为人知的功能
- Calling a Function in a Database
- Calling a Stored Procedure in a Database
- Integrate Drools with Maven2 is a worry~~
- Creating a Stored Procedure or Function in an Oracle Database
- JS中document对象详解
- Math.Round()方法的四舍五入(.NET)
- Windows 7] 初探 Windows 7 M3 Build6801 - 从当前系统升级
- Uploading Material Master Long Text (Basic data text, Inspection text, Internal comment)
- 注册域名的分类