2013-07-09 79 views
0

我已经写含有像一个while语句一个PostgreSQL功能:验证一个布尔条件的函数内部

WHILE id_exist == 'f' LOOP 
    lotto_id = lotto_id + 1; 
    id_exist = check_if_exist(lotto_id, 'lotto', 'id'); 
END LOOP; 

id_exist是通过调用check_if_exist()方法初始化的布尔变量(也用于内部,而代码),该返回的布尔值。

现在,当我尝试打电话给我的功能,我得到这个错误

ERROR: operator does not exist: boolean == unknown 
LINE 1: SELECT id_exist == 'f' 
        ^
HINT: No operator matches the given name and argument type(s). You might need to add 
explicit type casts. 
QUERY: SELECT id_exist == 'f' 
CONTEXT: PL/pgSQL function "acquistolotto" line 11 at WHILE 

回答

1

比较运算符是一个等号(“=”,而不是“==”)

而且,做您在进入循环之前将值设置为id_exist?

+0

好的,没错。但是现在我有一个无限循环问题。我会打开另一个问题。谢谢 当然,我已经设置该值调用check_if_exist()函数,而 – giozh

+0

如果是这样的话,它看起来像你的check_if_exist()函数总是返回“false”。先看看那个。 – Curt