runstoredprocedure - Call stored procedure with input and output parameters

Syntax

results = runstoredprocedure(conn, sp_name, parms_in, types_out)

Description

results = runstoredprocedure(conn, sp_name, parms_in, types_out) calls a stored procedure with specified input parameters and returns output parameters, where:

Use runstoredprocedure to return the value of a variable to a MATLAB® variable, which you cannot do when running a stored procedure via exec. Running a stored procedure via exec returns resultsets but cannot return output parameters.

Examples

These examples illustrate how runstoredprocedure differs from running stored procedures via exec.

  1. The command:

    x = runstoredprocedure(c,'myprocnoparams')

    Runs a stored procedure that has no input or output parameters.

  2. The command:

    x = runstoredprocedure(c,'myprocinonly',{2500,'Jones'}) 

    Runs a stored procedure given input parameters 2500 and 'Jones'. It returns no output parameters.

  3. The command:

    x = runstoredprocedure(c,'myproc',{2500,'Jones'},{java.sql.Types.NUMERIC})

    Runs the stored procedure myproc given input parameters 2500 and 'Jones'. It returns an output parameter of type java.sql.Types.NUMERIC, which could be any numeric Sun™ Java™ data type. The output parameter x is the value of a database variable n. The stored procedure myproc creates this variable, given the input values 2500 and 'Jones'. For example, myproc computes n, the number of days when Jones is 2500. It then returns the value of n to x.

See Also

cursor.fetch, exec

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS