Example: Input and Output Arguments in JDBC - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
qtb1554762060450.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

Consider the stored procedure spSample2, which can be executed using the following JDBC API calls:

     CallableStatement cstmt = con.prepareCall("CALL spSample2(p1, ?,      ?)");
     ResultSet rs = cstmt.executeQuery();

The following alternatives can be used for the second line (ResultSet rs = …):

     boolean bool = cstmt.execute();

or

     int count = cstmt.executeUpdate();

The QUESTION MARK character indicates an argument and acts as a placeholder for IN or INOUT parameters in the prepareCall() request. The question mark placeholder arguments must be bound with the application local variables and literals using the CallableStatement.setXXX() JDBC API calls.

Alternatively, an IN or INOUT argument can be a constant expression.

The INOUT and OUT arguments need to be registered using the following JDBC API call:

     CallableStatement.registerOutParameter()

After execution the parameter values can be retrieved from the response using the CallableStatement.getXXX() JDBC API calls.