Updating mysql row halal dating saiid rajha
Here’s my database structure to accomodate nextval.
Depending on your database setup, it may be a good idea to have the sequence related stuff on its own database.
INSERT INTO sequence.sequence_data (sequence_name, sequence_increment, sequence_max_value) VALUE ('sq_sequence_2', 10, 100) ; DELIMITER $$ CREATE FUNCTION `nextval` (`seq_name` varchar(100)) RETURNS bigint(20) NOT DETERMINISTIC BEGIN DECLARE cur_val bigint(20); SELECT sequence_cur_value INTO cur_val FROM sequence.sequence_data WHERE sequence_name = seq_name ; IF cur_val IS NOT NULL THEN UPDATE sequence.sequence_data SET sequence_cur_value = IF ( (sequence_cur_value sequence_increment) Create Function…
INSERT INTO sequence.sequence_data (sequence_name) VALUE ('sq_my_sequence') ; -- You can also customize the sequence behavior.
Then, if cur_val is not null (remember from my explanation why I have sequence_cur_value column null-able), we want to increment the cur_val so that next time this function is called, the next sequence is ready to be fetched. We have to consider: Then finally, we return cur_val.
Note that the select on line 6 – 12 will return null if the sequence name doesn’t exist.
At this point in time, you really should be using the My SQLi or the PDO module to access your database.
Any host with PHP and My SQL should offer them and they both already contain most of the functionality this wrapper gave the old mysql_* commands.
This page/script has been classified as abandoned and will no longer be updated.