Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2004, 05:27 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reserved word conflict!

Hello,

i have a db in Oracle that i'm trying to connect using Access.
To make these simple forms.

Only, now i have a problem with one of my tables.
There is a field that is called KEY.
And as far as i know it's a reserved word.

Here is my SQL:
SELECT STREET, POSTCODE, CITY
FROM ADDRESSES, ADDRLINKS, BORROWERS
WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO AND ADDRLINKS.KEY = BORROWERS.BORROWER;

The renaming of the field is absolute not an option!
Does anybody know what i must do to make it work?

Thanks in advance!

greetz

Timmyboy

 
Old June 11th, 2004, 05:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wrap the reserved word in square brackets ([ and ]), e.g.:
Code:
SELECT STREET, POSTCODE, CITY
  FROM ADDRESSES, ADDRLINKS, BORROWERS
 WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO
   AND ADDRLINKS.[KEY] = BORROWERS.BORROWER;
   I hope this helps

Regards
Owain Williams
 
Old June 11th, 2004, 06:02 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thnx!

It works al though now i get an error that the types of expressions do not match.
ADDRLINKS.KEY = Text
BORROWERS.BORROWER = Number

greetz

Timmyboy

 
Old June 11th, 2004, 11:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am not sure how linked tables work in Access as far as SQL is concerned, but in Access SQL you can use the Val() or CLng() functions and in Oracle PL/SQL you can use the CAST function (I think, but I no hardly anything about Oracle, I only know about the SQL92 CAST function). Here is an example Access' Val() function:
Code:
SELECT STREET, POSTCODE, CITY
  FROM ADDRESSES, ADDRLINKS, BORROWERS
 WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO
   AND Val(ADDRLINKS.[KEY]) = BORROWERS.BORROWER;
   And here is an example of the CAST function
Code:
SELECT STREET, POSTCODE, CITY
Code:
  FROM ADDRESSES, ADDRLINKS, BORROWERS
 WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO
   AND CAST(ADDRLINKS.[KEY] AS Int) = BORROWERS.BORROWER;
   I hope this helps.

Regards
Owain Williams
 
Old June 14th, 2004, 02:00 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by owain
 I am not sure how linked tables work in Access as far as SQL is concerned, but in Access SQL you can use the Val() or CLng() functions and in Oracle PL/SQL you can use the CAST function (I think, but I no hardly anything about Oracle, I only know about the SQL92 CAST function). Here is an example Access' Val() function:
Code:
SELECT STREET, POSTCODE, CITY
Code:
  FROM ADDRESSES, ADDRLINKS, BORROWERS
 WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO
   AND Val(ADDRLINKS.[KEY]) = BORROWERS.BORROWER;
And here is an example of the CAST function
Code:
SELECT STREET, POSTCODE, CITY
  FROM ADDRESSES, ADDRLINKS, BORROWERS
 WHERE ADDRESSES.ADDRNO = ADDRLINKS.ADDRNO
   AND CAST(ADDRLINKS.[KEY] AS Int) = BORROWERS.BORROWER;
I hope this helps.

Regards
Owain Williams
Very very kind of you!
It works!
The VAL works but the other not.
So it's not a problem anymore!

kind regards,

timmyboy






Similar Threads
Thread Thread Starter Forum Replies Last Post
error code 1001 reserved jeremy1048 Access 3 April 9th, 2008 06:14 AM
Cryatal Report and Word document object conflict deeptisingh20 ASP.NET 1.0 and 1.1 Basics 1 July 24th, 2006 05:25 AM
Crystal Report and word document conflict deeptisingh20 ASP.NET 1.0 and 1.1 Professional 0 July 24th, 2006 04:15 AM
Avoiding Double bookings via 'reserved' status davidosullivan PHP Databases 0 March 30th, 2006 10:44 AM
removing the reserved line for the xml tag muki XSLT 2 November 2nd, 2005 04:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.