 |
| 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
|
|
|
|

June 11th, 2004, 05:27 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 11th, 2004, 05:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 11th, 2004, 06:02 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 11th, 2004, 11:01 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 14th, 2004, 02:00 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |