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 -> Re: fun sql question

Re: fun sql question

From: Alex Filonov <afilonov_at_pro-ns.net>
Date: Sun, 03 Dec 2000 05:23:30 GMT
Message-ID: <90clcg$cr8$1@nnrp1.deja.com>

Is this an index search? If so, is it unique index? I both answers are yes, then just select count from each table.

Common solution: PL/SQL function (yes, I hate using pl/sql for data access, this is one of rare exceptions):

function itexists(t1k in number) return varchar2 as  c varchar2 (3);
 i number;
 begin
   select count(1)
   into i
   from t1
   where k = t1k
 and rownum <= 1;
   if i = 0 then
 select count(1)
 into i
 from t2
 where k = t1k
 and rownum <= 1;
   end if;
   if i > 0 then
 c := 'YES';
   else
 c := 'NO';
  end if;
  return c;
end;

Code is not perfect, just an idea.

In article <908sh9$lbp$1_at_nnrp1.deja.com>,   seanldus_at_my-deja.com wrote:
> Does anyone know the best(quickest) way to check for the existernce
 of
> something? I know, not very descriptive, So I have two huge tables
> and one or more instance of (x WHERE y and z) could show up in one or
> both of these tables. I am looking for the quickest way to get a yes
> or no answer as to wheather it's in there. In other words, if I find
> one instance I would like to stop.
>
> Any Ideas???
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sat Dec 02 2000 - 23:23:30 CST

Original text of this message

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