How to reference the field name in Firedac in Delphi

I am developing an application that runs on multiple databases, many of which have their own way to refer to reserved words as field names, such as
such as

< /p>

select `key` from mytable

or

select "key" from mytable

Either

select [key] from mytable

I want to know if there is a preprocessor command (or some other mechanism) that can automatically Determine the correct quote character to use for a given database. Yes (before someone commented) I shouldn’t use reserved words to denote field names, but the pattern is already predefined (decades ago).

For constant SQL command strings, you can replace escape sequence with the {id} identifier. Example Usage:

FDQuery1.SQL.Text :='SELECT {id Key} FROM {id MyTable}';
FDQuery1.Open;

For the assignment in the code, you can use the substitution variable macro with the AsIdentifier accessor. Example usage:

FDQuery1.SQL.Text :='SELECT &KeyCol FROM &TheTable';
FDQuery1.MacroByName('KeyCol').AsIdentifier :='Key';
FDQuery1.MacroByName('TheTable') .AsIdentifier :='MyTable';
FDQuery1.Open;

I am developing an application that runs on multiple databases, many of which have Use your own way to quote reserved words as field names, such as
such as

select `key` from mytable

either

select "key" from mytable

Either

select [key] from mytable

I want to know if there is a preprocessor command (or some other mechanism) that can automatically determine the The correct quote character for a given database. Yes (before someone commented) I shouldn’t use reserved words to denote field names, but the pattern has been predefined (decades ago).

For constant SQL command strings, you can use {id} identifier to replace escape sequence. Example usage:

FDQuery1.SQL.Text :='SELECT {id Key} FROM {id MyTable}';
FDQuery1.Open;

For the allocation in the code, you can add substitution variable macro is used with the AsIdentifier accessor. Example usage:

FDQuery1.SQL.Text :='SELECT &KeyCol FROM &TheTable';
FDQuery1.MacroByName('KeyCol').AsIdentifier :='Key';
FDQuery1.MacroByName('TheTable').AsIdentifier :='MyTable';
FDQuery1.Open ;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3187 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.