1

I have just started using postgres and am new to the whole thing, I am using postgres version 9.6 and am trying to create a new function however I keep getting the error

ERROR: syntax error at or near "CREATE"
LINE 6: CREATE OR REPLACE FUNCTION time_passed(created text)

my function is this

CREATE OR REPLACE FUNCTION time_passed(created text)
 RETURNS text AS 
BEGIN
created :='Now';
RETURN created;
END;
$$ LANGUAGE plpgsql

What could be wrong with the Create syntax?

Mureinik
316k54 gold badges404 silver badges406 bronze badges
asked Dec 21, 2016 at 21:02

1 Answer 1

2

You're missing the opening $$ to match the closing ones:

CREATE OR REPLACE FUNCTION time_passed(created text)
RETURNS text AS $$
-- Here --------^
BEGIN
 created :='Now';
 RETURN created;
END;
$$ LANGUAGE plpgsql
answered Dec 21, 2016 at 21:05
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.