TAILIEUCHUNG - Beginning SQL Server 2005 for Developers From Novice to Professional phần 8

Ví dụ đầu tiên sẽ chứng minh nơi một giá trị varchar thành công sẽ cập nhật một cột được định nghĩa là số nguyên. Nhập đoạn mã sauCác văn bản của chương này không phải là chất lỏng nhất, nhưng thông tin sẽ rất hữu ích khi bạn bắt đầu sử dụng SQL Server. | 348 CHAPTER 10 STORED PROCEDURES EXECUTE @RetVal 1 @ClearedBalance OUTPUT @UnclearedBalance OUTPUT SELECT @RetVal AS ReturnValue @ClearedBalance AS ClearedBalance @UnclearedBalance AS UnclearedBalance GO 9. Now that the template has been altered with the changes we need execute the template by pressing Ctrl E or F5 or clicking the execute button on the toolbar. This will create the stored procedure and run the examples at the end to demonstrate the procedure. Of course we can run this section of code as many times as we want because the whole scenario from dropping and losing the stored procedure through to re-creating the stored procedure is all there ready for us. The stored procedure will pass back its output parameter value to the @ClearedBalance and @UnclearedBalance variables defined within the execution batch and the return value to the @RetVal variable. From there once the variables are set the values can be printed out using a SELECT statement. This will produce the output shown in Figure 10-7 in the results pane. s Results Messages ReturnValue ClearedBalance UnclearedBalance 1 0 4311 22 21311 Figure 10-7. Results after running the OUTPUT stored procedure We have now built two very basic stored procedures in which we are performing an INSERT and a SELECT. Next we look at control of flow. Controlling the Flow When working on a stored procedure there will be times when it is necessary to control the flow of information through it. The main control of flow is handled with an LSE statement. You can also control the flow with a WHILE. .BREAK statement. Note The GOTO statement can also control the flow of a stored procedure. You can use this statement to jump to a label within a stored procedure but this can be a dangerous practice and really is something that should be avoided. For example it might be better to nest the stored procedure calls. Controlling the flow through a stored procedure will probably be required when a

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.