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"? Commented Feb 7, 2012 at 15:40
  • The above just gives me a syntax error... Commented 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. Commented 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. Commented 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. Commented Feb 8, 2012 at 11:18

1 Answer 1

2

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;
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.