Subject Re: Index for query
Author karolbieniaszewski
--- In firebird-support@yahoogroups.com, Claudio Romero <clauslack@...> wrote:
>
> You right
> but I need this query with index
>
> SELECT * FROM table where integer_field like '21095%'
>
> because I use this in a function (Lazarus program) that support integer and
> varchar fields.
>
> Here the full function
> function GeneraSentenciaSql(Tabla,FiltroFijo,filtro,valor:string):string;
> var consulta:string;
> begin
> valor:=UpperCase(valor);
> consulta:='select * from '+Tabla+' ';
> if FiltroFijo<>'' then begin
> consulta:=consulta+'where '+FiltroFijo+' ';
> if (filtro<>'')and(valor<>'') then consulta:=consulta+'and
> '+filtro+' like '+valor;
> end
> else if (filtro<>'')and(valor<>'') then consulta:=consulta+'where
> '+filtro+' like '+valor;
> if filtro<>'' then consulta:=consulta+' order by '+filtro;
> //showmessage(consulta);
> result:=consulta;
> end;
>
> Otherwise, I must include the data field as parameter of this funcion.
> Regards
>
>
> [Non-text portions of this message have been removed]
>

then you must past this as param
but add params with default values to not use special casts ;-)

index can not be used if you not include the same expression in select

Karol Bieniaszewski