Subject Re: [firebird-support] Check if record exist
Author Greg Strauss
That makes sense...

I had made the presumption that PersID was a unique primary key, but of
course that's not always the case. In particular, this is useful for the
case where PersID is a foreign key on the many side of the relationship.

Thx for the insight.

Greg
----- Original Message -----
From: ""Ann W. Harrison"" <aharrison@...>
Newsgroups: egroups.ib-support
To: <firebird-support@yahoogroups.com>
Sent: Thursday, January 27, 2005 10:01 AM
Subject: Re: [firebird-support] Check if record exist


>
> Greg Strauss wrote:
>>
>> Would doing:
>> select 1 from Person where PersId=:PersId
>
> If you have more than one qualifying person, that query will not be a
> singleton select.
>>
>> select 1 from rdb$database
>> where exists (select 1 from Person where PersId=:PersId)
>>
>
> Because there is only one rdb$database record, that is a singleton
> select and stops after the first qualifying record.
>
> Assuming that there's an ascending index on PersId, this singleton
> select will also touch only one record and is more generic:
>
> select min (p.PersId) from Person p where p.PersId = :PersId
>
>
> Regards,
>
>
> Ann
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>