Re: Using a variable in sql in a function

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Using a variable in sql in a function
Date: 2010-01-07 11:59:18
Message-ID: hi4iam$sn9$2@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

you could possibly do it like this.

FOR o in SELECT distinct(col_id) as id
FROM table1
JOIN table2
ON col_id = t2_t1_id
WHERE
CASE period_type
WHEN 'CURRENT' THEN field1 IS NULL
WHEN 'old' THEN field1 IS NOT NULL

...etc...

END
LOOP

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2010-01-07 12:52:09 Re: Error on Vacuum?
Previous Message Andrew Rose 2010-01-07 11:42:34 Using TCP load-balancers for read-only connections