merlinthemago
Programmer
Hi Everybody!
I need understand the LOCK of SQL. I´m development a program with instructions of SQL Syntax. Imagine, Client A and Client B, for the routine below:
MOVE POW-NUMERIC OF FCODIGO TO WS-CODIGO-SQL
EXEC SQL
DECLARE EDT CURSOR FOR
SELECT CODIGO, DESCRICAO FROM NATUREZAS WHERE CODIGO = :WS-CODIGO-SQL
END-EXEC
EXEC SQL
WHENEVER SQLERROR GO TO-ERROR
END-EXEC.
P-START.
EXEC SQL
OPEN EDT
END-EXEC
EXEC SQL
FETCH EDT INTO :TNAT-CODIGO, :TNAT-DESCRICAO
END-EXEC
EXEC SQL
CLOSE EDT
END-EXEC
CALL "MOVE-DATA"
CALL "ENABLE-DATA"
GOBACK.
P-ERROR.
DISPLAY SQLSTATE SQLCODE
GOBACK
Well, when Client A, get the data, for exemple, CODIGO = 5, and Client B, execute the same program with the CODIGO = 5, the LOCK occurs at SQLServer. This is correct, because the Client B, will not be able alter this data while the Client A liberate the data. Occurs that, when the program execute the instruction EXEC SQL FETCH EDT INTO :TNAT-CODIGO, :TNAT-DESCRICAO END-EXEC, my application for Client B, stop and i don´t have more controller above my program. I obtain to controller again, when the Client A desists of data, with ROLLBACK or COMMIT instructions. I question: Exists any configuration for execute in the SQL Server?!
Thanx for cooperation!
Nicola Losacco
From Brazil
I need understand the LOCK of SQL. I´m development a program with instructions of SQL Syntax. Imagine, Client A and Client B, for the routine below:
MOVE POW-NUMERIC OF FCODIGO TO WS-CODIGO-SQL
EXEC SQL
DECLARE EDT CURSOR FOR
SELECT CODIGO, DESCRICAO FROM NATUREZAS WHERE CODIGO = :WS-CODIGO-SQL
END-EXEC
EXEC SQL
WHENEVER SQLERROR GO TO-ERROR
END-EXEC.
P-START.
EXEC SQL
OPEN EDT
END-EXEC
EXEC SQL
FETCH EDT INTO :TNAT-CODIGO, :TNAT-DESCRICAO
END-EXEC
EXEC SQL
CLOSE EDT
END-EXEC
CALL "MOVE-DATA"
CALL "ENABLE-DATA"
GOBACK.
P-ERROR.
DISPLAY SQLSTATE SQLCODE
GOBACK
Well, when Client A, get the data, for exemple, CODIGO = 5, and Client B, execute the same program with the CODIGO = 5, the LOCK occurs at SQLServer. This is correct, because the Client B, will not be able alter this data while the Client A liberate the data. Occurs that, when the program execute the instruction EXEC SQL FETCH EDT INTO :TNAT-CODIGO, :TNAT-DESCRICAO END-EXEC, my application for Client B, stop and i don´t have more controller above my program. I obtain to controller again, when the Client A desists of data, with ROLLBACK or COMMIT instructions. I question: Exists any configuration for execute in the SQL Server?!
Thanx for cooperation!
Nicola Losacco
From Brazil