From: | "Kevin Field" <kev(at)brantaero(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: boolean short-circuiting in plpgsql |
Date: | 2008-07-31 12:52:02 |
Message-ID: | 2447358484-BeMail@CPE0040caab50b8-CM001a66710216 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Kev <kevinjamesfield(at)gmail(dot)com> writes:
> > ...because the case should force it to only evaluate 'old' when
> > TG_OP
> > = 'UPDATE' and otherwise ('INSERT') skip through to 't'. But this
> > causes the same error on insert. I suspect it's because the select
> > query gets parameterized and at that point the 'old' is missing,
> > before the case even gets to be parsed.
>
> Got it in one.
Thanks. Shouldn't there be some way around this then?
> > How do I get around this
> > without having two 'perform' statements?
>
> What you need is two nested IF statements. The PERFORM in your
> example
> is not relevant to the problem.
>
> regards, tom lane
Well, sure, in one sense, but I am actually trying to make it look
neater. Unless I'm missing something (quite possible...) the two
nested IF statements end up having two PERFORM statements:
if TG_OP = 'INSERT' then
perform recalc_sortnumpath(new.id);
else
if (new.sortnum != old.sortnum or new.parent != old.parent) then
perform recalc_sortnumpath(new.id);
end if;
end if;
...is there some way to boil this down using nested IF statements that
only has one PERFORM? (I mean, besides inverting it and having three
return statements and one perform.)
Thanks,
Kev
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Richardson | 2008-07-31 12:57:58 | Re: How do I specify intervals in functions? |
Previous Message | Volkan YAZICI | 2008-07-31 12:51:47 | Re: How do I specify intervals in functions? |