Sql Question


i defined below sql in schema:

select TASK_LIST_DT_SYS, count(*) as TTL_NO from TASK_LIST_TBL
where {where}

then I new newdataset as below to get data

srcData := Serviceschema.NewDataset(Connection,‘TASK_COUNT_VIEW’,[],wb.Xml);

However, if I put the field not in select statement, it show error that complain that field cant be in the where clause. However that field is in the task_list_tbl.

If I need usae a field in where clause which not in the select statement. How can I do that?

Please advise



this is as expected.

By security reasons we disallow this case by default.

Check TDataAbstractService.AllowAllFieldsInDynamicWhere property. Here you can change default behavior.

I already set this one but still show this error.

Please advise.


Some overloads of NewDataset have AllowAllFieldsInDynamicWhere parameter.
use it and set that parameter to True.

    function NewDataset(const aConnection: IDAConnection; const aName: string;
      aDynSelectFields: array of string;
      aWhereClause: UnicodeString;
      aStatementName: string='';
      OpenIt: boolean = false;
      AlwaysGenerateDynamicWhereStatement: Boolean=False;
      AllowAllFieldsInDynamicWhere: Boolean = False;
      aSortColumnName: string = '';
      aSortAscMode: boolean = True;
      aMaxRecords: Integer = -1;
      aConnectionType: string=''): IDADataset; overload;