Home:ALL Converter>PostgreSQL stynax error creating function

PostgreSQL stynax error creating function

Ask Time:2014-07-18T16:39:09         Author:Jacob

Json Formatter

I am creating a function in my PostgreSQL but I'm getting this syntax error and I ran out of ideas what could be wrong... Please assist.

CREATE OR REPLACE FUNCTION get_docName(IN p_docId_id bigint) 
RETURNS TABLE(name varchar) AS
$BODY$

begin
RETURN query SELECT name * FROM (documents) where id=p_docId
end;
$BODY$
LANGUAGE sql STABLE;
ALTER FUNCTION public.get_documents(IN bigint)
  OWNER TO postgres;

Errors:

ERROR:  SyntaxError at „RETURN“
LINE 8: RETURN query SELECT * FROM (
        ^
********** Error **********

ERROR: SyntaxError at „RETURN“
SQL state: 42601
Character: 173

Author:Jacob,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24820702/postgresql-stynax-error-creating-function
yy