Sie sind auf Seite 1von 3

Server compiles each stored procedure once and then reutilizes the execution plan.

This results in tremendous performance boosts when stored procedures are called repeatedly. Reduced client/server traffic. If network bandwidth is a concern in your environment, you'll be happy to learn that stored procedures can reduce long SQL queries to a single line that is transmitted over the wire. Efficient reuse of code and programming abstraction. Stored procedures can be used by multiple users and client programs. If you utilize them in a planned manner, you'll find the development cycle takes less time. Enhanced security controls. You can grant users permission to execute a stored procedure independently of underlying table permissions. Structure Stored procedures are extremely similar to the constructs seen in other programming languages. They accept data in the form of input parameters that are specified at execution time. These input parameters (if implemented) are utilized in the execution of a series of statements that produce some result. This result is returned to the calling environment through the use of a recordset, output parameters and a return code. That may sound like a mouthful, but you'll find that stored procedures are actually quite simple. Example: CREATE PROCEDURE updtopbooks ( @topbookid int, @topbooksbookid int )

As update tbtopbooks set TopbooksbookID=@topbooksbookid where TopbookID=@topbookid

PROJECT PROCEDURES
In our project Online Book Store, we have used several stored procedures for making transactions with the dat abase. For each table of our database there are Five Stores procedures used for different operations i.e. Select, Insert, Delete, Update and Search. Following are the details for each stored procedure for respective tables. 1. Books Info. Table a. Select Procedure CREATE PROCEDURE dispbook As select * from tbbook b. Insert Procedure CREATE PROCEDURE insbook ( @booksubcatid int, @booktit varchar(50), @bookshortdesc varchar(200), @bookpub varchar(50), @bookaut varchar(50), @bookisbn varchar(50), @bookprc integer, @bookdisc integer, @bookimg varchar(50), @bookaddate datetime, @bookstatus char(10) ) As

insert into tbbook(BooksubcatID,Booktit,Bookshortdesc,Bookpub,Bookaut,BookISBN,Bookprc,Bookdisc,Bookimg,Bookaddate, Bookstatus) values(@booksubcatid, @booktit, @bookshortdesc, @bookpub, @bookaut,@bookisbn, @bookprc, @bookdisc, @bookimg, @bookaddate, @bookstatus) c. Delete Procedure CREATE PROCEDURE delbook ( @bookid int ) As delete from tbbook where BookID=@bookid d. Update Procedure CREATE PROCEDURE updbook ( @bookid int, @booksubcatid int, @booktit varchar(50), @bookshortdesc varchar(200), @bookpub varchar(50), @bookaut varchar(50), @bookisbn varchar(50), @bookprc integer, @bookdisc integer, @bookimg varchar(50), @bookaddate datetime, @bookstatus char(10) ) As update tbbook set BooksubcatID=@booksubcatid,Booktit=@booktit,Bookshortdesc=@bookshortdesc,Bookpub=@bookpub,

Das könnte Ihnen auch gefallen