Re: conditional insert

From: Sim Zacks <sim(at)compulab(dot)co(dot)il>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: conditional insert
Date: 2011-09-05 10:42:38
Message-ID: 4E64A79E.7030503@compulab.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="direction: ltr;">
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<style>body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" bgcolor="#ffffff"
text="#000000">
On 09/05/2011 01:37 PM, Pau Marc Mu&ntilde;oz Torres wrote:
<blockquote
cite="mid:CADFuJLi3K0X1A7OwR+9_neWjKCEXtYYyMP_n=x5z=D2+GNCTNw(at)mail(dot)gmail(dot)com"
type="cite">i don't&nbsp; 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>
&nbsp;lets image that i 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>
Either put a unique constraint on molec or do<br>
insert into tbl(molec,seq)<br>
select 'ubq', 'aadgylpittrs' where not exists(select molec from tbl
where molec='ubq')<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.2 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pau Marc Muñoz Torres 2011-09-05 10:47:15 Re: conditional insert
Previous Message Pau Marc Muñoz Torres 2011-09-05 10:37:54 Re: conditional insert