-
SQL query on Oracle DB
Hi!
I have some problems with running an SQL-query on an Oracle db in VB
I've run the following query in Oracle SQL*Plus, which went just fine.
SQL> SELECT Min(pt.A_DATE)
FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p
WHERE pt.ACT_SEQ = a.ACT_SEQ
AND pt.PROJ_ID = a.PROJ_ID
AND pt.SUB_ID = a.SUB_ID
AND pt.ACT_NO = a.ACT_NO
AND pt.PROJ_ID = p.PROJ_ID
----------
2003-08-04
I'm trying to run the same query in VBA, where I get the error message: Invalid Character.
There's nothing wrong with the connection to the oracle DB, cos I can run the query if I only use the first 2 rows.
But when I add the where-statement I get the error-message. Have I missed something in the syntax, I'm just trying to connect a couple of tables.
connection1 = "Provider=MSDAORA.1;" & _
"Data Source=A;" & _
"User Id=AB;" & _
"Password=AB"
Set oCn1 = New ADODB.Connection
oCn1.Open connection1
szSQL = "SELECT Min(pt.A_DATE)" & _
"FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p" & _
"WHERE pt.ACT_SEQ = a.ACT_SEQ" & _
"AND pt.PROJ_ID = a.PROJ_ID" & _
"AND pt.SUB_ID = a.SUB_ID" & _
"AND pt.ACT_NO = a.ACT_NO" & _
"AND pt.PROJ_ID = p.PROJ_ID;"
Set oRs1 = New ADODB.Recordset
oRs1.Open szSQL, oCn1, adOpenForwardOnly, adLockReadOnly, adCmdText
/Bjso
-
Just a guess, but it looks like you don't have any spaces separating the lines. Try this.
szSQL = "SELECT Min(pt.A_DATE)" & _
" FROM APP.PROJECT_TRANSACTION pt,APP.ACT a, APP.PROJ p" & _
" WHERE pt.ACT_SEQ = a.ACT_SEQ" & _
" AND pt.PROJ_ID = a.PROJ_ID" & _
" AND pt.SUB_ID = a.SUB_ID" & _
" AND pt.ACT_NO = a.ACT_NO" & _
" AND pt.PROJ_ID = p.PROJ_ID;"
-
Thanks, that was it.
bjso