Re: Is this legal SQL? Is it a good practice?

Поиск
Список
Период
Сортировка
От Bill Harper
Тема Re: Is this legal SQL? Is it a good practice?
Дата
Msg-id 412BBE5C.6080404@solutionst.com
обсуждение исходный текст
Ответ на Is this legal SQL? Is it a good practice?  (Carlos Moreno <moreno@mochima.com>)
Ответы Re: Is this legal SQL? Is it a good practice?  (Carlos Moreno <moreno@mochima.com>)
Список pgsql-general
Carlos Moreno wrote:

> But I'm wondering -- is this a PostgreSQL extension,
> or is it "legal SQL"?

This is a reasonably standard result from an "exec" or "execute" call,
but I am not an SQL expert.  How else could the psql command
line utility process command files?

> What happens if the first command is ok but the second
> one fails?

I've not used this interface extensively because I do
mostly transactional work. The easy way to test would be to
make the second statement fail on a syntax error.

> Any reason why this should be avoided?

Yes. You've raised the core issue in your question about what happens
when a command fails.  For efficiency and convenience, use prepared
statements.
For greater efficiency, execute stored procedures to do your work

In general, my web applications use prepared statements for moderate
efficiency.
For batch applications, I would use stored procedures or embedded SQL (both
provide the advantage of stored, optimized query plans).

-bill

В списке pgsql-general по дате отправления:

Предыдущее
От: "Gavin M. Roy"
Дата:
Сообщение: Re: Gentoo for production DB server?
Следующее
От: Greg Stark
Дата:
Сообщение: Deadlocks caused by referential integrity checks