Meaning, an index that does not allow duplicate values to be inserted.
You don't say which RDBMS you are using, but this is pretty basic
functionality that is widely supported. The documentation on the "CREATE
INDEX" command for your DB should say so.
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Jeff Eckermann" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, August 27, 2001 2:41 PM
Subject: Re: Looping multiple selects
Jeff,
Not sure I follow you, using a unique index??
On Mon, 27 Aug 2001 14:35:42 -0500, "Jeff Eckermann" <[EMAIL PROTECTED]>
wrote:
>>How about a unique index on that field in the database? ISTM that this is
>>what you are trying to emulate with your code.
>>----- Original Message -----
>>From: <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Sent: Saturday, August 25, 2001 9:55 PM
>>Subject: Looping multiple selects
>>
>>
>>Hi All,
>>
>>I have a sub routine that needs to check to make sure that a group of tag
id
>>numbers are not already in our database. But I'm not sure this is going to
>>work
>>the way I think it will or there maybe a better way to do it. Here's the
>>snip:
>>
>>sub check_tag_num {
>>my @tagnums = shift();
>>
>>$sqlquery = qq|SELECT tagid FROM tags WHERE tagnumber = ?|;
>>$sth = $dbh->prepare($sqlquery) or dbError("Error: $DBI::errstr");
>>
>>for my $tags (@tagnums) {
>>$sth->execute($tags);
>> my($id) = $sth->fetchrow_array();
>>$id and error("The Tag Number entered: $tagid is already in our
>>database","Duplicate Tag Number");
>> }
>>
>>}
>>
>>the @tagnums array stores the multiple tagid numbers and I need to loop
thru
>>each one to make sure it's not already in the tags table. Is this the best
>>may
>>to approach this??
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel: 1(225)686-2002
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=