How to check if sql statement has been executing before executing another SQL statement.
I make like this
DECLARE tempId double default 2;
insert IGNORE into `system_users`( `user_id`,`username`,`password`) values (id , userName ,md5(password)) ;
set tempId= last_insert_id();
IF tempId <> 0 THEN
insert into `user_profile`(`user_id`, `full_name`, `cellphone`, `Date_time_ added`,`added_by`) values (id, fullName ,cellPhone , CURRENT_TIMESTAMP(),addedBy ) ;
function last_insert_id() doesn’t work with my case because user_id is not auto increment pk, it’s the identification number fot the user. what is the function that is used to test execution of sql statement.
You didn’t specify what DMBS you’re using so I’ll assume MySQL (it looks like MySQL to me, please specify if otherwise) For
INSERTstatements, use ROW_COUNT()E.g.
This will return the number of affected rows.
Also, note that for
SELECTstatements, you would use FOUND_ROWS()e.g.
Although this will tell you the total number of rows found, regardless of whether or not you have a
LIMITclause.