Subject | Re: Atomic Execution |
---|---|
Author | Alexander V.Nevsky |
Post date | 2003-09-03T10:08:46Z |
--- In firebird-support@yahoogroups.com, Juan Pedro López Sáez
<jpls@a...> wrote:
constructed from three SQL statements - Select and two Updates.
Secondly, what do you mean "atomic"? SQL statements are atomic in the
sense they are entirely successfull or entirely not. If condition of
update statement cause update of 2 records and updating one server
will encounter exception, no one record will be updated. In this sense
entirely SP execution is atomic too since call is SQL statement - in
case of any exception all changes made by SP will be undone (if there
is not explicit exceptions handling code within this SP). If you mean
- will result of Select is still valid when you perform Update - no,
data can be changed between this statements execution.
Best regards,
Alexander.
<jpls@a...> wrote:
> Hello all,nothing to
>
> Is this SQL statement atomically executed?
>
> IF (EXISTS (SELECT C_STATE
> FROM SETUP_PUSH_PROMOTION
> WHERE ((K_PROMOTION =:PROMOTION)
> AND (C_STATE = 'PENDIENTE'))
> )
> )
> THEN UPDATE PROMOTIONS SET C_STATE = 'ACTIVO'
> WHERE K_PROMOTION = :PROMOTION;
> ELSE UPDATE PROMOTIONS SET C_STATE = 'INACTIVO'
> WHERE K_PROMOTION = :PROMOTION;
>
> It will be part of a Stored Procedure, but I suppose this has
> do with atomic execution.Juan, firstly this is not SQL statement but PSQL statement
>
> Is there any rule to know whether a SQL statement is atomic or not?
>
constructed from three SQL statements - Select and two Updates.
Secondly, what do you mean "atomic"? SQL statements are atomic in the
sense they are entirely successfull or entirely not. If condition of
update statement cause update of 2 records and updating one server
will encounter exception, no one record will be updated. In this sense
entirely SP execution is atomic too since call is SQL statement - in
case of any exception all changes made by SP will be undone (if there
is not explicit exceptions handling code within this SP). If you mean
- will result of Select is still valid when you perform Update - no,
data can be changed between this statements execution.
Best regards,
Alexander.