MySQL Forums
Forum List  »  French

Procedure stocké d'insertion
Posted by: Oumar TOURE
Date: March 28, 2017 11:07AM

Bonjour à tous,
Merci de m'assister car ma procedure stocké ci-dessous me renvoi une erreur lors de sa création.

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



Le messare d'eurreur est :

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT null, motifDemamde,vehicule, demandeur, CONCAT(prefixe, '-', LPA' at line 15

Options: ReplyQuote


Subject
Views
Written By
Posted
Procedure stocké d'insertion
1427
March 28, 2017 11:07AM
653
March 28, 2017 03:55PM


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.