Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: To check a record's existence in a table, FAST!
Why not use EXISTS (seems to me like that why it's there) In my application I've used a soultion with a helptable OneValue (which contain one column (int) and one row (1)):
FUNCTION RecordExist RETURN BOOLEAN IS
CURSOR Check IS
SELECT Val FROM OneValue WHERE EXISTS (SELECT * FROM <table-name> WHERE <where-clause>); vVal INTEGER; -- Dummy BEGIN FETCH Check INTO Val; IF Check%found THEN RETURN TRUE; END IF; RETURN False;
Uses explicit cursor to avoid a second fetch. If you use implicit cursor there is a second fetch performed to verify if Oracle should raise exception TO_MANY_ROWS.
![]() |
![]() |