Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Edson Richter
ld the actions of both stored procedures would be a single atomic action? Thanks again for lending me your experience, it can, and is, saving me days. Evan. From: Bill Moran [wmo...@potentialtech.com] Sent: Saturday, June 09, 2012 4:35 PM To: Evan Rempe

Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Chris Travers
Depending on the version of Pg there are two possible solutions to this problem. The first (old solution) that really only works well one row at a time is to do a stored procedure that does something like: update foo set bar = baz where id = in_id if not found insert into foo (bar) values (ba

Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Evan Rempel
again for lending me your experience, it can, and is, saving me days. Evan. From: Bill Moran [wmo...@potentialtech.com] Sent: Saturday, June 09, 2012 4:35 PM To: Evan Rempel Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] is there a select for update insert if not exist type command? On S

Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread David Johnston
> -Original Message- > > Both clients A and B becomes aware to do a task > Ideally you would have this aware-ness manifested as an INSERT into some kind of job table. The clients can issue the "SELECT FOR UPDATE" + "UPDATE" commands to indicate that they are going to be responsible for

Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Edson Richter
You will find this reading a good start point: http://www.cs.uiuc.edu/class/fa07/cs411/lectures/cs411-f07-tranmgr-3.pdf There are no "fit all needs" cookbook about this, you will have to learn the theory about transactional database transaction management and locking mechanism and work on your

Re: [GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Bill Moran
On Sat, 9 Jun 2012 15:41:34 -0700 Evan Rempel wrote: > I have a project where I will have two clients essentially doing the > same things at the same time. The idea is that if one has already done the > work, then the second one does not need to do it. > > I was hoping that adding a task related

[GENERAL] is there a select for update insert if not exist type command?

2012-06-09 Thread Evan Rempel
I have a project where I will have two clients essentially doing the same things at the same time. The idea is that if one has already done the work, then the second one does not need to do it. I was hoping that adding a task related unique identifier to a table could be used to coordinate these c