Customsql at Server Side

Hi,

id := Connection.NewDataset(sql) as IDAServerDataset;

I use this method to get custom sql datatset. However, some sql is contain special character that violate the sql syntax. Is there any way to make sql safe or can I use parameter way like parambyname to do it?

Please advise.

joe

Hi,

You can use ParamByName or DynamicWhere for using special characters:

    procedure RefreshParams;
    function ParamByName(const aName: string): TDAParam;    
    property Params: TDAParamCollection read GetParams;
    property DynamicWhere: TDAWhereBuilder read GetDynamicWhere write SetDynamicWhere;

Yes I know this but as I use it at serverside module and it supp by IDAServerDataset;.

can you provide a simple example?

Thanks

Hi,

simple examples:
*

id := Connection.NewDataset('select * from table where field1 = :p') as IDAServerDataset;
id.ParamByName('p').Value := some_value;
id.Open;
id := Connection.NewDataset('select * from table where {WHERE}') as IDAServerDataset;
id.DynamicWhere.Expression := id.DynamicWhere.NewBinaryExpression('table','field1',some_value);
id.Open;