I am getting error while executing below query in VB (I am using macro to run this query). But in ORACLE, the same query runs file and gives me the expected result. Please note that, "XML_FIELD" is a CLOB Which has XML Data in it. I am trying to extract data from "XML_FIELD" using VB Macro.
Query in SQL: executes fine :
---> select xmltype(XML_FIELD).extract('//XML_TAGNAME/text()').getStringVal() as NEW_COL from TAB_1 where TEST_ID = 123
Error in VB: SQL Execution Error ora-00936 missing expression
Query in VBA:
Sub Extract_CLOB()
Dim SQL As String
Dim OraDynaSet As Object
'Comment: I am using two single quotes (' ' ) to escape the other single quote
SQL = "select xmltype(XML_FIELD).extract(''//XML_TAGNAME/text()'').getStringVal() as NEW_COL from TAB_1 where TEST_ID = 123"
Set OraDynaSet = objDataBase.DBCreateDynaset(SQL, 0&)
End Sub