DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_cloneHeader`( vSelf INT, OUT vNewEntryFk INT, vTravelFk INT ) BEGIN /** * Clones an entry header. * * @param vSelf The entry id * @param OUT vNewEntryFk The new entry id * @param vTravelFk Travel for the new entry or %NULL to use the source entry travel */ INSERT INTO entry( travelFk, supplierFk, dated, isExcludedFromAvailable, isRaid, commission, currencyFk, companyFk, clonedFrom, typeFk ) SELECT IFNULL(vTravelFk, travelFk), supplierFk, dated, isExcludedFromAvailable, isRaid, commission, currencyFk, companyFk, vSelf, typeFk FROM entry WHERE id = vSelf; SET vNewEntryFk = LAST_INSERT_ID(); END$$ DELIMITER ;