Data.DB.TParams.ParseSQL

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function ParseSQL(const SQL: string; DoCreate: Boolean): string;

C++

System::UnicodeString __fastcall ParseSQL(const System::UnicodeString SQL, bool DoCreate);

Properties

Type Visibility Source Unit Parent
function public
Data.DB.pas
Data.DB.hpp
Data.DB TParams

Description

Locates the parameters in an SQL statement and replaces them with question marks.

Call ParseSQL to replace all the parameters in the SQL statement passed as SQL with question marks (?). ParseSQL recognizes parameters by a preceding colon (:). Double colons (::) or colons contained in quoted strings are parsed as literals, and the immediately following name is not replaced with a question mark. The converted SQL statement is returned.

If the DoCreate parameter is true, all parameters in the Items property are replaced with a set of TParam objects whose names are the same as the strings removed from the SQL statement.

For example, given the SQL string

SELECT * FROM EMPLOYEES WHERE (ID = :EMP_ID) AND (NAME = :EMP_NAME)

ParseSQL returns the string

SELECT * FROM EMPLOYEES WHERE (ID = ?) AND (NAME = ?)

and, if DoCreate is true, the Items property contains two TParam objects with the names EMP_ID and EMP_NAME.

See Also