Professional Documents
Culture Documents
DETERMINISTIC NONDETERMINISTIC
Returns same result for same input. Returns different result for same input.
Executing method definition again and again for
deterministic giving significant time for
same input. Take more execution time compare
execution if it is giving same result.
than determisitic
When using nondeterministic for
When using deterministic for nondeterministic
deterministic type of functions will take
methods might return wrong results.
unwanted execution time.
Because not executing for getting different
Because unwantly executing again and
outside at all time for the same input.
again for the same output.
2. Functions can have only input parameters for it whereas Procedures can
have input/output parameters.
3. Functions can be called from Procedure whereas Procedures cannot be
called from Function.
7. Functions that return tables can be treated as another rowset. This can
be used in JOINs with other tables.
IF UPDATE(CustomerId)
BEGIN
RAISERROR('CustomerId cannot be updated.', 16 ,1)
ROLLBACK
INSERT INTO CustomerLogs
VALUES(@CustomerId, 'CustomerId cannot be updated.')
END
ELSE
BEGIN
UPDATE Customers
SET Name = @Name,
Country = @Country
WHERE CustomerId = @CustomerId
Disa Procedura
- Procedura e par: Afishon Emrin e Restorantit i cili zgjidhet nga ne , Id e restoranti, rankimi,
kuzhina, adresa,telefoni si dhe website.
- Procedura e tret: Afishon shtimin e nj porosie t re (Po_Id, Art_Id, Sasia). Pra krijohet nj
stored procedure pr insertim t dhnash.
@tavolin Int,
@artikull nvarchar(255),
@sasia Int
AS
BEGIN
END
GO
@tavolin Int,
@restorant nvarchar(25),
@data nvarchar(25),
@ora nvarchar(25),
@klientId int
AS
BEGIN
Update Tavolina
set Data_Rez=@data, Ora_Rez=@ora,Klient_Id=@klientId
Where Tavolina.Res_Id=@ResId and Tavolina.Tavolin_Id=@tavolin
END
GO
Funksione
Funksioni i par: Llogarit faturn e nj porosie n nj tavolin t nj restoranti. Merr si input
numrin e tavolins dhe afishon faturn.
USE [RESTORANTET E TIRANES]
GO
END
Thirrja e funksionit:
Use [RESTORANTET E TIRANES]
go
select Tavolina.Tavolin_Id, dbo.Fatura(5) as fatura from Tavolina where
Tavolina.Tavolin_Id=1