创建postgresql函数时出错 [英] Error while creating postgresql function
本文介绍了创建postgresql函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建 postgresql 函数,但它出现以下错误:
I am trying to create a postgresql function but it is giving the following error:
ERROR: syntax error at or near ";"
LINE 16: end;
^
********** Error **********
ERROR: syntax error at or near ";"
SQL state: 42601
Character: 308
我尝试过:
What I have tried:
create or replace function prcUDF(p_col1 integer,p_col2 text,p_col3 text)
returns void LANGUAGE 'plpgsql' as
$$
begin
if(p_col2='1')
then
UPDATE tblA set COLUMN12=p_col3 WHERE COLUMN0=p_col1;
ELSE IF (p_col2='2')
then
UPDATE tblI set COLUMN11=p_col3 WHERE COLUMN0=p_col1;
end if;
end;
$$
推荐答案
开始
if(p_col2 ='1')
然后
UPDATE tblA set COLUMN12 = p_col3 WHERE COLUMN0 = p_col1;
ELSE IF(p_col2 ='2')
然后
UPDATE tblI set COLUMN11 = p_col3 WHERE COLUMN0 = p_col1;
结束如果;
end;
begin if(p_col2='1') then UPDATE tblA set COLUMN12=p_col3 WHERE COLUMN0=p_col1; ELSE IF (p_col2='2') then UPDATE tblI set COLUMN11=p_col3 WHERE COLUMN0=p_col1; end if; end;
else if似乎有问题,我认为它需要看起来像这样:
There seems to be a problem with "else if", I think it needs to look like this:
CREATE FUNCTION public.test1(IN p_col1 integer, IN p_col2 text, IN p_col3 text) RETURNS void AS
这篇关于创建postgresql函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文