TTable.Filter and Minus-Sign in Fieldnames 
Author Message
 TTable.Filter and Minus-Sign in Fieldnames

Hi,

i have an odbc-data source, i'm using the ttable component and everything
works fine with the exception of the filter-attribute when a fieldname of
the table has a minus-sign including:

Using
n-herkunft = 'MVA*'
raises the error: Unable to find field 'n'

Due to restrictions from the customer i am not able to rename the fields
physically in the database - is there any workaround? is there a way to
rename the fields in the delphi program for the ttable component?

Thx
  Sven Klaus

--
Sven Klaus

CUTEC-Institut GmbH, Leibnizstr. 21-23, D-38678 Clausthal-Z., Germany
Phone: +49 5323 933 335



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames
You could try replacing the TTable with a TQuery component, explicitly
specify the fields you're interested in in the SQL property, and enclose
your fieldnames in quotes?

HTH,

Conor


Quote:
> Hi,

> i have an odbc-data source, i'm using the ttable component and everything
> works fine with the exception of the filter-attribute when a fieldname of
> the table has a minus-sign including:

> Using
> n-herkunft = 'MVA*'
> raises the error: Unable to find field 'n'

> Due to restrictions from the customer i am not able to rename the fields
> physically in the database - is there any workaround? is there a way to
> rename the fields in the delphi program for the ttable component?



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames


Quote:
> Hi,

> i have an odbc-data source, i'm using the ttable component and everything
> works fine with the exception of the filter-attribute when a fieldname of
> the table has a minus-sign including:

> Using
> n-herkunft = 'MVA*'
> raises the error: Unable to find field 'n'

Enclose the field name in quotes, e.g.

    'n-herkunft'='MVA*'

Quote:

> Due to restrictions from the customer i am not able to rename the fields
> physically in the database - is there any workaround? is there a way to
> rename the fields in the delphi program for the ttable component?

> Thx
>   Sven Klaus

> --
> Sven Klaus

> CUTEC-Institut GmbH, Leibnizstr. 21-23, D-38678 Clausthal-Z., Germany
> Phone: +49 5323 933 335



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames

Quote:
>i have an odbc-data source, i'm using the ttable component and everything
>works fine with the exception of the filter-attribute when a fieldname of
>the table has a minus-sign including:

>Using
>n-herkunft = 'MVA*'
>raises the error: Unable to find field 'n'

>Due to restrictions from the customer i am not able to rename the fields
>physically in the database - is there any workaround? is there a way to
>rename the fields in the delphi program for the ttable component?

Whenever you have fields with unusual names (such as with embedded spaces
or mathematical operators), enclose the field name in square brackets in
the Filter property string.

  [n-herkunf] = 'MVA*'

This is currently not mentioned in the help, but I have added it for future
releases or updates.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames
Hello!

: Whenever you have fields with unusual names (such as with embedded spaces
: or mathematical operators), enclose the field name in square brackets in
: the Filter property string.
:   [n-herkunf] = 'MVA*'

[fieldname] works! Thanks a lot!

'fieldname' works for delphi, but raised an error (Incompatible datatypes)
on the database server side.

Regards
  Sven

--
Sven Klaus

CUTEC-Institut GmbH, Leibnizstr. 21-23, D-38678 Clausthal-Z., Germany
Phone: +49 5323 933 335



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames

Quote:
>[fieldname] works! Thanks a lot!

>'fieldname' works for delphi, but raised an error (Incompatible datatypes)
>on the database server side.

It causes an error *when*? When you set the Filter property? When you
execute an SQL statement with that column name? Or ... ?

(Follow-ups to the newsgroup only, please.)

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Nothing is impossible for the man who doesn't
Felton, CA                  have to do it himself."
                                                           -- A. H. Weiler



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames
:>'fieldname' works for delphi, but raised an error (Incompatible datatypes)
:>on the database server side.
: It causes an error *when*? When you set the Filter property? When you
: execute an SQL statement with that column name? Or ... ?

Hi Steve

i set the property filter to
'fieldname' = 'bla'
and when i turned filtered to true
then i got an error message from the progress database server
[ODBC][Openlink][Progress]Incompatible DataTypes
together with an Progress Database error number - when i set the filter
property to
[fieldname] = 'bla'
it worked fine.

i work with:
Delphi 4.0 C/S, Service Pack 3
ODBC 3.0
OpenLink MultiTier DataAccess Suite 3.2
Progress 8.3A
Client and Server OS are Win NT 5.0

Regards
  Sven Klaus

--
Sven Klaus

CUTEC-Institut GmbH, Leibnizstr. 21-23, D-38678 Clausthal-Z., Germany
Phone: +49 5323 933 335



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames

[...]

Quote:
>i set the property filter to
>'fieldname' = 'bla'
>and when i turned filtered to true
>then i got an error message from the progress database server
>[ODBC][Openlink][Progress]Incompatible DataTypes
>together with an Progress Database error number - when i set the filter
>property to
>[fieldname] = 'bla'
>it worked fine.

Why is your table column name in quotation marks anyway? Enclosing a column
name in delimiters should only be necessary when the name is the same as a
reserved word or contains embedded spaces (or other unusual characters).
Your column name does not fit either profile.

By enclosing it in single quotation marks, I would suspect that the SQL
generated from that and passed to your database back-end includes a
comparison between the string "fieldname" (a string, not a column) and the
string "bla". Use a utility like SQL Monitor to spy on this background SQL
to see what is actually sent.

So the contents of your Filter property should look more like this:

  fieldname = 'bla'

Or, when filling this property programmatically at runtime:

  Query1.Filter := 'fieldname = ' + QuotedStr('bla');

When using the Filter property with columns that require a delimiter
(embedded space in the name or a reserved word), use the square brackets
and not quotation marks.

  [Species Name] = 'Lutjanus jocu'

Or, when done at runtime:

  Query1.Filter := '[Species Name] = ' + QuotedStr('Lutjanus jocu');

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Nothing is impossible for the man who doesn't
Felton, CA                  have to do it himself."
                                                           -- A. H. Weiler



Wed, 18 Jun 1902 08:00:00 GMT  
 TTable.Filter and Minus-Sign in Fieldnames
:>i set the property filter to
:>'fieldname' = 'bla'
:>and when i turned filtered to true
:>then i got an error message from the progress database server

Hi Steve,

the precise data are the ones from my initial posting from this thread:
tablename: lb-stamm (not importatnt)
fieldname: n-herkunft
filter:    = 'MVA*'

'n-herkunft' = 'MVA*'
raised the incompatible datatypes error from the progress database server

[n-herkunft] = 'MVA*'
worked well

: Why is your table column name in quotation marks anyway? Enclosing a column
: name in delimiters should only be necessary when the name is the same as a
: reserved word or contains embedded spaces (or other unusual characters).
: Your column name does not fit either profile.

as i stated in my initial psting, using
n-herkunft = 'MVA*'
raised the error that the bde cannot find a column n

but i have another question: is there any way to use something like:
[n-herkunft] = '*MVA*'

(this didn't worked in delphi 4 in the "expected" way ....)

Regards
  Sven

--
Sven Klaus

CUTEC-Institut GmbH, Leibnizstr. 21-23, D-38678 Clausthal-Z., Germany
Phone: +49 5323 933 335



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Filtering on fields with minus sign ('- ') in fieldname

2. TTable Filter property

3. TTable.Filter question in C/S app

4. TQuery / TTable .Filter expression

5. Problem with TTable Filter

6. Problem with Filter of TTable .....?

7. TTable filter and wildcards?

8. Bug in TTable.Filter (D4)

9. ttable filter y2k problem

10. About TTable.Filter

11. DBLookupCombo and filtering TTable problem

12. Filtering a ttable : operation not applicable....

 

 
Powered by phpBB® Forum Software