0

I am working on postgresql function where i want to return a xml.

 CREATE OR REPLACE FUNCTION schema.func_name(
    ws_queue_array character varying DEFAULT NULL::character(1),
    OUT ws_out_xml_data xml)
          RETURNS xml

I am creating an xml using xml function in postgreql but I am not sure how will I return that xml.

SELECT  XMLELEMENT (NAME "name",                 
                   XMLAGG (XMLELEMENT(NAME "var1",                           
                             XMLATTRIBUTES (                                    
                          c_name        AS "c name",                         
                          c_id  AS "c ID"))                         
                     ORDER BY c_id ASC))              
                        INTO OUT_XML_DATA;

How do i return this OUT_XML_DATA?

1
  • 1
    Can you post the whole function? I guess you're just missing just the RETURN OUT_XML_DATA command in the end of your function. Commented Feb 16, 2018 at 14:57

1 Answer 1

2
CREATE OR REPLACE FUNCTION my_function() RETURNS XML AS $BODY$
DECLARE output XML;
BEGIN 
SELECT '<foo bar="xyz"><abc/><!--test--><xyz/></foo>'::XML INTO output;
RETURN output;
END;
$BODY$
  LANGUAGE plpgsql;

SELECT my_function();
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.