Re: Transactions - working but unsure about steps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you are adding a conditonal /validaton
statement as the constraint ? More then x characters
will generate an error.
My understaning is an error in mysql transaction will
rollback should rollback the entire set of
transactions.  
error handling for each statement- values will be
coming from user input into form, my validations will
be in the form.
I've also thought about checking for effected rows and
then if == 0 , stopping the transaction, but that
seems redundant to what I believe is the way mysql
transactions should work.

Stuart

--- Martín Marqués <martin@xxxxxxxxxxxxxxx> wrote:


> prueba=> create table tab1 (
> prueba(> cod SERIAL PRIMARY KEY,
> prueba(> first INT CHECK (first < 0),
> prueba(> names varchar(25)
> prueba(> );
> CREATE TABLE
> prueba=> begin;
> BEGIN
> prueba=> insert into tab1 values
> (default,10,'Martín');
> ERROR:  new row for relation "tab1" violates check
> constraint "tab1_first"
> prueba=> insert into tab1 values
> (default,-8,'José');
> ERROR:  current transaction is aborted, commands
> ignored until end of 
> transaction block
> prueba=> end;
> COMMIT
> prueba=> select * from tab1;
>  cod | first | names
> -----+-------+-------
> (0 filas)
> 
> Now, as you see, because the CHECK constraint was
> violated in the first 
> INSERT, ever other comand that would modify the
> table would be ignored until 
> the transaction is over.
> 
> This is the way a transactional database works
> (Oracle, Informix, Sybase, 
> etc.) As I already stated, I don't work with MySQL
> so I don't know how it 
> works with transactions. Maybe you should try to
> execute the same sentences I 
> did in the mysql shell (does MySQL have CHECK
> constraints? If not just try 
> putting a string larger then 25 chars in the names
> field) to see what 
> happens.
> 
> Good luck.
> 
> -- 
>  10:55:02 up 34 days,  1:13,  2 users,  load
> average: 0.36, 0.26, 0.19
>
-----------------------------------------------------------------
> Martín Marqués        | select 'mmarques' || '@' ||
> 'unl.edu.ar'
> Centro de Telematica  |  DBA, Programador,
> Administrador
>              Universidad Nacional
>                   del Litoral
>
-----------------------------------------------------------------
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux