MySQL Forums
Forum List  »  French

Re: Immatriculation véhicules
Posted by: Oumar TOURE
Date: March 28, 2017 10:30AM

Salut
Merci Benoit pour ta solution, elle marche a merveille.
Mais en ajoutant cela à ma procedure stoker, ça me donne des erreurs.

CREATE DEFINER=`root`@`localhost` PROCEDURE `formulairedemamde_Insert`(motifDemamde varchar(100),vehicule INT,demandeur INT,immatriculationNumber varchar(45),creationUserId INT)
BEGIN
INSERT INTO `gesparc`.`formulairedemamde`(
`id`,
`motifDemamde`,
`vehicule`,
`demandeur`,
`immatriculationNumber`,
`creationDate`,
`creationUserId`,
`lastModifdate`,
`lastmodifUserId`)
VALUES
(
SELECT
null,
motifDemamde,vehicule,
demandeur,
CONCAT(prefixe, '-', LPAD(IF(numero=9999, 0, numero+1), 4, '0'), '-', IF(numero=9999, prochain_suffixe, suffixe)) AS nouvelle_plaque ,
CURRENT_TIMESTAMP,
creationUserId,
CURRENT_TIMESTAMP,
creationUserId
FROM
(
SELECT immatriculationNumber, MID(immatriculationNumber, 1, 2) AS prefixe, (MID(immatriculationNumber, 4, 4) + 0) AS numero, MID(immatriculationNumber, 9, 2) AS suffixe, IF(MID(immatriculationNumber, 10, 1)='Z', CONCAT(CHAR(ASCII(MID(immatriculationNumber, 9, 1)) + 1), 'A'), CONCAT(MID(immatriculationNumber, 9, 1), CHAR(ASCII(MID(immatriculationNumber, 10, 1)) + 1))) AS prochain_suffixe
FROM formulairedemamde
ORDER BY suffixe DESC, numero DESC
LIMIT 1
) t
);
END

Options: ReplyQuote


Subject
Views
Written By
Posted
2868
March 28, 2017 03:25AM
946
March 28, 2017 03:42AM
889
March 28, 2017 03:57AM
979
March 28, 2017 03:56AM
1064
March 28, 2017 04:02AM
1109
March 28, 2017 04:47AM
999
March 28, 2017 05:15AM
955
March 28, 2017 05:23AM
Re: Immatriculation véhicules
1018
March 28, 2017 10:30AM
906
March 28, 2017 05:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.