Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing arguments by reference
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00941576
Message ID:
00941583
Vues:
8
The output parameters represent what you're calling "passing parameters by reference". You've to specify OUTPUT for output parameters in the call to SP. I'm not sure why you want to pass the same variable as both parameters. You can just use one OUTPUT parameter to pass value in and get result out, if it's your goal.
EXEC USP_O_MYPROC @tata, @tata OUTPUT
>I'm trying to call a SP (from another SP) with arguments that needs to be modified by the called SP.
>
>I could not find references on passing arguments by reference, so I tried with the OUTPUT argument modifier. Here is a simple example to explain my approach.
>
>USP_O_MYPROC @ORIGINAL_VALUE INT, @NEW_VALUE INT OUTPUT
>...
>...
>SET @NEW_VALUE = @ORIGINAL_VALUE + 1 !!! complex ;-)
>IF @NEW_VALUE IS NULL SET @NEW_VALUE = 0 !!! you'll see why later...
>RETURN
>
>
>When I call the SP, I simply do:
>EXEC USP_O_MYPROC @tata, @tata
>
>I tough that by doing so, @tata whould containt it's original value + 1...
>But @tata is null !!!! I'm puzzled ;-)
>
>The IF @NEW_VALUE IS NULL SET @NEW_VALUE = 0 line does not even change a thing...
>
>
>So what am I doing wrong here ;-)
>
>
>Thanks.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform