Clarification on SQL Server Function?
-
Friends, Need one big help:) Getting error while creating function in SQL Server. Pls help to resolve the issue. FYI, the inputs as follows. - Function name: func_check_seat_availability Description: The function will check for the availability of seats in a particular bus on a given day. Input Parameters: in_bus_No, in_DateOfJourney, in_NoOfAdults, in_NoOfChildren. Return Values: Return 1 if the seats are available, else return 0. Table details: Column Data Type Constraints ----------------------------------------------------------- BookingId Varchar(4) P_Key, Starts with B100 ----------------------------------------------------------- BusNo Int (REFERENCES tbl_busdetails) ----------------------------------------------------------- CustomerId Int (REFERENCES tbl_Customer) ----------------------------------------------------------- DateOfBooking DateTime ----------------------------------------------------------- DateOfJourney DateTime DateOfJourney>=DateOfBooking ----------------------------------------------------------- NoOfAdults Int Greater than zero ----------------------------------------------------------- NoOfChildren Int Greater than or = to zero -----------------------------------------------------------
-
Friends, Need one big help:) Getting error while creating function in SQL Server. Pls help to resolve the issue. FYI, the inputs as follows. - Function name: func_check_seat_availability Description: The function will check for the availability of seats in a particular bus on a given day. Input Parameters: in_bus_No, in_DateOfJourney, in_NoOfAdults, in_NoOfChildren. Return Values: Return 1 if the seats are available, else return 0. Table details: Column Data Type Constraints ----------------------------------------------------------- BookingId Varchar(4) P_Key, Starts with B100 ----------------------------------------------------------- BusNo Int (REFERENCES tbl_busdetails) ----------------------------------------------------------- CustomerId Int (REFERENCES tbl_Customer) ----------------------------------------------------------- DateOfBooking DateTime ----------------------------------------------------------- DateOfJourney DateTime DateOfJourney>=DateOfBooking ----------------------------------------------------------- NoOfAdults Int Greater than zero ----------------------------------------------------------- NoOfChildren Int Greater than or = to zero -----------------------------------------------------------
-
Friends, Need one big help:) Getting error while creating function in SQL Server. Pls help to resolve the issue. FYI, the inputs as follows. - Function name: func_check_seat_availability Description: The function will check for the availability of seats in a particular bus on a given day. Input Parameters: in_bus_No, in_DateOfJourney, in_NoOfAdults, in_NoOfChildren. Return Values: Return 1 if the seats are available, else return 0. Table details: Column Data Type Constraints ----------------------------------------------------------- BookingId Varchar(4) P_Key, Starts with B100 ----------------------------------------------------------- BusNo Int (REFERENCES tbl_busdetails) ----------------------------------------------------------- CustomerId Int (REFERENCES tbl_Customer) ----------------------------------------------------------- DateOfBooking DateTime ----------------------------------------------------------- DateOfJourney DateTime DateOfJourney>=DateOfBooking ----------------------------------------------------------- NoOfAdults Int Greater than zero ----------------------------------------------------------- NoOfChildren Int Greater than or = to zero -----------------------------------------------------------
What precisely are you expecting us to do with this information? You need to supply the script for the function and the error you are getting for us to help you!
Never underestimate the power of human stupidity RAH
-
HARI JJ wrote:
Getting error
We have no way of knowing what the error is unless you let us know.
-
HARI JJ wrote:
Getting error
We have no way of knowing what the error is unless you let us know.
-
What precisely are you expecting us to do with this information? You need to supply the script for the function and the error you are getting for us to help you!
Never underestimate the power of human stupidity RAH
-
Hi Shameel, Thanks for your mail. Could you send me the function queries. Iam new to this database, struggling hard to get into the basics too. having lot of doubts.
-
What have you tried? What is the error that you get? If you expect someone to write the function for you, then you're in the wrong place.
Sorry Shammel. Its very important for me, thatsy expecting help. Pls let me help how to resolve the queries. I tried the following. CREATE FUNCTION func_check_seat_availability ( @in_bUS_No int, @in_DateOfJourney datetime, @in_NoOfAdults int, @in_NoOfChildren int ) RETURNS decimal(36,30) AS BEGIN --considering 64 is the total count of bus select case when sum(NoOfAdults+NoOfChildren+@in_NoOfAdults+@in_NoOfChildren) >= 64 then 0 when sum(NoOfAdults+NoOfChildren+@in_NoOfAdults+@in_NoOfChildren) < 64 then 1 End from Bus_Details where BusNo=@in_bus_No and DateOfJourney=@in_DateOfJourney END
-
Friends, Need one big help:) Getting error while creating function in SQL Server. Pls help to resolve the issue. FYI, the inputs as follows. - Function name: func_check_seat_availability Description: The function will check for the availability of seats in a particular bus on a given day. Input Parameters: in_bus_No, in_DateOfJourney, in_NoOfAdults, in_NoOfChildren. Return Values: Return 1 if the seats are available, else return 0. Table details: Column Data Type Constraints ----------------------------------------------------------- BookingId Varchar(4) P_Key, Starts with B100 ----------------------------------------------------------- BusNo Int (REFERENCES tbl_busdetails) ----------------------------------------------------------- CustomerId Int (REFERENCES tbl_Customer) ----------------------------------------------------------- DateOfBooking DateTime ----------------------------------------------------------- DateOfJourney DateTime DateOfJourney>=DateOfBooking ----------------------------------------------------------- NoOfAdults Int Greater than zero ----------------------------------------------------------- NoOfChildren Int Greater than or = to zero -----------------------------------------------------------
try something like
CREATE FUNCTION func_check_seat_availability
(
@in_bUS_No int,
@in_DateOfJourney datetime,
@in_NoOfAdults int,
@in_NoOfChildren int
)
RETURNS decimal(36,30)
AS
BEGIN
--considering 64 is the total count of bus
declare @value decimal(36,30)
select
@value=case when sum(@in_NoOfAdults+@in_NoOfChildren) >= 34 then 0
when sum(@in_NoOfAdults+@in_NoOfChildren) < 14 then 1
end
from Details where BusNo=@in_bus_No and DateOfJourney=@in_DateOfJourney
return @value
ENDThanks
-
Could you send me the function queries. Iam new to this database, struggling hard to get into the basics too. having lot of doubts.
What I have nothing better to do than write your code for you tsk tsk not going to happen I'm afraid. How can you expect to learn if you don't research and try and do the coding, getting help when you stumble.
Never underestimate the power of human stupidity RAH