Database Administration (MOSC)

MOSC Banner

Check the Existence of Rows in a Table

edited Jan 30, 2009 1:57AM in Database Administration (MOSC) 7 commentsAnswered
  Are there better ways to check the existence of rows in a table instead of using the code below?


DECLARE
   row_count INT;

....

BEGIN
   SELECT COUNT(*) INTO row_count FROM table WHERE condition;

   IF row_count > 0 THEN --Record exists
       -- Do sth
   ELSE
      -- Do sth else
   END IF;

   ..

END;

Thanks,
Sambath

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center