AnyDAC
ContentsIndexHome
PreviousUpNext
TADCustomCommand.CommandText Property

The SQL command text to execute.

Group
Links

The CommandText set/get:

  • SQL command text to execute
  • or name of the stored procedure to execute, if CommandKind in [skStoredProc, skStoredProcWithCrs, skStoredProcNoCrs].

After setting CommandText, AnyDAC will do for non-stored procedures:

If you are adding long command, using CommandText.Add method, then it is recommended before command modification to call CommandText.BeginUpdate and after finishing command modification to call CommandText.EndUpdate. 

Later on Prepare call command text will be preprocessed and transformed in target DBMS command. See chapter Preprocessing Command Text for details about AnyDAC macros and escape sequences - preprocessor instructions.

property CommandText: TStrings;

Stored procedure:

ADCommand1.CommandKind := skStoredProc;
ADCommand1.CommandText.Text := 'MY_PROC';
ADCommand1.Prepare;
ADCommand1.Params[0].AsString := 'qwe';
ADCommand1.Execute;

General SQL command:

ADCommand1.CommandText.Text := 'insert into MyTab values (:p1)';
ADCommand1.Params[0].AsString := 'qwe';
ADCommand1.Execute;

Adding long command:

with ADCommand1.CommandText do begin
  BeginUpdate;
  Add('............');
  ......
  Add('............');
  EndUpdate;
end;
What do you think about this topic? Send feedback!