denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
MIT License
192 stars 53 forks source link

callproc returns input parameters instead of output parameters #81

Closed lostformars closed 6 years ago

lostformars commented 6 years ago

callproc returns what should be the procedure's output parameters from self._session.output_params.items(). However, when I call callproc the output contains the unchanged parameters that I send into the procedure.

The procedure below has 2 output parameters and should change the value of the first parameter. If I only send the first parameter then the output only includes the first input parameter. If I send both I get both returned (unchanged).

CREATE PROCEDURE dbo.TestOutParam (
    @outParam INT OUTPUT,
    @outParam2 INT = NULL OUTPUT
) 
AS 
BEGIN 
    SET @outParam = 1;
END;
GO
>>> cur.callproc("dbo.TestOutParam",(2,))
[2]
>>> cur.callproc("dbo.TestOutParam",(2,2))
[2, 2]
denisenkom commented 6 years ago

You need to declare output parameter properly, see example: https://github.com/denisenkom/pytds/blob/master/tests/all_test.py#L478