If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Strange Syntax error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-10, 08:14
tosa tosa is offline
Registered User
 
Join Date: Feb 2010
Posts: 35
Strange Syntax error

Hi!

When I do a "SELECT * ..." from a certain table, I get a normal result with rows and column headers. One column header reads "Resource", but when I do a "SELECT Resource FROM ..." I get Syntax error in SQL statement at or about "Resource FROM PUB.ActOper WHERE CreDate " (10713). It's a Progress database.

What could be the problem? Thanks!
Reply With Quote
  #2 (permalink)  
Old 05-26-10, 08:24
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
Quote:
Originally Posted by tosa View Post
What could be the problem?
my money is on RESOURCE being a reserved word
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-27-10, 02:21
tosa tosa is offline
Registered User
 
Join Date: Feb 2010
Posts: 35
Yes, that was it. How silly of me. Thank you. But when you solve one problem, along comes the next. According to the Progress SQL reference "you can use keywords as identifiers in SQL statements only if you delimit them with double quotation marks".

But I can't find the right syntax to use in my ASP.NET page. Double and single quotation marks are not interchangeable it seems. This will not work: Dim comm As New OdbcCommand('SELECT "Resource" FROM PUB.Table', conn)

Does anyone know the correct way to write this sentence?
Reply With Quote
  #4 (permalink)  
Old 05-27-10, 02:50
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
You did not post the error message that you received (I don't believe "This will not work" is a valid error message in Progress).

For future posts please remember: "does not work" will not get you any help. Post the exact error message that the DBMS (not your programming language!) gives you. Use Copy & Paste for that


So my wild guess is:

Normally column (and table) names are stored in uppercase in the database, which doesn't matter because SQL is case-insensitive.

When you use double quotes around an identifier, you are requesting to handle it in a case-sensitive manner ("Resource" being a different column than "RESOURCE").

So I would guess you will need to use

SELECT "RESOURCE" FROM PUB.Table
Reply With Quote
  #5 (permalink)  
Old 05-27-10, 03:35
tosa tosa is offline
Registered User
 
Join Date: Feb 2010
Posts: 35
Ok, sorry for not being clear enough.

The exact name of the column is Resource.

Case 1:
Dim comm As New OdbcCommand("SELECT Resource FROM PUB.ActOper WHERE CreDate > TO_DATE ('05/24/2010')", conn)

ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Syntax error in SQL statement at or about "Resource FROM PUB.ActOper WHERE CreDate " (10713)

Case 2:
If I try some other combination of single and double quotes I get a compilation error saying "valid continuation expected" or "expression expected".
Reply With Quote
  #6 (permalink)  
Old 05-27-10, 04:36
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
The first step in debugging problems like this, is to run the statement outside of your programming language (using the SQL interface of your DBMS) to make sure the SQL is correct.

Plese verify first that the syntax of your statement is correct outside of your code before you run it from within your code.

Quote:
ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Syntax error in SQL statement at or about "Resource FROM PUB.ActOper WHERE CreDate " (10713)
I have no idea about BASIC but to me this sounds like you don't have the quoting right, which makes it a programming language problem - not a SQL or DBMS problem.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On