Skip site navigation (1) Skip section navigation (2)

(Fwd)

From: suspect(dot)files(at)anr(dot)state(dot)vt(dot)us
To: pgsql-general(at)postgresql(dot)org
Subject: (Fwd)
Date: 2004-06-25 18:13:55
Message-ID: 40DC3323.19193.D2D488@localhost (view raw or flat)
Thread:
Lists: pgsql-general
------- Forwarded message follows -------
Date sent:      	25 Jun 2004 11:41:22 +0200
From:           	Ago <ago(at)nmb(dot)it>
To:             	<pgsql-general(at)postgresql(dot)org>
Send reply to:  	Ago <ago(at)nmb(dot)it>
Subject:        	[GENERAL]

I have a PHP script that runs this query on Postgresql 7.2.3. Once it
inserts the record in the e_catalog table it takes the id value and
then inserts it in the e_catalog_cache table, the two tables must 
have
the same rows and values.
 I thought rhat inside a transaction block the subquery SELECT 
MAX(id)
 FROM e_catalog was safe from concurrent same transactions, that 
is
 the id value from SELECT MAX(id) FROM e_catalog was exactly 
that one
 inserted in the previous statement, but reading some threads in this
 mailing list I have some doubt now. 
This is the query:

BEGIN WORK;
 INSERT INTO e_catalog(id, name, descr) VALUES 
(nextval('sequence'),
 '$Name', '$Descr');

 INSERT INTO e_catalog_cache(id, name, descr) VALUES 
((SELECT MAX(id)
 FROM e_catalog), '$Name', '$Descr');

COMMIT WORK;

Thanks.



---------------------------(end of
broadcast)--------------------------- TIP 2: you can get off all lists
at once with the unregister command
    (send "unregister YourEmailAddressHere" to
    majordomo(at)postgresql(dot)org)

------- End of forwarded message -------

Attachment: -
Description: application/octet-stream (1.0 KB)

pgsql-general by date

Next:From: A.N.OtherDate: 2004-06-26 04:06:19
Subject: postgresql web site gone missing!!!
Previous:From: Kris JurkaDate: 2004-06-25 18:13:46
Subject: Re: Query inside transaction

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group