1

Here is my query:

select XMLSERIALIZE(query_to_xml('select * from foo order by field1, field2 offset 1 limit 2', true, false,'') as character varying)

I receive this error:

ERREUR:  erreur de syntaxe sur ou près de « query_to_xml »
LINE 1: select XMLSERIALIZE(query_to_xml('select * from foo ord...
                        ^

********** Erreur **********

ERREUR: erreur de syntaxe sur ou près de « query_to_xml »
État SQL :42601
Caractère : 21

Translation from french to english :
erreur de syntaxe sur ou près de(...) is equivalent to syntax error near(...)

What am I doing wrong ?

EDIT:
I tried those two syntaxes too with no luck :

select XMLSERIALIZE(DOCUMENT query_to_xml('select * from foo ord
select XMLSERIALIZE(CONTENT query_to_xml('select * from foo ord

Postgresql 8.3

2 Answers 2

5

Here how I solve my problem. I failed to indicate the casting type.

Either syntaxes work:

select XMLSERIALIZE(DOCUMENT query_to_xml('select * from foo order by 1', false, false,'') as text)

select XMLSERIALIZE(DOCUMENT query_to_xml('select * from foo order by 1', false, false,'') as varchar)

Nota: I could replace DOCUMENT with CONTENT and it works like a charm.

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

2 Comments

Then my suggestion was not wrong. You indeed needed the document/content words.
@Clodoaldo Sure but your suggestion at first was just a cut/paste of Postgresql doc and not a specific answer to my initial problem. BTW your suggestion help me greatly for finding what's was wrong in my query. Thanks !
0
select XMLSERIALIZE({ DOCUMENT | CONTENT } query_to_xml(

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.