Re: [SQL] atomic multi-threaded upsert

2010-11-24 Thread MIkhail Puzanov
2010/11/25 KM > On 2010-11-24, "Mikhail V. Puzanov" wrote: > > Next, I execute the following two queries for that table: > > > >-- increment and get the counter if exists > > UPDATE sequences SET counter = counter + 1 > > WHERE section = 'testSection' AND name = 'testKey' > > RETURNING

Re: [SQL] atomic multi-threaded upsert

2010-11-24 Thread MIkhail Puzanov
2010/11/25 Tom Lane > "Mikhail V. Puzanov" writes: > >-- increment and get the counter if exists > > UPDATE sequences SET counter = counter + 1 > > WHERE section = 'testSection' AND name = 'testKey' > > RETURNING counter; > > Seems that what you have here is a bad manual implementation

Re: [SQL] atomic multi-threaded upsert

2010-11-24 Thread KM
On 2010-11-24, "Mikhail V. Puzanov" wrote: > Next, I execute the following two queries for that table: > >-- increment and get the counter if exists > UPDATE sequences SET counter = counter + 1 > WHERE section = 'testSection' AND name = 'testKey' > RETURNING counter; > >-- insert new

[SQL] How strings are sorted by LC_COLLATE specifically?

2010-11-24 Thread Chang Chao
Hello Dear All. How strings are sorted when LC_COLLATE = ja_JP.UTF-8. I tried to read the documention on that,but there are just a few words, like LC_COLLATE determines string sort order, Is there a specific reference about this? So I can implement an equivalent string sort function in JAVA. becau

Re: [SQL] insert from a select

2010-11-24 Thread Adrian Klaver
On Wednesday 24 November 2010 4:07:43 pm John Fabiani wrote: > Hi, > I have a strange issue that is mostly likely me not understanding > something. I always thought that an insert statement would accept any > select statement. I'm guessing I am wrong. > > I have created a temporary table ("tempcla

[SQL] insert from a select

2010-11-24 Thread John Fabiani
Hi, I have a strange issue that is mostly likely me not understanding something. I always thought that an insert statement would accept any select statement. I'm guessing I am wrong. I have created a temporary table ("tempclass") that is exact match to an existing table ('esclass'). When I

Re: [SQL] atomic multi-threaded upsert

2010-11-24 Thread Tom Lane
"Mikhail V. Puzanov" writes: >-- increment and get the counter if exists > UPDATE sequences SET counter = counter + 1 > WHERE section = 'testSection' AND name = 'testKey' > RETURNING counter; Seems that what you have here is a bad manual implementation of a sequence. Why don't you use

Re: [SQL] "compressing" consecutive values into one

2010-11-24 Thread Louis-David Mitterrand
On Tue, Nov 23, 2010 at 04:19:18PM +0100, Louis-David Mitterrand wrote: > Hi, > > On time series price data I'm trying to remove consecutive identical > prices and keep only the latest. I tried: > > delete from price where id_price in (select t.id_price2 from (select >

[SQL] atomic multi-threaded upsert

2010-11-24 Thread Mikhail V. Puzanov
Hi, All I'm trying to make a kind of upsert for the following table: CREATE TABLE sequences ( section VARCHAR( 50 ) NOT NULL, name VARCHAR( 50 ) NOT NULL, counter BIGINT NOT NULL ); CREATE UNIQUE INDEX IDX_SEQUENCES_SN ON sequences(section, name); Next, I execute the following two