Re: User-Defined Variables

From: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: User-Defined Variables
Date: 2008-07-10 09:08:46
Message-ID: 200807101108.46358.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 10. July 2008, Daniel Futerman wrote:
>Hi,
>
>Is there a quick solution to implementing user-defined variables in
>PostgreSQL as they are used in MySQL?
>
>I have the following MySQL script which i want to implement in
> Postgres (NOTE : all ` have been changed to " for Postgres use):
>
>SET @OTHER_CONCEPT_ID = (SELECT "concept_id" FROM "concept_name" where
> name = 'MRO' LIMIT 1);

You should probably think about using a function instead, like eg:

CREATE OR REPLACE
FUNCTION other_concept_id(INTEGER) RETURNS INTEGER AS $$
SELECT concept_id FROM concept_name where name = 'MRO' LIMIT 1;
$$ LANGUAGE sql STABLE;

hth,
--
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/
My Jazz Jukebox: http://www.last.fm/user/leifbk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2008-07-10 09:40:40 functional index not used, looping simpler query just faster
Previous Message Pavel Stehule 2008-07-10 08:49:53 Re: User-Defined Variables