X
XP
I am using Office 2003 on Windows XP.
I am trying to query an Oracle Database from Excel and run a "make table"
query into a csv text file. But, when I run the following code I get a
run-time error ("Query input must contain at least one table or query"). Can
someone please correct my SQL or ADO so I can get this running?
Dim sSQL As String
sSQL = "SELECT "
sSQL = sSQL & "A.ACCTNO, "
sSQL = sSQL & "A.ACCOUNT_DESC "
sSQL = sSQL & "INTO "
sSQL = sSQL & "[Text;Database=C:\Temp\;].TestFile#txt "
sSQL = sSQL & "FROM "
sSQL = sSQL & "[ODBC;" & sOracleConnection & ";].[APPS.GLBALVW] A "
sSQL = sSQL & "WHERE "
sSQL = sSQL & "A.PERIOD_NAME IN ('Sep-03', 'Sep-04') AND "
sSQL = sSQL & "A.FUND BETWEEN '800' AND '999' AND "
sSQL = sSQL & "A.ACCOUNT BETWEEN '0000' AND '8999';"
With CreateObject("adodb.connection")
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Extended Properties=""Text;HDR=Yes;"";" & _
"Data Source=C:\Temp\;"
.CursorLocation = 3 'adUseClient
.Open
.Execute sSQL
.Close
End With
Thanks much in advance.
I am trying to query an Oracle Database from Excel and run a "make table"
query into a csv text file. But, when I run the following code I get a
run-time error ("Query input must contain at least one table or query"). Can
someone please correct my SQL or ADO so I can get this running?
Dim sSQL As String
sSQL = "SELECT "
sSQL = sSQL & "A.ACCTNO, "
sSQL = sSQL & "A.ACCOUNT_DESC "
sSQL = sSQL & "INTO "
sSQL = sSQL & "[Text;Database=C:\Temp\;].TestFile#txt "
sSQL = sSQL & "FROM "
sSQL = sSQL & "[ODBC;" & sOracleConnection & ";].[APPS.GLBALVW] A "
sSQL = sSQL & "WHERE "
sSQL = sSQL & "A.PERIOD_NAME IN ('Sep-03', 'Sep-04') AND "
sSQL = sSQL & "A.FUND BETWEEN '800' AND '999' AND "
sSQL = sSQL & "A.ACCOUNT BETWEEN '0000' AND '8999';"
With CreateObject("adodb.connection")
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Extended Properties=""Text;HDR=Yes;"";" & _
"Data Source=C:\Temp\;"
.CursorLocation = 3 'adUseClient
.Open
.Execute sSQL
.Close
End With
Thanks much in advance.