User`s guide

runstoredprocedure
7-211
Close the database connection conn.
close(conn)
Call a Stored Procedure with Output Arguments
Define a stored procedure named maxDecVolume that selects the maximum sales volume
in December by executing this code. This procedure has one output argument data and
no input arguments. This code assumes you are using a Microsoft SQL Server database.
CREATE PROCEDURE maxDecVolume
@data int OUTPUT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @data = max(December) from salesVolume
END
GO
Create a Microsoft SQL Server database connection conn using the JDBC driver. For
details, see “Connecting to a Database”. Then, call the stored procedure using:
Database connection conn
Stored procedure maxDecVolume
Empty brackets to denote no input arguments
Numeric Java data type outputtype
outputtype = {java.sql.Types.NUMERIC};
results = runstoredprocedure(conn,'maxDecVolume',[],outputtype)
results =
[1x1 java.math.BigDecimal]
results returns a cell array that contains the maximum sales volume as a Java decimal
data type.
Display the value in results.