how to create a trigger?
I want to create a trigger for the following table :
This is my code :
CREATE TABLE INVOICE (
Invoice_id number CONSTRAINT Invoice_id_pk PRIMARY KEY,
Invoice_date datetime NOT NULL DEFAULT CURDATE(),
Invoice_location varchar2(150) NOT NULL,
Invoice_order number CONSTRAINT Invoice_order_fk REFERENCES order_header(Order_id)
What would be the syntax for a trigger for the above table?
I would really appreciate any help
You don't say what DMBS you are using, so for now I'll assume MySQL and ask if you have looked at the manual pages yet, perhaps starting here?
this is template for SQL server
-- Create T-SQL Trigger Template
USE <database_name, sysname, AdventureWorks>
IF OBJECT_ID ('<schema_name, sysname, Sales>.<trigger_name, sysname, uStore>','TR') IS NOT NULL
DROP TRIGGER <schema_name, sysname, Sales>.<trigger_name, sysname, uStore>
CREATE TRIGGER <schema_name, sysname, Sales>.<trigger_name, sysname, uStore>
ON <schema_name, sysname, Sales>.<table_name, sysname, Store>
AFTER <data_modification_statements, , UPDATE>
AS <T-SQL_statement, , UPDATE Sales.Store SET ModifiedDate = GETDATE() FROM inserted WHERE inserted.CustomerID = Sales.Store.CustomerID>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)