1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] The code runs completely in SQL but incompletely in Python [closed]

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I'm executing a SQL procedure on SQL Server for each line on my table. When I execute in SQL it runs every line. When I execute the same code in Python it executes only for around 10 lines and it closes (not pointing out any error). What could be the problem?

    My code:

    BEGIN
    SET NOCOUNT ON
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
    DECLARE @pedido_id INT = 0
    DECLARE c CURSOR FOR
    SELECT a.pedido_id
    FROM TABLE_SQL a
    order by a.pedido_id desc
    OPEN c
    FETCH FROM c INTO @pedido_id
    WHILE @@FETCH_STATUS = 0
    BEGIN
    exec PROCEDURE_SQL @pedido_id
    FETCH NEXT FROM c INTO @pedido_id
    END
    CLOSE c
    DEALLOCATE c
    END


    I tried to execute code on SQL and it worked, but didn't work completely in Python (only for the first lines).

    I tried to change SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED for Read Committed, and other different levels but the result is the same.

    Continue reading...

Compartilhe esta Página