From: | David Welton <davidw(at)gate(dot)cks(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | insert/update |
Date: | 1998-10-12 20:23:25 |
Message-ID: | 19981012132325.N31505@gate.cks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
[ please CC replies to me ]
I've been reading my sql, looking through the postgres docs, but still
haven't managed to find a clean way to do what I want, to wit:
$foo{"bar"} ++ ; # expressed in perl..
if $foo{"bar"} does not exist, it gets created and set to 1. If it
does exist, it gets increased by one. In SQL, it seems as if there is
no way to do this in one operation, and without using some sort of
language -
if (foo exists in table.row)
update table set row2 = row2 + 1 where row = 'foo';
else
insert into table values ('foo', 1);
This is certainly not elegant, IMHO, and would like to find a way of
doing it in just sql - is this possible? I would like this to be
portable to other sql implementations, if at all possible.
Thanks,
--
David Welton http://www.efn.org/~davidw
Debian GNU/Linux - www.debian.org
From | Date | Subject | |
---|---|---|---|
Next Message | Roberto Joao Lopes Garcia | 1998-10-13 17:00:51 | Re: [SQL] french caracters in Postgresql database ? |
Previous Message | Blaise Laurent | 1998-10-11 09:27:37 | french caracters in Postgresql database ? |