Re: conditional insert
| От | J. Hondius |
|---|---|
| Тема | Re: conditional insert |
| Дата | |
| Msg-id | 4E64AC45.6030704@rem.nl обсуждение исходный текст |
| Ответ на | Re: conditional insert (Pau Marc Muñoz Torres <paumarc@gmail.com>) |
| Ответы |
Re: conditional insert
|
| Список | pgsql-general |
I agree that there are better ways to do this.
But for me this works. (legacy driven situation)
INSERT INTO tbinitialisatie (col1, col2)
SELECT 'x', 'y'
FROM tbinitialisatie
WHERE not exists (select * from tbinitialisatie where col1 = 'x' and col2 = 'y')
LIMIT 1
Pau Marc Muñoz Torres schreef:
But for me this works. (legacy driven situation)
INSERT INTO tbinitialisatie (col1, col2)
SELECT 'x', 'y'
FROM tbinitialisatie
WHERE not exists (select * from tbinitialisatie where col1 = 'x' and col2 = 'y')
LIMIT 1
Pau Marc Muñoz Torres schreef:
Ok , thanks Sim, now i see it
P2011/9/5 Sim Zacks <sim@compulab.co.il>On 09/05/2011 01:37 PM, Pau Marc Muñoz Torres wrote:Either put a unique constraint on molec or doi don't see it clear, let me put an example
i got the following table
molec varchar(30)
seq varchar(100)
where I insert my values
lets image that i have a record introduced as ('ubq', 'aadgylpittrs')
how i can prevent to insert another record where molec='ubq' ?
thanks
insert into tbl(molec,seq)
select 'ubq', 'aadgylpittrs' where not exists(select molec from tbl where molec='ubq')
--
Pau Marc Muñoz Torres
Laboratori de Biologia Computacional
Institut de Biotecnologia i Biomedicina Vicent Villar
Universitat Autonoma de Barcelona
E-08193 Bellaterra (Barcelona)
telèfon: (+34)935 86 89 39
Email : paumarc.munoz@bioinf.uab.cat
В списке pgsql-general по дате отправления: