Board index » delphi » TStoredProc created in runtime

TStoredProc created in runtime

Hi

Could you give me some example how to create tstoredproc in runtime.
Also how to pass the parameters, how to get results and how to free the
memory ?

Thanks.

 

Re:TStoredProc created in runtime


Jaro,

function UpdateSomething(const UpdateThis :String):Boolean;
var
   sp_YourProc :TStoredProc;
begin
   sp_YourProc := TStoredProc.Create(nil);
   try
      with sp_YourProc do
         begin {Start of with Stored proc do}
            try    {Start of try...except block}
               DatabaseName := 'whatever your TDatabase.DatabaseName is';
               StoredProcName := 'YourProcName';
               Params.CreateParam(ftString,'@UpdateThis',ptInput);
               ParamByName('@UpdateThis').Value := UpdateThis;
               ExecProc;
               Result := True; {you may want better exception handling}
            except
               on e: Exception do
                  begin
                     Result := False;
                     {display an error, return an error code, whatever you
like}
                  end;
            end;  {End of try...except block}
         end; {End of with Stored proc do}
   finally
      sp_YourProc.Free;
   end;

Good luck,
krf

Quote
Jaro <j...@molis.be> wrote in message news:3b20cf7d_2@dnews...
> Hi

> Could you give me some example how to create tstoredproc in runtime.
> Also how to pass the parameters, how to get results and how to free the
> memory ?

> Thanks.

Other Threads