Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to use a trigger to validate input data

-- validate email
CREATE TRIGGER `person_validate_insert`
	BEFORE INSERT
	ON `person`
	FOR EACH ROW
BEGIN
	IF NEW.`email` NOT LIKE '%_@%_.__%' THEN
		SIGNAL SQLSTATE VALUE '45000'
			SET MESSAGE_TEXT = '[table:person] - `email` column is not valid';
	END IF;
END;
Comment

PREVIOUS NEXT
Code Example
Sql :: Are NULL values in a database the same as that of blank space or zero? 
Sql :: sql server list user permissions 
Sql :: get rows affected mysql python 
Sql :: reutrn string after character sql 
Sql :: first letter capital in mysql query 
Sql :: postgres get database encoding 
Sql :: split first name and last name in sql 
Sql :: drop table if exists oracle 
Sql :: how to get the ddl for datafile in oracle tablespace 
Sql :: how to delete a column in sql 
Sql :: list columns in table postgres 
Sql :: conda install pymysql "windows" 
Sql :: sql get number of days between two dates 
Sql :: how to delete table in mysql 
Sql :: copy one column data to another in sql 
Sql :: Oracle Column Names of a table 
Sql :: how to find date from date table in sql 
Sql :: difference between where and having clause 
Sql :: describe table query in postgresql 
Sql :: sql alchemy with azuresql server 
Sql :: oracle user privileges 
Sql :: mysql remove user privileges 
Sql :: mysql alter table set column unique 
Sql :: alter table name 
Sql :: not operator in oracle 
Sql :: mysqli_connect using prepare statement 
Sql :: insert all in sql 
Sql :: oracle search in date columns 
Sql :: oracle add auto_increment column to existing table 
Sql :: opensuse restart MySQL 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =