DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( IN vFiscalYear INT, OUT vNewBookEntry INT ) BEGIN UPDATE ledgerCompany SET bookEntry = LAST_INSERT_ID(bookEntry + 1) WHERE fiscalYear = vFiscalYear; SET vNewBookEntry = LAST_INSERT_ID(); END$$ DELIMITER ;