调用另一个触发器函数内的自定义函数时出现语法

时间:2017-01-11 09:27:35

标签: postgresql

继续发布更早的帖子:

我的职能:

CREATE OR REPLACE FUNCTION .instrbals(
    str text,
    sub text,
    startpos integer DEFAULT 1,
    occurrence integer DEFAULT 1)
  RETURNS integer AS
$BODY$
declare 
    tail text;
    shift int;
    pos int;
    i int;
begin
    shift:= 0;
    if startpos = 0 or occurrence <= 0 then
        return 0;
    end if;
    if startpos < 0 then
        str:= reverse(str);
        sub:= reverse(sub);
        pos:= -startpos;
    else
        pos:= startpos;
    end if;
    for i in 1..occurrence loop
        shift:= shift+ pos;
        tail:= substr(str, shift);
        pos:= strpos(tail, sub);
        if pos = 0 then
            return 0;
        end if;
    end loop;
    if startpos > 0 then
        return pos+ shift- 1;
    else
        return length(str)- pos- shift+ 1;
    end if;
end $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

我的选择陈述和错误:

select instrbals(;&
217011802;217011802;;
885;;F;F;10/01/2017 13:46:17;5.5100;;mmol/L;;0;;;;,;,1,2+1)

ERROR:  syntax error at or near ";"
LINE 1: select instrbals(;&
                         ^

0 个答案:

没有答案