Search Postgresql Archives

Re: Parameter for query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 17, 2013 at 6:25 AM, Robert James <srobertjames@xxxxxxxxx> wrote:
> Is there any way to set a variable or parameter for a query?
>
> I have a long query where a certain variable needs to be easy to
> change.  I'd like to do something like:
>
> threshold = 10.3
>
> SELECT... WHERE x > $threshold... AND y * 1.3 > $threshold...
>

Using prepared statements? See here:
http://www.postgresql.org/docs/9.2/static/sql-prepare.html


> Currently, I need to do this in a scripting language.  Is there a
> straightforward way to do this directly in Postgres?

well, if you are doing this in a script(ing) it should be quite easy
to do string interpolation.

Luca


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux