Restriction | See Support for optional PV-WAVE modules to check if this function is available on your operating system. |
; Create PROCEDURE TestInputParams(@c varchar(10),@z int)
; select population from state where city=@c and zip=@z.
@odbc_startup
oid=odbc_init()
; Connect to data source. It might be different on your system.
oid2=odbc_connect(oid,"<DSN>","")
; Call stored procedure auth_city_zip.
; Two parameter markers are in this SQL statement.
stmt = odbc_prepare(oid2,"{call TestInputParams(?,?)}")
; Notice that the number of parameters match the number of
; parameter markers. Name of stored procedure should also
; match the name of the procedure in the SQL statement.
Myvar = "Denver"
Myvar2 = 80501
; For input parameter marker, PV-WAVE variables must contain an
; appropriate value.
Param_list =odbc_bind_params(oid2,stmt,'TestInputParams',myvar1,myvar2)
; Get the resultset.
t=odbc_fetch(stmt,1)
; CREATE PROCEDURE TestOutputParams @OutParm1 int
; OUTPUT,@OutputParm2
; int OUTPUT AS
; SELECT name FROM emp
; select @OutParm=88
; select @parm2=-88
; RETURN 99
@odbc_startup
oid=odbc_init()
oid2=odbc_connect(oid,"sqlserver","")
; SQL statement with two output parameter markers.
stmt = odbc_prepare(oid2,"{call TestOutputParams(?,?)}")
; Bind PV-WAVE variables.
param_list = odbc_bind_params(oid2,stmt, 'TestParm2', myvar, $
myvar2)
; Fetch first result set.
t=odbc_fetch(stmt,1)
; Call odbc_fetch until no more data is available.
rc = odbc_fetch(stmt,5,output_params=param_list)
; Param_list should be populated with the output parameters.
print,param_list
; Close statement.
rv = odbc_fetch(stmt,6)