IDalCommand.Parse

Syntax

Parse;

Description

The Parse method analyzes a string, detects operators, conditions and parameters. After analyzing the compiler knows which conditions are used in the SQL query, the number of parameters, and so on.

Example

Executing the example requires that the repository contains a database with the BD identifier.

Add links to the Dal, Db, and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Com: IDalCommand;
    Cur: IDalCursor;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("BD").Open(NullAs IDatabaseInstance;
    Com := DB.Connection.CreateCommand("");
    Com.SQL := "Select * From Table_1 Where (Num1 > :Param) And (F_Date = :Param1)";
    Com.Parse;
    Com.Params.Item(0).Value := 40;
    Com.Params.Item(1).Value := "03.03.2000";
    Cur := Com.CreateCursor;
    While Not Cur.Eof Do
        i := i + 1;
        Cur.Next;
    End While;
    Cur.Close;
    Com.Close;
End Sub UserProc;

After executing the example the connection to BD database is established, and the SQL query that selects all records from the Table_1 table, for which the values of the Num1 and F_Date fields satisfy the assigned parameters, is executed. Two parameters are found as a result of the analysis of the SQL query using the Parse method.

See also:

IDalCommand