In this lesson, you will use Sybase WorkSpace to run the trigger you just created in the titles table.
If necessary, select Window|Open Perspective|Database Development from the main menu bar to open the Database Development perspective.
Find the insert_title trigger that you created in the previous tutorial, “Lesson 2: Create a new trigger”.
In the Database Explorer view, expand the Tables folder under the appropriate pubs sample database. Next, expand the titles folder and then the Triggers folder.
Run the trigger using either method:
Double-click the trigger to open it in the SQL Editor, and then right-click anywhere in the SQL Editor and select Run from the context menu.
Right-click the trigger and select Run Trigger from the context menu.
The Modify attributes and launch dialog box displays.
In the Run box, enter the following SQL statement that executes to cause the trigger invocation.
INSERT INTO titles ( title_id, title, � type, price, � advance, � royalty, � ytd_sales, � notes, � pubdate ) � VALUES ( 'XX9999', 'This Book Cannot Be Inserted', � 'drama', � 19.22, � 10000.00, � 10, � 99, � 'One great book!', � '8/12/1958' )
Although you can click SQL to launch the Visual SQL dialog to create the SQL statement, for this tutorial, manually enter the SQL statement in the Run box.
Click Apply to save the SQL statement for future invocations.
Click Run to execute the trigger.
Sybase WorkSpace executes the triggers and displays the results in the SQL Results view. The insert failed as expected because the trigger was designed to print an error message during an attempt to insert data into the table.
The Status tab displays the message that the raiserror command issued.
Select File|Close on the main menu bar to close the SQL Editor.
You can easily make changes to the trigger and save it back to the server.