Otel numarasına(grup otellerde) göre verilen bir odanın misafir bilgilerini getiren SQL procedure
Bu prosedür input olarak, hotelno, odano ve tarih alıyor. Sistemin içinde birden fazla otel datası olabiliyor. Bu değer parametrik olarak tanımlanabilir , tek otel için bu değer genelde 01 dir. Bu alanın tipi char(2) olarak tanımlıdır ve genellikle ‘01’, ‘02’ gibi bir değeri olur.
Örneğin, ‘01’ kodlu otelde, 21 ocak 2010 tarihinde, 127 nolu odada konaklayan kişiye ait bilginin sorgulanması için prosedürün
GET_ROOMINFO '01','127','2010-01-21'
şeklinde çalıştırılması gerekmektedir.
Prosedür output olarak odano, giriş tarihi, çıkış tarihi, misafir adı-soyadı, kimlik türü (N: TC kimlik no, P: pasaport) ve kimlik no değerlerini döndürür. Eğer sorgulanan odada bu tarihte konaklayan misafir yoksa, prosedürün outputu oda no haricinde, null değerlerden oluşur.
create procedure GET_ROOMINFO @hotelno char(2),@room char(6),@today datetime
as
declare @musteri varchar(50),@rno int, @gno int, @kimlikno varchar(20), @kimlikturu char(1), @passno varchar(20), @ardate datetime, @dedate datetime;
if exists (select RNO from HOUSE where HOTELNO=@hotelno and ROOM=@room and CHECKIN=1 and CHECKOUT=0 and @today>=ARTARIH and @today<=DETARIH) begin
select @rno=RNO, @ardate=ARTARIH, @dedate=DETARIH from HOUSE where HOTELNO=@hotelno and ROOM=@room and CHECKIN=1 and CHECKOUT=0 and @today>=ARTARIH and @today<=DETARIH
if exists (select GNO from HGUEST where HOTELNO=@hotelno and RNO=@rno) begin
set @gno=(select GNO from HGUEST where HOTELNO=@hotelno and RNO=@rno)
if exists (select GNO from GUEST where HOTELNO=@hotelno and GNO=@gno) begin
select @musteri=rtrim(ADI+' '+SOYADI), @kimlikno=KIMLIK, @passno=PASS_NO from GUEST where HOTELNO=@hotelno and GNO=@gno
if @kimlikno='' and @passno<>'' select @kimlikno=@passno, @kimlikturu='P'
else set @kimlikturu='N'
end
end
end
else set @rno=0
select @room as ODANO, @ardate as GIRISTARIHI, @dedate as CIKISTARIHI, @musteri as MUSTERI, @kimlikturu as KIMLIKTURU, @kimlikno as KIMLIKNO