Home DADE

Specify the dataset on creating runtime Where-clause

edited March 2003 in DADE
In the Data tab of my report I'm using a query based on a join between
three tables. Each of these table has a column named "BoekSoort".
When I want to add a restriction on this column in the where clause I'm
using the following code (from the ExtraxtSQLObject sample):

lSQL.AvailableCriteriaList(lFields);

{set string list entries to field names}
for liIndex := 0 to lFields.Count - 1 do
lFields[liIndex] := TdaField(lFields.Objects[liIndex]).FieldName;

{create BoekSoort criteria}
liIndex := lFields.IndexOf('BoekSoort');

The result is not exactly what I want. In the where-clause the criteria
is added on .BoekSoort. For performance reasons I want
to have the criteria on .BoekSoort. Is it possible to specify
the . on which you want to add the criteria?
The help file did not help me much.

Is there some help/documentation available on the daSQL module?

Thanks,

Arjen Korpershoek

Comments

  • edited March 2003
    There is no documentation on TdaSQL. The source is the documentation. DADE
    was supposed to be an internal library, but it is possible to interact with
    it at runtime. You'll have to use smoe more code. In the demo, there is a
    line which gets the fields, with Tablename.Fieldname as a single string.
    Find the index of the field that you want in this list and then find it in
    the other list as the demo does in the next few lines. Here is the section
    that I changed in the demo. Notice that there is a space at the end of the
    orders.CustNo string. You can loop through the lFields list and trim them
    before performing the IndexOf call on it.

    lSQL.AvailableCriteriaList(lFields);

    {added a memo to see the table.fieldnames list visually}
    Memo1.Lines := lFields;

    {used new liCriteriaIndex local variable instead of liIndex}
    liCriteriaIndex := lFields.IndexOf('orders.CustNo ');

    {make the call with the index retrieved using the tablename.fieldname}
    if (liCriteriaIndex <> -1) then
    begin
    lCriteria := lSQL.SelectCriteria(liCriteriaIndex);
    lCriteria.Operator := dacoEqual;
    end;


    {set string list entries to field names}
    for liIndex := 0 to lFields.Count - 1 do
    lFields[liIndex] := TdaField(lFields.Objects[liIndex]).FieldName;

    {create other criteria as shown in the demo using liIndex...}

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Thanks Jim,
    It works ok now.

    Best regards,
    Arjen

This discussion has been closed.