UNIT 7 Flashcards
______ a set of Transact-SQL (T-SQL) statements that is compiled and stored as a single database objects for later repetitive use.
Stored procedure
API
Application Programming Interface
logically, a stored procedure consists of
header, body
defines the name of the stored procedure, the input and output parameters, and some miscellaneous processing options. You can think of it as an API declaration of the stored procedure.
header
contains one or more Transact-SQL statements to be executed at runtime.
body
the one way to change a stored procedure
drop or re-create
Two ways to prevent the error “Msg 2714, Level 16, State 3, Procedure pr_Eqipment_Get, Line 4
There is already an object named pr_Equipment_Get’ in the database.”
use
Drop Procedure pr_EqipmentByEqTypeID_get
go // this will say that we need to execute the next line of code
create stored procedure for MYSQL
CREATE OR REPLACE PROCEDURE pr_getEquipment()
other way to write drop and create procedure in MS SERVER
IF object_id(‘ pr_equipment_get’) is not null – we check if theres an object called pr_equipment_get,if it exists,delete it
begin
drop PROCEDURE pr_equipment_get
end
what is the other way to change a stored procedure?
Alter Procedure statement
execute a procedure in mysql
call pr_Get_Name ()
execute a procedure in ms server
exec pr_Get_Name()
altering procedure in ms server
alter procedure pr_Equipment_Get
altering procedure in mysql
create or replace procedure pr_Equipment_Get
When you are creating or changing a stored procedure, keep in mind the ____
limits