Re: Declaring constants in SQL

From: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Declaring constants in SQL
Date: 2008-08-01 04:06:00
Message-ID: e7522359-ba65-4a12-b9ff-027f5a5c0768@c65g2000hsa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The last part got scrambled, should read like this:

(...)
Use it like this:
SELECT * FROM foo WHERE foo_id > myval();

Or, for the case at hand, an example in sql:

CREATE FUNCTION my_colors()
RETURNS text[] AS
$$ SELECT ARRAY['red','green','blue'] $$
LANGUAGE 'sql' IMMUTABLE;

Use it like this:
SELECT * FROM foo WHERE color = ANY(my_colors());

Regards
Erwin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2008-08-01 07:12:13 Re: eliminating records not in (select id ... so SLOW?
Previous Message Erwin Brandstetter 2008-08-01 04:00:04 Re: Declaring constants in SQL