Publish date: 2003-01-05
Work with IN and OUT parameters in stored procedure
The procedure get_heapid has one IN and one OUT parameter. Point out on adParamInput and adParamOutput.
function TPxBank.GetID(strHeap:WideString; out id: integer): HResult;
var
cmd: _Command;
ra: OleVariant;
begin
Result := S_Ok;
try
cmd := CoCommand.Create;
cmd.Set_ActiveConnection(GetConnection);
cmd.CommandText := 'execute procedure get_heapid(?)';
cmd.Parameters.Append(cmd.CreateParameter('heap', adVarChar, adParamInput, length(strHeap), strHeap));
cmd.Parameters.Append(cmd.CreateParameter('id', adInteger, adParamOutput, -1, 0));
cmd.Execute(ra, EmptyParam, 0);
id := cmd.Parameters.Item['ID'].Value;
SetComplete;
except
on E: Exception do begin
Result := E_FAIL;
SetAbort;
raise;
end;
end;
end;
