Why No WHERE clause for INSERT statements

From: Maurice Gittens <mainmanmauricio(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Why No WHERE clause for INSERT statements
Date: 2010-08-17 08:32:12
Message-ID: AANLkTimKDDBjAp3FxL4Q=RhJf6LYhQ-ZKF1i=rvs0ark@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

the postgresql 8.4 documentation defines the syntax of the DELETE statement as:

DELETE FROM [ ONLY ] table [ [ AS ] alias ]
[ USING usinglist ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

The syntax includes a where clause allowing qualified declarative
control over what is deleted.

Why would the same not hold for the insert statement?
More specifically; the INSERT statement is currently defined as:

INSERT INTO table [ ( column [, ...] ) ]
{ DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [,
...] | query }
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

Does not symmetry dictate that the definition of the INSERT statement
be similar to:

INSERT INTO table [ ( column [, ...] ) ]
[ USING usinglist ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
{ DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [,
...] | query }
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

This syntax would allow tuples to be inserted only when some condition is true.
What I am missing?

Cheers,
Maurice

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Atul.Goel 2010-08-17 08:53:06 Re: good exception handling archiecutre
Previous Message Philippe Lang 2010-08-17 08:15:37 Re: Non-reentrant plperlu function & concurrent access