I am trying to pass PL/SQL query from file via VBA to the Oracle DB.
Simple test query like SELECT * FROM DUAL
works flawlessly.
However just a bit more complicated (even not yet PL/SQL) like
SELECT x, y, z FROM table WHERE DATE = '5may2017'
already fails (actually no explicit error, just empty result).
I'm connecting to Conn.Provider = "OraOLEDB.Oracle.1", apply user schema by ALTER SESSION SET CURRENT_SCHEMA=MyUserSchema. Finally my last code-snippet is:
With Cmd
.Properties("PLSQLRSet") = True '(actually this line doesnt affect)'
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = SqlStatement
Set rs = .Execute
End With
Sheets(1).Range("A1").CopyFromRecordset rs
So, excel sheet is populated with the 1st test simpliest query, however remains empty for the more complex part (I have no semicolon in the end :) ) However final sql-script will be 400+ lines long...
What am I missing at this step?
Set rs = .Openinstead ofSet rs = .Execute