0

I've created a test table, then a Type Table and then a SP:

CREATE TABLE prueba (

    id int IDENTITY,
    datos varchar (20),
    nums NUMERIC (10,2)
    CONSTRAINT PK_PRUEBA PRIMARY KEY (id)
)

CREATE TYPE dbo.pruebatable AS TABLE (

    datos varchar (20),
    nums NUMERIC (10,2)
)

CREATE PROC spruebatable
@test pruebatable READONLY
AS
BEGIN
INSERT INTO prueba (datos,nums)
SELECT 
datos, nums
FROM @test

END;

And in python, I'm trying to calls this with a private connection function that works fine:

from haegpi import sqlconn

cursor = sqlconn()

var = ('int',1)
sql = "{CALL spruebatable (?)}"
cursor.execute (sql,var)

I've tried to send it as tuple, list and result is the same. Any clues?

8
  • 2
    Try var = [('int',1)] Commented Apr 26, 2023 at 13:35
  • Hi there Gord! I've tried that but i receive this current error : "pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC SQL Server Driver]Tipo de datos SQL no válido (0) (SQLBindParameter)')" Commented Apr 26, 2023 at 13:58
  • Hmm, okay … try var = ([('int', 1)],) Commented Apr 26, 2023 at 14:32
  • Thanks Gordon, but same same: "pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC SQL Server Driver]Tipo de datos SQL no válido (0) (SQLBindParameter)')" I still cant find the solution. Commented Apr 26, 2023 at 15:02
  • 1
    print(connection.getinfo(pyodbc.SQL_DRIVER_NAME)). If it shows SQLSRV32.DLL then you are using the ancient driver regardless of the date stamp on the DLL file. Commented Apr 26, 2023 at 15:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.