Delphi: Paradox DB Field Name Issue (Spaces in field name)

此生再无相见时 提交于 2019-11-28 07:34:31

问题


I have a paradox table from a legacy system I need to run a single query on. The field names have spaces in them - i.e. "Street 1". When I try and formulate a query in delphi for only the "Street 1" field, I get an error - Invalid use of keyword. Token: 1, Line Number: 1

Delphi V7 - object pascal, standard Tquery object name query1.


回答1:


You need to prefix the string with the table name in the query.

For example: field name is 'Street 1', table is called customers the select is:

SELECT customers."Street 1" FROM customers WHERE ...



回答2:


You normally need to quote the field name in this case. For example:

select * from t1 where "street 1" = 'test';

I tried this on a paradox 7 table and it worked. If that doesn't help, can you post the query you are trying to use? It would be easier to help with that info.




回答3:


I only need the street information from the address details held in the customer table. I can get it to work fine if I do a SELECT * FROM customers, however this is a very large table and returns numerous results. If I do SELECT "Street 1" FROM customers, the output is "Street 1" in every record returned - i.e. it does not return the actual data. It must be something to do with the use of "

Thanks for your help

Joe




回答4:


I think you must use [ and ] instead of ":

SELECT customers.[Street 1] FROM customers WHERE ...


来源:https://stackoverflow.com/questions/116163/delphi-paradox-db-field-name-issue-spaces-in-field-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!