0

I'm trying to create a function with two text parameters, second one should have a default value "en" (it is a localisation parameter).

CREATE FUNCTION nav.getpathtext_new(path text, locale text DEFAULT "en") RETURNS json AS
$BODY$DECLARE
-- function code here ...
RETURN array_to_json(_toJson);

END$BODY$
LANGUAGE plpgsql VOLATILE NOT LEAKPROOF;

And I'm getting error:

ERROR: column "en" does not exist

LINE 1: ...getpathtext_new(path text, locale text DEFAULT "en") RETU..

                            ^

PostgreSQL version is 9.4. What am I doing wrong?

2
  • 3
    try single qoutes DEFAULT 'en' Commented Feb 22, 2016 at 20:39
  • Oh, silly mistake. Thanks! Could you please post this suggestion as an answer? Commented Feb 22, 2016 at 20:41

1 Answer 1

7

You need to use single quotes ' to specify text values so

CREATE FUNCTION nav.getpathtext_new(path text, locale text DEFAULT "en") RETURNS json AS

becomes

CREATE FUNCTION nav.getpathtext_new(path text, locale text DEFAULT 'en') RETURNS json AS

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.