7 - Advance Database Objects
7 - Advance Database Objects
BENEFITS:
-reduced client server traffic
-stronger security
-reuse of code
-easier maintenance
-improved performance
-----------------------------------------------------------------------------------
------------------------
CREATE PROCEDURE getAll
AS
SELECT * FROM Customers
GO;
SCALAR:
A function has a return type and returns a value. A procedure does not have a
return type. But it returns values using the OUT parameters.
Doesnot allow DML queries. Only Select queries. You can use DML queries such as
insert, update, select etc� with procedures.
A function does not allow output parameters A procedure allows both
input and output parameters.
You cannot manage transactions inside a function. You can manage transactions
inside a procedure.
You cannot call stored procedures from a function You can call a function from
a stored procedure.
You can call a function using a select statement. You cannot call a procedure
using select statements.
-----------------------------------------------------------------------------------
--------------------
TRIGGERS:
-Are special kind of stored procedures that automatically executes when an event
occur in DB server.
-There are two Types DDL triggers and DML triggers.
-DML: when insert, delete, update, select.
-DDL: when create, alter, drop etc.
**create trigger that prints message when there is creation, alteration or drop of
any table. **