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 -> Preferred way to check a record exists

Preferred way to check a record exists

From: David <auto90059_at_hushmail.com>
Date: Wed, 17 Sep 2003 22:44:45 +1000
Message-ID: <3f68573e$0$10355$afc38c87@news.optusnet.com.au>


What's the preferred way to check whether a record actually exists in a table? If I wanted to check whether author is listed, is it naive to do something like this, or it better to catch the NO_DATA_FOUND exception? Maybe there's another approach altogether...

SELECT COUNT (*)

        INTO v_count
        FROM People
        WHERE AddAuthor.address = Address
        AND author = Name;
    IF v_count = 1 THEN
        DBMS_OUTPUT.PUT_LINE (author || ' in ' || AddAuthor.address ||

' was found in the database, now registering as an author ...
');

    ELSE

        DBMS_OUTPUT.PUT_LINE (author || ' in ' || AddAuthor.address ||

' not found');
Received on Wed Sep 17 2003 - 07:44:45 CDT

Original text of this message

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