Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Select Statement

Status
Not open for further replies.

cdm1221

Programmer
Jan 26, 2004
32
0
0
US
Can someone tell me why I get an error (ORA-00911: invalid character) for the following statement:

strQuery = "SELECT A.SEQ_GMT FROM _SMDBA_._PERSONNEL_ A
WHERE A.CODE = " & user
Set rs1 = conn1.Execute(strQuery)

I believe it's because of the period in the table name. Does anyone know a workaround for this besides changing the name?
 
If "user" isn't numeric, that's why you're getting the error. There was a post very similar to this yesterday.

Try this:
Code:
strQuery = "SELECT A.SEQ_GMT FROM _SMDBA_._PERSONNEL_ A
WHERE A.CODE = [b]'" & user & "'"[/b]
Set rs1 = conn1.Execute(strQuery)
(Note the added single quotes arount the user field.)

-dave
 
I had tried this before, and again now. But the same error message. "user" is a string, and I think your suggestion was correct. However, I believe the error still appears because of the period in the table name. I have no control over the table name; the period has to remain.
 
Ok, didn't get that the first time. Try using brackets around the table name like this:
Code:
SELECT A.SEQ_GMT FROM [_SMDBA_._PERSONNEL_] A
-dave
 
BTW, thanks for replying to me.

Tried that too, and tried some iSQL suggestion to use \" before the table name and before the period. But, that doesn't work either in the quotations - throws a VB compilation error. Any other suggestions???
 
Okay I threw two double quotes around the table name and now the "ORA-00942: table or view does not exist" error appears. Do you think that fixed it or caused a new error?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top