Command 4: Calling Stored Procedures 3
<< Click to Display Table of Contents >> Command 4: Calling Stored Procedures 3 |
![]() ![]() ![]() |
Below is a sample where the same stored procedure as in the previous is called, but now the parameters are set by the application.
FUNCTION Start
LOCAL oRs AS AdoRecordSet
LOCAL oConn AS AdoConnection
LOCAL oCmd AS AdoCOmmand
LOCAL oPars AS AdoParameters
LOCAL oPar AS AdoParameter
LOCAL i AS DWORD
oConn := OpenConnection()
CreateProc2(oConn)
oCmd := AdoCommand{}
oCmd:ActiveConnection := oConn
oCmd:CommandText := "sp_OrderTotal"
oCmd:CommandType := AdCmdStoredProc
? "Define our own parameters"
oPars := oCmd:PARAMETERS_
oPar := oCmd:CreateParameter("return", adInteger,;
adParamReturnValue,NIL,NIL)
oPars:Append(oPar)
oPar := oCmd:CreateParameter("start", adDate,; adParamInput,NIL,1996.07.01)
oPars:Append(oPar)
oPar := oCmd:CreateParameter("end", adDate, ;
adParamInput,NIL,1996.07.31)
oPars:Append(oPar)
oPar := oCmd:CreateParameter("total", adCurrency, ;
adParamOutPut,NIL,NIL)
oPars:Append(oPar)
? "Parameters"
FOR i := 1 TO oPars:Count
oPar := oPars:[Item,i]
? i, PadR(oPar:Name,12) ,;
PadR(AdoEnum2Str(oPar:Direction,;
AdoParameterDirectionEnum(),FALSE),20), ;
AdoEnum2Str(oPar:TYPE, AdoDataTypeEnum(), FALSE), oPar:Value
NEXT
wait
oRs := oCmd:Execute(NIL,NIL,NIL)
? "List of results"
?
DO WHILE ! oRs:EOF
FOR i := 1 TO oRs:Fields:Count
?? PadL(oRs:FIELDGET(i),12)
NEXT
?
oRs:MoveNext()
ENDDO
oRs:close()
? "Value OF RETURN and Output PARAMETER"
? oPars:[Item, "Return"]:Value
? oPars:[Item, "total"]:Value
?
wait