Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> count(*) vs. a cursor when determining the existing record on primary key

count(*) vs. a cursor when determining the existing record on primary key

From: jgk <javapda_at_yahoo.com>
Date: 16 Jun 2003 11:18:16 -0700
Message-ID: <6851e45e.0306161018.1e31fa7f@posting.google.com>


If you have a table with a primary key and you want to determine if a particular primary key exists what is the fastest way to accomplish this?

In Steve Feuerstein's great book "Oracle PL/SQL Best Practices" SQL-08: Use COUNT only when the actual number of occurrences is needed...he gives some case(s) where a cursor should be used instead of the count(*) function.

If you have a table. The table has a primary key field. If you want to test for existence of a matching primary key is it better to use the COUNT function and see if there is a match > 0 (it would always be 1 or zero)...or should a cursor be used?

Thanks,

JGK Received on Mon Jun 16 2003 - 13:18:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US