Returning one boolean for mutiple inputs [message #37802] |
Thu, 28 February 2002 09:42 |
epro
Messages: 11 Registered: January 2002
|
Junior Member |
|
|
Hi
I have function that returns a boolean(True or false),
It does in such a way, first it looks for rows in a table, where column1 = :parameter,
then the cursor gives 3 or 4 rows.
in my logic, one row is enough if that satisfies the requirement.
I have program like this
============
cursor c select * from tab_1
where emp_num = &p;
/* this cursor gives 3 or 4 rows *, I have to see each row, for condition and result*/
If 1st row satisfies, I dont want to process 2nd row with same emp_num., but if not I have to chek all rows.
begin
for c_rec in c
loop
if emp_dept in (a,b) then
return true /* and stop */
elsif emp_dept in ('c') then
call_proc(p1,p2)
if p2 = c2 then
return true /* and stop */
elsif....
end loop;
after checking all rows, if we can't return TRUE, then
we have return FALSE.
===================
any idea, please let me know.
Thanks
|
|
|
Re: Returning one boolean for mutiple inputs [message #37804 is a reply to message #37802] |
Thu, 28 February 2002 10:45 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
Wouldn't just adding a 'return false;' after your loop accomplish what you want?
That is, if none of the conditions are satisfied as you run through your cursor, return false.
It would appear this is optimized since the first true condition you hit will exit the function.
|
|
|
|
|