Example: Input and Output Arguments in JDBC - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
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.