TAILIEUCHUNG - The Language of SQL- P37

The Language of SQL- P37:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | 166 Chapter 16 Stored Procedures and Parameters DATABASE DIFFERENCES MySQL In MySQL the previous example would look like DELIMITER CREATE PROCEDURE ProcedureOne BEGIN SELECT FROM Customers END DELIMITER Remember that creating a stored procedure does not execute anything. It simply creates the procedure so that it can be executed later. Along with tables and views the procedure will be visible in your database management tool so that you can view its contents. Parameters in Stored Procedures All of the SELECT statements you have seen up until now have had a certain static quality due to the fact that they were written to retrieve data in one specific way. The ability to add parameters to SELECT statements gives you the possibility of much greater flexibility. The term parameter in SQL statements is similar to the term variable as it is used in other computer languages. A parameter is basically a value that is passed to a SQL statement by the calling program. It can have whatever value the user specifies at the time the call is made. Let s start with a simple example. We have a SELECT statement that retrieves data from a Customers table. Rather than select all customers we would like the SELECT to retrieve data for only one specific CustomerID number. However we don t want to code the number directly in the SELECT statement. We want the SELECT statement to be general enough so it can accept any provided CustomerID number and then execute with that value. The SELECT statement without any parameters is simply SELECT FROM Customers Parameters in Stored Procedures 167 Our goal is to add a WHERE clause that will allow us to select data for a particular customer. In a general form we d like the SELECT statement to be SELECT FROM Customers WHERE CustomerID Parametervalue In Microsoft SQL Server the creation of such a stored procedure can be accomplished with CREATE PROCEDURE CustomerProcedure @CustID INT AS BEGIN SELECT FROM Customers WHERE CustomerID @CustID END Notice the

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.