语法误差接近或接近; [英] Syntax error at or near ;

查看:117
本文介绍了语法误差接近或接近;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多触发功能,对于某些错误,有一个奇怪的错误:"Syntax error at or near ;"这是我的代码:

I have many trigger functions, and for some there is a strange error: "Syntax error at or near ;" Here is my code:

CREATE OR REPLACE FUNCTION zajisti_vyplnenost() RETURNS trigger AS $$
BEGIN
  IF NEW.typ_vztahu != 1 THEN
    RETURN NEW;
  END IF;

  IF NEW.nad.typ_sj = 1 THEN
    IF NEW.nad.vrstva.vypln = true THEN
    ELSE
      RAISE EXCEPTION 'Totožné stratigrafické jednotky musejí být stejného typu!';
  END IF;

  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER zajisti_vyplnenost
BEFORE INSERT OR UPDATE ON s_vztah
FOR EACH ROW
  EXECUTE PROCEDURE zajisti_vyplnenost();

根据调试器,错误应该在第14行(带有END;).我试图找到可能导致问题的原因,但此功能看起来像其他不会触发任何错误的功能.我查看了一些有关plpgsql中的函数和END语法的文档,但并不高兴,分号使该错误对Google完全不友好.

According to the debugger, the error should be on line 14 (with END;). I tried to find something which might cause the problem, but this function looks like the others which don't trigger any errors. I looked on some documentation for function and END syntax in plpgsql, but with no joy, and semicolon makes the error quite Google unfriendly.

那么我的语法的哪一部分是错误的,以及如何纠正?

So which part of my syntax is wrong, and how to correct it?

推荐答案

好像您忘记了一个END IF:

IF NEW.nad.typ_sj = 1 THEN
  IF NEW.nad.vrstva.vypln = true THEN
  ELSE
    RAISE EXCEPTION 'Totožné stratigrafické jednotky musejí být stejného typu!';
  END IF;
END IF;

应该是正确的

这篇关于语法误差接近或接近;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆