[GENERAL] Using Variables in Queries - Mailing list pgsql-general

From Igal @ Lucee.org
Subject [GENERAL] Using Variables in Queries
Date
Msg-id da409c77-2b07-c89b-3378-e74e09793aa5@lucee.org
Whole thread Raw
Responses Re: [GENERAL] Using Variables in Queries  (Scott Mead <scottm@openscg.com>)
Re: [GENERAL] Using Variables in Queries  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: [GENERAL] Using Variables in Queries  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general

Hello,

In other database servers, which I'm finally dropping in favor of Postgres, I can do the following (mind you that this is for illustration only, I do not actually write queries like that):

DECLARE @query varchar(64) = 'red widget';

SELECT *
FROM products
WHERE col1 LIKE @query
   OR col2 LIKE @query
   OR col3 LIKE @query
   OR col4 LIKE @query
   OR col5 LIKE @query

The point is, though, that I can change the @query variable in one place which is very convenient.

Is it still true (the posts I see on this subject are quite old) that I can not do so in Postgres outside of a stored procedure/function?  And if so, what's the reason of not adding this feature?  Seems very useful to me.

Thanks,


Igal Sapir
Lucee Core Developer
Lucee.org

pgsql-general by date:

Previous
From: STERBECQ Didier
Date:
Subject: Re: [GENERAL] Table partionning : INSERT with inconsistent returnligne inserted.
Next
From: Scott Mead
Date:
Subject: Re: [GENERAL] Using Variables in Queries