0
DECLARE @text AS VARCHAR(10) = '//text()'
DECLARE @TSQL VARCHAR(8000)

SET @TSQL = 'select * from openquery(HHOBI,''select rtrim(xmlagg(xmlelement(e,id,'''','''').extract('''''+@text+''''') order by id).GetClobVal(),'''','''') from (select level as id from dual
connect by level)'')'

EXEC(@TSQL)

I get an error:

OLE DB provider "OraOLEDB.Oracle" for linked server "HHOBI" returned message "ORA-00920: invalid relational operator

2
  • 1
    So, what’s the minimal NON DYNAMIC Swl case that reproduces the issue? Commented Jan 26, 2019 at 6:05
  • Your query 'select level as id from dual connect by level' is wrong. What would you like to achieve by it? Also, it seems the 'e' variable in the xmlelement call is undefined. Commented Jan 26, 2019 at 7:30

1 Answer 1

3

Oracle requires a query of the form:

select level as id from dual
connect by <BOOLEAN EXPRESSION HERE>

You have passed an INT to a place where it expects a boolean

Try something like this:

select level as id from dual
connect by level <= 100

If you want oracle to generate you 100 arbitrary rows (a single column counting from 1 to 100)

Obviously I cannot guess as to how many rows you need oracle to create in order to use them to rip your XML doc apart; that's for you to decide and finish off

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.