Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unexpected end of function definition on PostgreSQL function

Tags:

postgresql

What is wrong with this function? EDITED>>

CREATE OR REPLACE FUNCTION on_ai_myTable() RETURNS TRIGGER AS $$

BEGIN
SELECT fn_name, count(*) + 1 FROM table_ebscb_spa_log02 WHERE time_type = 'Start' GROUP BY fn_name
RETURN NEW.fn_name;
END
$$
LANGUAGE plpgsql;

Ok I added the ";" but now, when I try to create it, it send me the message ERROR: syntax error at or near "RETURN" LINE 5: RETURN fn_name;

How can I solve it????

Thanks Advanced.

like image 967
Natysiu16 Avatar asked Jun 20 '15 18:06

Natysiu16


1 Answers

You just need to add semicolons:

CREATE OR REPLACE FUNCTION on_ai_myTable() RETURNS TRIGGER AS $$

BEGIN
SELECT fn_name, count(*) + 1 FROM table_ebscb_spa_log02 WHERE time_type = 'Start' GROUP BY fn_name;
RETURN NEW.fn_name;
END
$$
LANGUAGE plpgsql;
like image 69
user_0 Avatar answered Sep 18 '22 07:09

user_0