filtragem no clientdataset

12/07/2004

0

estou com uma duvidazinha muita enjoada :evil:
o negócio é o seguinte eu quero fazer uma filtragem usando a propriedade [b:7d12908e95]filter[/b:7d12908e95] entre duas datas em um clientdataset, se duvidas me retorne


Metalleiro_delphiano

Metalleiro_delphiano

Responder

Posts

12/07/2004

Rômulo Barros

To restrict users to a subset of available data on a temporary basis, applications can use ranges and filters. When you apply a range or a filter, the client dataset does not display all the data in its in-memory cache. Instead, it only displays the data that meets the range or filter conditions. For more information about using filters, see Displaying and editing a subset of data using filters. For more information about ranges, see Limiting records with ranges.

With most datasets, filter strings are parsed into SQL commands that are then implemented on the database server. Because of this, the SQL dialect of the server limits what operations are used in filter strings. Client datasets implement their own filter support, which includes more operations than that of other datasets. For example, when using a client dataset, filter expressions can include string operators that return substrings, operators that parse date/time values, and much more. Client datasets also allow filters on BLOB fields or complex field types such as ADT fields and array fields. 

The various operators and functions that client datasets can use in filters, along with a comparison to other datasets that support filters, is given below:

Operator
or functionExampleSupported by other datasetsComment
Comparisons
=State = ´CA´Yes
<>State <> ´CA´Yes
>=DateEntered >= ´1/1/1998´Yes
<=Total <= 100,000Yes
>Percentile > 50Yes
<Field1 < Field2Yes
BLANKState <> ´CA´ or State = BLANKYesBlank records do not appear unless explicitly included in the filter.
IS NULLField1 IS NULLNo
IS NOT NULLField1 IS NOT NULLNo
Logical operators
andState = ´CA´ and Country = ´US´Yes
orState = ´CA´ or State = ´MA´Yes
notnot (State = ´CA´)Yes
Arithmetic operators
+Total + 5 > 100Depends on driverApplies to numbers, strings, or date (time) + number.
-Field1 - 7 <> 10Depends on driverApplies to numbers, dates, or date (time) - number.
*Discount * 100 > 20Depends on driverApplies to numbers only.
/Discount > Total / 5Depends on driverApplies to numbers only.
String functions
UpperUpper(Field1) = ´ALWAYS´No
LowerLower(Field1 + Field2) = ´josp´No
SubstringSubstring(DateFld,8) = ´1998´
Substring(DateFld,1,3) = ´JAN´NoValue goes from position of second argument to end or number of chars in third argument. First char has position 1.
TrimTrim(Field1 + Field2)
Trim(Field1, ´-´)NoRemoves third argument from front and back. If no third argument, trims spaces.
TrimLeftTrimLeft(StringField)
TrimLeft(Field1, ´$´) <> ´´NoSee Trim.
TrimRightTrimRight(StringField)
TrimRight(Field1, ´.´) <> ´´NoSee Trim.
DateTime functions
YearYear(DateField) = 2000No
MonthMonth(DateField) <> 12No
DayDay(DateField) = 1No
HourHour(DateField) < 16No
MinuteMinute(DateField) = 0No
SecondSecond(DateField) = 30No
GetDateGetDate - DateField > 7NoRepresents current date and time.
DateDateField = Date(GetDate)NoReturns the date portion of a datetime value.
TimeTimeField > Time(GetDate)No Returns the time portion of a datetime value.
Miscellaneous
LikeMemo LIKE ´¬filters¬´NoWorks like SQL-92 without the ESC clause. When applied to BLOB fields, FilterOptions determines whether case is considered.
InDay(DateField) in (1,7)NoWorks like SQL-92. Second argument is a list of values all with the same type.
*State = ´M*´YesWildcard for partial comparisons.
When applying ranges or filters, the client dataset still stores all of its records in memory. The range or filter merely determines which records are available to controls that navigate or display data from the client dataset. 

Note:When fetching data from a provider, you can also limit the data that the client dataset stores by supplying parameters to the provider. For details, see Limiting records with parameters.



Responder

12/07/2004

Motta

O filter do cds é mais completo que o do dataset ordinário.


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar