FireDAC Components for Basecamp

Build 20.0.7587

Executing Stored Procedures

You can prepare and execute stored procedures with a TFDStoredProc or TFDQuery object. Use TFDStoredProc when the stored procedure does not return a result set. To retrieve a stored procedure's results, use TFDQuery.

Using TFDStoredProc

When visually designing an application, after you select the StoredProcName menu in the Object Inspector, you are prompted to connect. The list of available stored procedures is then displayed in the menu. After selecting a stored procedure, the Params collection is filled in automatically.

You can then set parameter values in code:

FDStoredProc1.StoredProcName := 'RefreshOAuthAccessToken';
FDStoredProc1.Prepare;
FDStoredProc1.ParamByName('OAuthAccessToken').AsString := 'OAuthAccessToken';
FDStoredProc1.ExecProc;

Using TFDQuery

TFDQuery objects cannot generate a stored procedure call based on the stored procedure metadata. To execute a stored procedure with a TFDQuery object, you will need to write the SQL statement:

FDQuery1.SQL.Text := 'EXEC RefreshOAuthAccessToken OAuthAccessToken = :OAuthAccessToken';
FDQuery1.Params[0].AsString := 'OAuthAccessToken';
FDQuery1.Open;

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587