Re: Date range problem
"Lloyd Muccio" <[email protected]> Wed, 19 Mar 2003 07:10:44 -0500
| Newsgroups | gmane.comp.db.oracle.devel |
|---|---|
| Organization | NOAA |
| Message-ID | <LYRIS-1796914-918559-2003.03.19-12.08.32--gcdod-oracle#[email protected]> |
My guess would be a lookup function something like this.
I didn't test it though..
The heart of the test is the query associated with c_lookup.
Good luck.
CREATE OR REPLACE FUNCTION IS_VEHICLE_AVAILABLE(
START_DATE_IN DATE
, END_DATE_IN DATE
) RETURN VARCHAR2
IS
answer varchar2(3) := 'YES';
cursor c_lookup is select 'NO'
FROM vehicle_booking
WHERE (start_date_in between booking_from_date and booking_to_date)
OR (end_date_in between booking_from_date and booking_to_date)
OR (booking_from_date between start_date_in and end_date_in)
OR (booking_to_date between start_date_in and end_date_in);
c_lookup_rec c_lookup%rowtype;
begin
open c_lookup;
fetch c_lookup into answer;
close c_lookup;
return answer;
exception
WHEN NO_DATA_FOUND
RETURN 'YES';
WHEN OTHERS THEN
RETURN 'NO';
end;
waseem altaf wrote:
> Hi
>
> I have a table named "Vehicle_Booking" this table has two fields
> "Booking_From_Date" and "Booking_To_Date" .
>
> Scenario:
> If a vehicle is booked from 5-JAN-2003 To 10-JAN-2003 by an employee A . another employee B comes and want to book it
> from 8-JAN-2003 to 12-JAN-2003.
>
> I want to check whether the vehicle is already booked by some employee or not before assigning vehicle to employee B.
> How can i do this.
>
> Thanx in advance.
>
> _____________________________________________________________
> 100% private, FREE email for life!
> Visit http://inbox.com.pk
>
> _____________________________________________________________
> Select your own custom email address for FREE! Get [email protected] w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag
>
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or
> to unsubscribe send a blank email to %%email.unsub%%.
---
Change your mail options at http://p2p.wrox.com/manager.asp or
to unsubscribe send a blank email to [email protected].