Subject | Re: [firebird-support] using select count(*) |
---|---|
Author | Helen Borrie |
Post date | 2006-04-18T00:35:13Z |
At 08:50 AM 18/04/2006, you wrote:
if exists (select 1 from atable where <something unique> then ...
In your application (if you must do this kind of test) write a
function that makes the equivalent test and returns 1 for a true
result and returns no rows otherwise:
select 1 from rdb$database where exists<something unique>
But, really, a SP is a much better way to do this two-sided stuff,
where your app doesn't know whether it's going to insert or update.
./heLen
>In our triggers and stored procedures we useGood grief, this sounds pretty flaky from the point of view of consistency!
>
>select count(*)
>from table
>where value = Primary Key.value
>
>to determine whether we should run an insert or an update
>query on triggered tables.
>Is there a faster way?Read more. :-)
>
>I am half way through Helen's book "The firebird book"
>She suggests never using select count(*) but I do not know aIn PSQL:
>faster way of doing this.
if exists (select 1 from atable where <something unique> then ...
In your application (if you must do this kind of test) write a
function that makes the equivalent test and returns 1 for a true
result and returns no rows otherwise:
select 1 from rdb$database where exists<something unique>
But, really, a SP is a much better way to do this two-sided stuff,
where your app doesn't know whether it's going to insert or update.
./heLen