this is strange, I was writing a function:
IF CURRENT_DATE - v_recom_record.date_appended::date > 28 THEN
IF v_recom_record.current_recommendation = 1 AND
v_recom_record.zacks_rank = 3 THEN
v_rec_rank := 3;
.
.
.
EXCEPTION
WHEN OTHERS THEN
.
.
And when I try and compile id:
zrecdev-# \i daily_recommendation_update.sql
psql:daily_recommendation_update.sql:126: ERROR: syntax error at or near "EXCEPTION"
LINE 61: EXCEPTION
However, if I add a BEGIN between the IF statements:
IF CURRENT_DATE - v_recom_record.date_appended::date > 28 THEN
BEGIN
IF v_recom_record.current_recommendation = 1 AND
v_recom_record.zacks_rank = 3 THEN
v_rec_rank := 3;
Compiles fine.
Does Postgres not allow 2 conditionals like that?
Aucun commentaire:
Enregistrer un commentaire