pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Bax <fbax@sympatico.ca>
To: me@shanewright.co.uk
Cc: pgsql-php@postgresql.org
Subject: Re: constants
Date: Mon, 04 Feb 2002 16:12:11 -0500
Message-ID: <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca> (raw)
In-Reply-To: <200202041400.g14E0oA11034@fullerruss.dsvr.co.uk>

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@postgresql.org
>



view thread (7+ messages)  latest in thread

Message-ID: <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca>
Permalink:  ../3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca/
Also on:    postgresql.org/message-id/3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: fbax@sympatico.ca, me@shanewright.co.uk
  Subject: Re: constants
  In-Reply-To: <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca>
  References: <200202041400.g14E0oA11034@fullerruss.dsvr.co.uk> <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox