Re: Using a variable in sql in a function - Mailing list pgsql-novice

From Jasen Betts
Subject Re: Using a variable in sql in a function
Date
Msg-id hi4iam$sn9$2@reversiblemaps.ath.cx
Whole thread Raw
In response to Using a variable in sql in a function  (Peter Jackson <mltasmaniac@tasjackson.com>)
List 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


pgsql-novice by date:

Previous
From: Andrew Rose
Date:
Subject: Using TCP load-balancers for read-only connections
Next
From: Tom Lane
Date:
Subject: Re: Error on Vacuum?