Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Passing arguments by reference
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.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement