TAILIEUCHUNG - Beginning Visual Basic 2005 Databases phần 7

Lớp WBLTimeSheets là thêm vào bên cạnh các thành phần logic kinh doanh và thực hiện các giao diện IDisposable cũng giống như các lớp học khác trong thành phần này. Bạn có thêm một biến tư nhân để đại diện cho các lớp học tương ứng | Chapter 13 The logic that you implement in the usp_UpdateRole stored procedure in the next Try It Out involves the use of IF statements variables and the implementation of error handling. You saw these SQL statements in action in the various INSERT stored procedures that you wrote in Chapter 11. Try It Out Admin Form Stored Procedures To complete this exercise 1. Open your Time Tracker application in Visual Studio 2005. 2. View the Server Explorer window and click the Auto Hide icon on the window to keep it visible and then view the Stored Procedures node for your database. 3. The first stored procedure to be created is the usp_UpdateRole stored procedure. This stored procedure updates a single role in the Roles table. Readers using SQL Server should right-click the Stored Procedures and choose Add New Stored Procedure from the context menu. Readers using Oracle should use their favorite Oracle tool such as iSQL Plus to create the stored procedures. Enter the code for the following stored procedure SQL Server CREATE PROCEDURE usp_UpdateRole @RoleID UNIQUEIDENTIFIER @RoleName VARCHAR 50 @RoleDescription TEXT @Ranking TINYINT AS -- Declare local variables DECLARE @ID UNIQUEIDENTIFIER -- See if the ranking exists SELECT @ID RoleID FROM Roles WHERE Ranking @Ranking BEGIN IF @ID IS NOT NULL BEGIN -- The ranking exists now verify it doesn t belong to the -- role you are updating IF @RoleID @ID BEGIN RAISERROR Ranking already exists and cannot be duplicated. 18 1 RETURN END END END -- Either the ranking does not exist or it belongs to the role being updated BEGIN TRY UPDATE Roles Set RoleName @RoleName RoleDescription @RoleDescription Ranking @Ranking LastUpdateDate GeTDATE WHERE RoleID @RoleID END TRY 438 Updating Data BEGIN CATCH BEGIN RAISERROR Update role failed. 18 1 RETURN END END CATCH Click the Save icon on the toolbar to create the stored procedure. Oracle CREATE OR REPLACE PROCEDURE usp_UpdateRole inRoleID CHAR inRoleName VARCHAR2 inRoleDescription CLOB .

TỪ KHÓA LIÊN QUAN
Đã 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.