0

Consider I have a function like (but the following does not work):

CREATE FUNCTION func(VARIADIC params character varying[]) 
RETURNS type1 AS
$BODY$
   SELECT * FROM func2('id', array_to_string($1,'###’)
$BODY$
LANGUAGE sql VOLATILE;

The signature of func2 is:

 func2(character varying, character varying)

Thus, what I am trying to do is convert the array from “func” into a long string that is delimited by say the characters “###”. I then want to pass the entire string as the second argument of func2.

7
  • What error do you get; or if no error, how does it "not work"?
    – araqnid
    Feb 7, 2012 at 15:40
  • The above just gives me a syntax error...
    – Larry
    Feb 7, 2012 at 15:52
  • 1
    You're missing a close-bracket and the single quote after '###' is a non-standard character rather than a regular quote.
    – araqnid
    Feb 7, 2012 at 15:56
  • Thanks so much... actually the problem was just the missing bracket. The quote is just when copy-pasting to stackoverflow editor.
    – Larry
    Feb 7, 2012 at 16:05
  • BTW, the VARIADIC keyword does not make sense in your example. If there isn't more to it, just drop it. Feb 8, 2012 at 11:18

1 Answer 1

1

Just to make clear, the answer to the above question is as follows:

CREATE FUNCTION func(VARIADIC params character varying[]) 
RETURNS type1 AS
$BODY$
   SELECT * FROM func2('id', array_to_string($1,'###’))
$BODY$
LANGUAGE sql VOLATILE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.