https://www.selikoff.net/ocp11-819/
Removed: Callable Statements Skip CallableStatements (Ch10 of Programmer II, Ch21 of CSG)
Moderator: admin
Removed: Callable Statements Skip CallableStatements (Ch10 of Programmer II, Ch21 of CSG)
Code: Select all
create procedure sp_sum_numbers(IN a int, IN b int, OUT result int)
begin
set result= a+b;
end
Code: Select all
String sql = "{call sp_sum_numbers(?,?,?)}";
try(var conn = DriverManager.getConnection(url,username,password);
var call = conn.prepareCall(sql)){
call.setInt(1,25);
call.setInt("b",25); // No exception; MySQL is supporting mixing index and named parameters in same query
call.registerOutParameter(3, Types.INTEGER);
call.execute();
int sum = call.getInt(3);
System.out.println("sum is = "+ sum); // sum is 50
}
May be Mysql has not implemented this requirement strictly.It is not possible to combine setting parameters with ordinals and with names in the same statement. If ordinals and names are used for parameters in the same statement, an SQLException is thrown.
Users browsing this forum: Google [Bot] and 8 guests