What is wrong with the below PostgreSql insert function.. throwing error
I have written a function in PostgreSQL which accepts two parameters viz varchar and int . The ai开发者_运维问答m is to insert record
CREATE OR REPLACE FUNCTION fnInsert(varchar,int) RETURNS void AS
'BEGIN
Insert Into testtable(col1,col2) values ($1,$2)
RETURN;
END;'
LANGUAGE plpgsql;
But while trying to compile it is throwing error
ERROR: syntax error at or near "RETURN"
LINE 4: RETURN;
^
********** Error **********
ERROR: syntax error at or near "RETURN"
SQL state: 42601
Character: 173
If I take out the RETURN statement, I am getting the below error
ERROR: syntax error at or near "END"
LINE 4: END;'
^
********** Error **********
ERROR: syntax error at or near "END"
SQL state: 42601
Character: 173
Please help me in identifying what is wrong here?
Thanks
It's probably complaining about the lack of semicolon after
Insert Into testtable(col1,col2) values ($1,$2)
精彩评论