MySQL Forums
Forum List  »  Triggers

Re: How to convert oracle scripts to mysql
Posted by: Peter Brawley
Date: May 02, 2012 08:27PM

Is this what you mean?

drop table if exists employee;
create table employee (
  id int primary key,  
  first_name varchar(200), 
  last_name varchar(15), 
  start_date date, 
  end_date date , 
  salary decimal(8,2), 
  city varchar(10) ,
  description varchar(15)
);
CREATE TRIGGER HASHPASSWORD_PARENT BEFORE INSERT ON employee 
FOR EACH ROW SET NEW.first_name = MD5(NEW.first_name); 

insert into employee values 
(1, 'lokesh', 'Martin', '1996-07-25', '2006-07-25', 600.00, 'Toronto',   'Programmer'), 
(2, 'chris', 'Mathews', '1976-03-21', '1986-02-21', 600.00, 'Vancouver', 'Tester' ),
(3, 'loknath', 'VARMA', '1976-03-21', '1986-02-21', 600.00, 'Vancouver', 'Tester' ),
(4, 'kumar', 'MOHAN',   '1976-03-21', '1986-02-21', 600.00, 'Vancouver', 'Tester' );

select id,first_name from employee;
+----+----------------------------------+
| id | first_name                       |
+----+----------------------------------+
|  1 | 5f0e353b1c01e95c08233f477bf4f945 |
|  2 | 6b34fe24ac2ff8103f6fce1f0da2ef57 |
|  3 | 727b8b8a7274be87cfadb7e641147398 |
|  4 | 79cfac6387e0d582f83a29a04d0bcdc4 |
+----+----------------------------------+

For MySQL Trigger syntax see the MySQL manual page for Triggers.

PB

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to convert oracle scripts to mysql
1504
May 02, 2012 08:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.