Skip site navigation (1) Skip section navigation (2)

plpgsql and control structures

From: Nick Boutelier <nboutelier(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql and control structures
Date: 2009-01-30 22:08:19
Message-ID: 7827ee3c-d51d-4858-abc1-eb4b36025aed@y23g2000pre.googlegroups.com (view raw or flat)
Thread:
Lists: pgsql-general
I noticed that if I use...

IF (TG_OP = 'DELETE' AND OLD.myColumn) THEN
  -- Do something
END IF;

when an insert happens, I get an error that 'OLD' has not been
assigned. I would of thought that the control structure would just
ignored the rest of the 'if' statement if the first part (TG_OP) was
false.

Does this mean I have to branch out my control structures if I want
better speed? If the first part of the 'if' is rarely true, then I
might as well put the second control within the first.

-Nick

Responses

pgsql-general by date

Next:From: Scott MarloweDate: 2009-01-30 22:23:01
Subject: Re: PGSQL or other DB?
Previous:From: Steve CrawfordDate: 2009-01-30 22:07:42
Subject: Re: PGSQL or other DB?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group