Article View: borland.public.vdbase.data.sql
Article #1035Re: Reserved Word Field Name Crashes SQL Builder
From: Steve Koterski
Date: Wed, 03 Jun 1998 00:00
Date: Wed, 03 Jun 1998 00:00
71 lines
3845 bytes
3845 bytes
On 3 Jun 1998 11:12:56 GMT, "Alan" <ABoba@Compuserve.com> wrote: >My bank downloads my account data to a Microsoft Access v2.0 database. One >of the fields is named Desc. As it turns out, "Desc" is a reserved word. >(gimmie a break, I'm a SQL novice) Sorry, but the SQL-92 specification explicitly states that there will be no breaks given novices <gd&r>. Article 23, section 9A states: "Neither break nor slack shall ye give to they new to the sport." >If I use the Visual SQL tool, any attempt to run or close a query that uses >the "Desc" field crashes VdB. > >If I use the SQL editor and enter the field name as tablename."Desc" the >queries run fine. If I subsequently open the Visual SQL tool the query gets >hosed again. I'm no where near fluent enoungh to use the SQL editor to >create my queries. I cannot speak for this Visual SQL tool in Visual dBASE, perhaps one of the emminent dBASE TeamB folks will chime in on that. I can say, though, that the use of reserved words for metadata object names (like column and table names) is bad medicine. It can lead to problems no matter what programming front-end or database back-end you might use. This practice is highly discouraged. It is also documented in the local SQL online help file, LOCALSQL.HLP, found in the main BDE directory. Having said all that, you should know that local SQL *can* work with columns named after reserved words. In local SQL statements, the column name must be enclosed in quotation marks and that reference prefixed with either the table name or a table correlation name. SELECT T1."Desc" FROM "MyTable.dbf" T1 Now, just because local SQL supports this syntax does not guarantee all database systems will. Most will support this type syntax. Microsoft Access, known for a number of deviations from standard SQL, will also accept the column name delimited by square brackets (and prefixed with a table reference). But to do this from Visual dBASE, you would need to use pass-through SQL. (I believe this is done with the ExecSQL function.) For example: SELECT T1.[Desc] FROM MyTable T1 And, just because local SQL (common to all BDE-using INPRISE programming tools) supports this syntax and noncompliant use of reserved words does not guarantee every visual SQL-building tool will. >Does anyone know how to correct this problem so the reserved field name my >be selected from within the Visual SQL tool? As indicated before, use of reserved words is discouraged and "against the rules." To then support deviation from the rules in this visual tool would be unlikely. The better solution is to use appropriate naming conventions. BTW, DESC (accepted short form for DESCENDING) is an element in the SQL-92 specification. Very standard, commonly-used. DESC as a reserved word is not specific to the Borland Database Engine, local SQL, Visual dBASE, or even Access. >Does the point release that Borland charges $20 s&h correct the problem? No. INPRISE does not produce updates for the SQL-92 specification. ************************************************************************** Steve Koterski INPRISE Corporation, Technical Publications http://www.inprise.com/delphi
Technical Details
Message-ID:
<357cb34b.19646519@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01bd8ee1$d575e0e0$c58baec7@ctx>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff5a1,b0b2a4c92d05bb82 X-Google-Attributes: gidff5a1,public From: koterski@borland.com (Steve Koterski) Subject: Re: Reserved Word Field Name Crashes SQL Builder Date: 1998/06/03 Message-ID: <357cb34b.19646519@forums.inprise.com> X-Deja-AN: 359260543 Content-Transfer-Encoding: 7bit References: <01bd8ee1$d575e0e0$c58baec7@ctx> Content-Type: text/plain; charset=us-ascii Organization: INPRISE Corporation, Technical Publications Mime-Version: 1.0 Reply-To: koterski@borland.com Newsgroups: borland.public.vdbase.data.sql