Skip site navigation (1) Skip section navigation (2)

Re: constants

From: Shane Wright <me(at)shanewright(dot)co(dot)uk>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: constants
Date: 2002-02-04 21:33:53
Message-ID: 200202042134.g14LYFh23008@fullerruss.dsvr.co.uk (view raw or flat)
Thread:
Lists: pgsql-php
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(at)postgresql(dot)org

In response to

Responses

pgsql-php by date

Next:From: Frank BaxDate: 2002-02-05 03:23:45
Subject: Re: constants
Previous:From: Shane WrightDate: 2002-02-04 21:31:26
Subject: Re: constants

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group