récupération de parametres en sortie d'une SP
Salut,
J'ai une procédure stockée relativement simple, mais cet après midi, j'ai peut-être de la m... dans les yeux, mais je n'arrive pas à récupérer le paramètre en sortie !!!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| CREATE PROC P_LFB_GetNumSerie
(
@TPT_ID_K numeric(5),
@CPT_ID_K numeric(5),
@NumSerie CHAR(15) OUTPUT
)
AS
DECLARE
@NumMax CHAR(15),
@NumDispo CHAR(15),
@Pas numeric(4)
BEGIN TRANSACTION GetNumSerie
SELECT @Pas=TR_PAS, @NumDispo=TR_NUM_DISPO, @NumMax=TR_NUM_FIN FROM TJ_TRANCHE WHERE TR_CPT_ID_FK_K=@CPT_ID_K AND TR_TPT_ID_FK_K=@TPT_ID_K
IF @@ERROR<>0 OR @@ROWCOUNT<>1
BEGIN
ROLLBACK TRANSACTION GetNumSerie
SElecT @NumSerie = '' ;
Raiserror('Erreur dans "P_LFB_GetNumSerie". La tranche demandée (cpt=%d,tpt=%d) n''a pas été trouvée ou a provoqué une erreur.',16,1,@CPT_ID_K,@TPT_ID_K)
return
END
ELSE
BEGIN
IF (convert(numeric(9),@NumDispo) + @Pas)> convert(numeric(9),@NumMax)
BEGIN
ROLLBACK TRANSACTION GetNumSerie
SElecT @NumSerie = '' ;
Raiserror('Erreur dans "P_LFB_GetNumSerie". La tranche demandée (cpt=%d,tpt=%d) n''a plus de numéros disponibles.',16,1,@CPT_ID_K,@TPT_ID_K)
return
END
ELSE
BEGIN
select @NumSerie=@NumDispo
UPDATE TJ_TRANCHE SET TR_NUM_DISPO = convert(CHAR(15),convert(numeric(9),@NumDispo) + @Pas) WHERE TR_CPT_ID_FK_K=@CPT_ID_K AND TR_TPT_ID_FK_K=@TPT_ID_K
IF @@ERROR <> 0 OR @@ROWCOUNT <> 1
BEGIN
ROLLBACK TRANSACTION GetNumSerie
SElecT @NumSerie = '' ;
Raiserror('Erreur dans "P_LFB_GetNumSerie". La mise à jour de la tranche demandée (cpt=%d,tpt=%d) n''a pas réussie ou a provoqué une erreur.',16,1,@CPT_ID_K,@TPT_ID_K)
return
END
ELSE
BEGIN
COMMIT TRANSACTION GetNumSerie
END
END
END
GO |
Dans l'analyseur de requête, voici ce que je tape :
Code:
1 2 3
| declare @NumMia char(15)
exec P_LFB_GetNumSerie 2,33,@NumMia ;
select 'Numéro mia = ' + @NumMia as NumMia |
Citation:
Envoyé par Analyseur de requête
(1 ligne(s) affectée(s))
NumMia
----------------------------
NULL
(1 ligne(s) affectée(s))
Vous voyez quelque chose qui cloche ? 8O