Re: [SQL] Select For Update and Left Outer Join

2011-06-15 Thread greg.fenton
On Apr 28, 2:00 am, pate...@patearl.net (Patrick Earl) wrote: > This is a follow-up to an old message by Tom Lane: > >    http://archives.postgresql.org/pgsql-sql/2006-10/msg00080.php > [...] > > select * from Pet > left join Dog on Dog.Id = Pet.Id > left join Cat on Cat.Id = Pet.Id > > Now suppo

[SQL] Select For Update and Left Outer Join

2011-04-27 Thread Patrick Earl
This is a follow-up to an old message by Tom Lane: http://archives.postgresql.org/pgsql-sql/2006-10/msg00080.php In ORMs like NHibernate, there are a few strategies for mapping inheritance to SQL. One of these is "Joined Subclass," which allows for the elimination of duplicate data and clean

Re: [SQL] SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an outer join

2006-10-06 Thread James Robinson
Oh that's sweet and all I needed anyway thanks. On Oct 6, 2006, at 12:25 PM, Tom Lane wrote: Note that you can select "FOR UPDATE OF a" in this situation, it's just the B side that is problematic. James Robinson Socialserve.com ---(end of broadcast)---

Re: [SQL] SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an outer join

2006-10-06 Thread Tom Lane
James Robinson <[EMAIL PROTECTED]> writes: > select a.id, b.id from foo a left outer join bar b on (b.a_id = > a.id) for update; > SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an > outer join > Is this behavior spec-mandated, or could only the rows in B which are >

[SQL] SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an outer join

2006-10-06 Thread James Robinson
Given something like: create table foo (id int primary key not null); create table bar (id int primary key not null, a_id int references foo(id)); select a.id, b.id from foo a left outer join bar b on (b.a_id = a.id) for update; PG 8.1.4 balks, saying: SELECT FOR UPDATE/SHARE can

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-07 Thread D'Arcy J.M. Cain
On December 6, 2002 02:10 pm, Bruce Momjian wrote: > It should lock only the rows you retrieved, but I have no idea how FOR > UPDATE and INTO TEMP behave. My guess is that it should work fine, but > I have never seen those two used together before. Turns out that it wasn't the SELECT ... FOR UPDA

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread Tom Lane
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > We have the following query: > SELECT certificate_id > INTO TEMP TABLE x_certs > FROM certificate > WHERE cert_status = 0 AND > certificate_id BETWEEN AND AND > client_id IN (1, 2, 3) > ORDER BY certificate_i

Re: [SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread Bruce Momjian
It should lock only the rows you retrieved, but I have no idea how FOR UPDATE and INTO TEMP behave. My guess is that it should work fine, but I have never seen those two used together before. --- D'Arcy J.M. Cain wrote: > W

[SQL] SELECT FOR UPDATE locks whole table

2002-12-06 Thread D'Arcy J.M. Cain
We have the following query: SELECT certificate_id INTO TEMP TABLE x_certs FROM certificate WHERE cert_status = 0 AND certificate_id BETWEEN AND AND client_id IN (1, 2, 3) ORDER BY certificate_id FOR UPDATE; Is there any reason that this query should

Re: [SQL] select for update

2002-11-26 Thread Stephan Szabo
On Wed, 20 Nov 2002, Justin Georgeson wrote: > I'm pretty new to databases in general, and would like to find a spiffy > way to do something. I want to use two columns from one table to > populate three columns in two other tables. Assuming t1 is the table I > want to take the values from, here is

[SQL] select for update

2002-11-26 Thread Justin Georgeson
I'm pretty new to databases in general, and would like to find a spiffy way to do something. I want to use two columns from one table to populate three columns in two other tables. Assuming t1 is the table I want to take the values from, here is the structure of what I want to insert into t2 an

[SQL] SELECT FOR UPDATE CLAUSE

2001-10-10 Thread Gerardo Perosio
Hi all. I have a problem with an application written in php. I need to lock a record for update, and I use the following transaction: BEGIN WORK; //row1 is an indexed field SELECT row1, row2 from table1 where row3 = NULL order by row1 FOR UPDATE limit 1; //fetch row1 in $myvar UPDATE table1 set

Re: [SQL] select ... for update in plpgsql

2001-04-24 Thread Cedar Cox
'select ... for update' needs to be inside a transaction. plpgsql cannot start or end transactions. 'begin' and 'end' are not transaction statements. (read the docs). -Cedar On Fri, 20 Apr 2001, Jie Liang wrote: > > Hi, > > I have a question about 'select ... for update'; > according to t

[SQL] SELECT ... FOR UPDATE

2001-04-05 Thread Loïc Bourgeois
I have to create a program to use the lastest version of PostgreSQL. Many processes of this program must run in parallele. In a table I have to select some specific row next insert a new row with the same search carateristiques and commit. But between the select and the insert action none other

Re: [SQL] SELECT ... FOR UPDATE

2001-03-29 Thread Cedar Cox
On Wed, 28 Mar 2001, Marcos Minshew wrote: > I am interested in using the SELECT ... FOR UPDATE feature but it doesn't > work quite the way I had hoped. If there is a better/different way of doing > this please enlighten me. > > If I issue: > > BEGIN; > SELECT * FROM atable WHERE atable.key

[SQL] SELECT ... FOR UPDATE

2001-03-28 Thread Marcos Minshew
I am interested in using the SELECT ... FOR UPDATE feature but it doesn't work quite the way I had hoped. If there is a better/different way of doing this please enlighten me. If I issue: BEGIN; SELECT * FROM atable WHERE atable.key = 10 FOR UPDDATE; in one session and then issue the same comm

Re: [SQL] select ... for update

2000-12-13 Thread Karel Zak
> > Hi, > > How can I use select ... for update to update limit to update what I > select?? First thing - the SELECT FOR UPDATE is not merge of SELECT and UPDATE but transaction option. The PostgreSQL use row-locking for UPDATEed rows. Standard SELECT ignore this lock, but SELECT FOR UPDATE wa

[SQL] select ... for update

2000-12-12 Thread Jie Liang
> Hi, How can I use select ... for update to update limit to update what I select?? somewhat like: select url,id from mytable for update order by priority,id limit 5; I want update the id in above return like: update mytable set allocatedto='whatever' where id in above return set. Could I do it i