2013-07-09 80 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