Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET GLOBAL log_bin_trust_function_creators = 1;
- create database seq;
- use seq;
- create table `seq` (
- `seq_name` varchar(20) NOT NULL,
- `last_val` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
- PRIMARY KEY (`seq_name`)
- ) ENGINE=MyISAM
- ;
- delimiter //
- create function `get_next_seq_val`(`seq_name` varchar(20))
- returns bigint(20) NOT DETERMINISTIC
- begin
- update seq set last_val = last_insert_id(last_val + 1) where name = seq_name;
- return last_insert_id();
- end
- //
- delimiter ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement