Received: from smtp-relay.noc.dsvr.net (smtp-relay.noc.dsvr.net [212.69.192.4]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g14LYEl35221 for ; Mon, 4 Feb 2002 16:34:14 -0500 (EST) (envelope-from me@shanewright.co.uk) Received: from [212.69.206.2] (helo=fullerruss.dsvr.co.uk) by smtp-relay.noc.dsvr.net with esmtp (Exim 3.16 #1) id 16Xqkh-000N33-00 for pgsql-php@postgresql.org; Mon, 04 Feb 2002 21:34:15 +0000 Received: from there (fuller-230.adsl.newnet.co.uk [213.131.184.230]) by fullerruss.dsvr.co.uk (8.11.3/8.11.1) with SMTP id g14LYFh23008 for ; Mon, 4 Feb 2002 21:34:15 GMT Message-Id: <200202042134.g14LYFh23008@fullerruss.dsvr.co.uk> Content-Type: text/plain; charset="iso-8859-1" From: Shane Wright Reply-To: me@shanewright.co.uk To: pgsql-php@postgresql.org Subject: Re: constants Date: Mon, 4 Feb 2002 21:33:53 +0000 X-Mailer: KMail [version 1.3.2] References: <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca> In-Reply-To: <3.0.6.32.20020204161211.02c1b8d0@pop6.sympatico.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archive-Number: 200202/17 X-Sequence-Number: 923 Hi Frank, Thanks, interesting idea - it looks like it would work fine, but wouldn't it be a little on the slow side? I like the constant table idea (hmm, could automatically populate the constant table by parsing my PHP definitions files, tasty...) - but again speed is of the essence... -- Shane On Monday 04 Feb 2002 9:12 pm, Frank Bax wrote: > 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