How to query a odbc datasource with field named date

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
jeisma
Participant
Posts: 18
Joined: Mon Mar 20, 2017 12:19 pm

How to query a odbc datasource with field named date

Post by jeisma »

hi,

my odbc datasource has a field with name "date". I get error "... Syntax error in SQL statement at or about "date FROM PUB.my_table" (10713)

i tried to manually the query using several combinations like:

SELECT my_table.date FROM PUB.my_table
SELECT [date] FROM PUB.my_table

tried, SELECT 'date' FROM PUB.my_table - but it threw me a separate batch of errors, it seems that the value is being converted to character as being read, and to date again before being written.
Any ideas how to do this?

Thanks!
PaulVL
Premium Member
Premium Member
Posts: 1315
Joined: Fri Dec 17, 2010 4:36 pm

Post by PaulVL »

Slap your source system DBA team with so many lefts they will be begging for a right.

There are certain key words that should not be used for column names in databases. I am surprised that they would have allowed that.

If they allowed the "date" column name, ask them for the correct syntax for the SQL statements to extract data. Have them give you an example of it running.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What database is this, exactly? For SQL Server, the square brackets [date] syntax should have worked or at least that's my understanding. But the rules for reserved words change from DB to DB so it would be good to know for certain which one it was.

And yes, a stern finger-wagging is in order for whomever chose that field name. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
jeisma
Participant
Posts: 18
Joined: Mon Mar 20, 2017 12:19 pm

Post by jeisma »

It's a Progress RDBMS database. i would personally would have named it according to the purpose of the field (ie. trans_date, po_date, etc).

I may be able argue to rename that field if indeed there is no way out of the error.

And avoiding the finger-wagging and slapping :wink: I'd ask the rational why they used that field name.
jeisma
Participant
Posts: 18
Joined: Mon Mar 20, 2017 12:19 pm

Post by jeisma »

hi,

that actually worked!

thank you!

(i would still argue to rename that field though.. :-)
Post Reply