Re: [GENERAL] Using Variables in Queries
От | David G. Johnston |
---|---|
Тема | Re: [GENERAL] Using Variables in Queries |
Дата | |
Msg-id | CAKFQuwbTrD-xN2pX7DamDAbCWqxGjobrZQAStAZr7D4NrezByA@mail.gmail.com обсуждение исходный текст |
Ответ на | [GENERAL] Using Variables in Queries ("Igal @ Lucee.org" <igal@lucee.org>) |
Ответы |
Re: [GENERAL] Using Variables in Queries
|
Список | pgsql-general |
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.
<not positive on syntax but the concept should be sound>
PREPARE sqlquery AS SELECT * FROM products WHERE col1 LIKE $1 OR col2 LIKE $1;
EXECUTE sqlquery('red widget');
Alban's DO blocks are problematic since they are incapable of generating a result set.
As Scott said people needing this functionality in PostgreSQL are content with using psql.
Adding lots of new custom syntax to pure server-side parsed SQL is a non-trivial undertaking whose need is reduced by the alternatives so described (functions, DO block, PREPARE, psql).
David J.
В списке pgsql-general по дате отправления: