Re: conditional insert - Mailing list pgsql-general

From J. Hondius
Subject Re: conditional insert
Date
Msg-id 4E64AC45.6030704@rem.nl
Whole thread Raw
In response to Re: conditional insert  (Pau Marc Muñoz Torres <paumarc@gmail.com>)
Responses Re: conditional insert  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
List pgsql-general
I agree that there are better ways to do this.<br /> But for me this works. (legacy driven situation)<br /><br />
INSERTINTO tbinitialisatie (col1, col2) <br />  SELECT 'x', 'y' <br />  FROM tbinitialisatie <br />  WHERE not exists
(select* from tbinitialisatie where col1 = 'x' and col2 = 'y') <br />  LIMIT 1 <br /><br /><br /> Pau Marc Muñoz Torres
schreef:<blockquote cite="mid:CADFuJLjfHUMEuYTPKgG6GtJMfzJeeq3-bkt162RywRVqc7OYgg@mail.gmail.com" type="cite">Ok ,
thanksSim, now i see it<br /><br /> P<br /><br /><div class="gmail_quote">2011/9/5 Sim Zacks <span dir="ltr"><<a
href="mailto:sim@compulab.co.il"moz-do-not-send="true">sim@compulab.co.il</a>></span><br /><blockquote
class="gmail_quote"style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;"><divbgcolor="#ffffff" style="direction: ltr;" text="#000000"><div class="im"> On 09/05/2011 01:37 PM, Pau Marc
MuñozTorres wrote: <blockquote type="cite">i don't  see it clear, let me put an example<br /><br /> i got the following
table<br/><br /> molec varchar(30)<br /> seq varchar(100)<br /><br /> where I insert my values<br /><br />  lets image
thati have a record introduced as ('ubq', 'aadgylpittrs')<br /><br /> how i can prevent to insert another record where
molec='ubq'?<br /><br /> thanks<br /><br /></blockquote></div> Either put a unique constraint on molec or do<br />
insertinto tbl(molec,seq)<br /> select 'ubq', 'aadgylpittrs' where not exists(select molec from tbl where
molec='ubq')<br/></div></blockquote></div><br /><br clear="all" /><br /> -- <br /><b>Pau Marc Muñoz Torres</b><br /><br
/>Laboratori de Biologia Computacional   <br /> Institut de  Biotecnologia   i Biomedicina Vicent Villar               
                   <br /> Universitat Autonoma de Barcelona<br /> E-08193 Bellaterra (Barcelona)<br />              
<br/> telèfon:  (+34)935 86 89 39<b><br /> Email : <a href="mailto:paumarc.munoz@bioinf.uab.cat" moz-do-not-send="true"
target="_blank">paumarc.munoz@bioinf.uab.cat</a></b><br/></blockquote> 

pgsql-general by date:

Previous
From: Radosław Smogura
Date:
Subject: Protocol question - fastpath & parameter status 'S'
Next
From: Oguz Yilmaz
Date:
Subject: compression of query and result data in tcp socket connections