Re: constants

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: me(at)shanewright(dot)co(dot)uk
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: constants
Date: 2002-02-04 21:12:11
Message-ID: 3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Try a pg function.

http://www.postgresql.org/idocs/index.php?sql-createfunction.html

CREATE FUNCTION one() RETURNS int4
AS 'SELECT 1 AS RESULT'
LANGUAGE 'sql';
SELECT one() AS answer;
answer
--------
1

If you are truly adventurous, you could create a 'constant' table and have
the function take an argument, which is key to the table.

Frank

At 02:00 PM 2/4/02 +0000, Shane Wright wrote:
>Hi
>
>This may be the wrong list to ask this, apologies if so :)
>
>Anyway, is there any way to define constants in PostgreSQL - my app has lots
>of them at the PHP level, but it'd be nice to use them directly in the SQL
>without overly complex query building.
>
>Something like this...
>
>DEFINE CONSTANT MYCONST = 4;
>
>SELECT * FROM mytable WHERE myfield=MYCONST;
>
>
>Thanks
>
>--
>Shane
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

  • constants at 2002-02-04 14:00:03 from Shane Wright

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Shane Wright 2002-02-04 21:31:26 Re: constants
Previous Message Chadwick Rolfs 2002-02-04 19:48:21 Re: constants