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 > PC based Database Applications > Microsoft Excel > Invalid Identifier

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-07, 04:52
Ritch77 Ritch77 is offline
Registered User
 
Join Date: May 2007
Posts: 3
Invalid Identifier

Guys,

I have been asked to roll back the years and do some development work on botched attempt by one of my previous colleagues to create a Project Management Dashboard...

Anyway I have hit an error today and I can't get past it!

I am submitting a query from VB in Excel to an Oracle Database as below;

rs.Open "SELECT CUSTOMER_NAME, TO_CHAR(START_DATE), TO_CHAR(END_DATE), PROJECT_MANAGER, HEAD_OF_PROJECTS, PRODUCT, CLARITY_ID, PROJECT_SCOPE, OVERALL_STATUS, CONTRACT, CURRENT_PHASE, PERCENT_COMPLETE, EST_PERCENT_TO_COMPLETE FROM PROJECT, PROJECT_LAYER WHERE PROJECT.PROJECT_ID = PROJECT_LAYER.PROJECT_ID and PROJECT.PROJECT_ID = " + strProject + " and TO_CHAR(LAYER_DATE, 'DD-MON-YY') = " + strReportDate, con

and I am getting the following error;

Run-time error '-214721900 (80040e14)':

[Microsoft][ODBC driver for Oracle][Oracle]ORA-00904: "MAY": invalid identifier

strReportDate is a string and contains '15-MAY-07'

I have tried the code directly against the database via Toad, hardcoding the variables as they are and it works.

Any ideas?

cheers
Reply With Quote
  #2 (permalink)  
Old 05-16-07, 04:57
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
and TO_CHAR(LAYER_DATE, 'DD-MON-YY') = " + strReportDate, con
Do the lack of a closing quote plus a dangling ", con" have anything to do with it?
EDIT: Being foolish, nevermind about th quote

And why do you convert your LAYER_DATE to char instead of converting strReportDate to date?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 05-16-07, 04:59
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Oh, oh oh!
Actually...
Code:
and TO_CHAR(LAYER_DATE, 'DD-MON-YY') = '" + strReportDate + "'", con
Might cover it....
Remeber that strings need to be treatead as strings (wrapped in singles)
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 05-16-07, 05:03
Ritch77 Ritch77 is offline
Registered User
 
Join Date: May 2007
Posts: 3
excellent that works perfectly now, thank you very much.
Reply With Quote
  #5 (permalink)  
Old 05-16-07, 05:04
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
It was the quotes, wasn't it?
And you are more than welcome
__________________
George
Twitter | Blog
Reply With Quote
  #6 (permalink)  
Old 05-16-07, 05:06
Ritch77 Ritch77 is offline
Registered User
 
Join Date: May 2007
Posts: 3
It most definitely was the quotes......

thankfully the day is almost over so don't have to hang my head in shame too much longer!
Reply With Quote
  #7 (permalink)  
Old 05-16-07, 05:46
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Luky for some!
May work day has only began 2 hours and 15 minutes ago *sigh*
__________________
George
Twitter | Blog
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On