No entiendo como se manejan los cursores en un procedimiento almacenado.
Este es el procedimiento que da el error.
Código SQL
[-]CREATE PROCEDURE CALC_CUENTACORRIENTE (
PCOD_CLIENTE INTEGER)
AS
DECLARE VARIABLE HABER FLOAT;
DECLARE VARIABLE DEBE FLOAT;
DECLARE VARIABLE ID INTEGER;
DECLARE VARIABLE TMP_SALDO FLOAT = 0;
declare variable statuscta varchar(1);
declare variable limitesaldo float;
begin
TMP_SALDO = 0;
for select ID, DEBE, HABER from CLIENTES_CUENTA
where COD_CLIENTE =:PCOD_CLIENTE
and (cerrado = '0')
order by fecha,id
into :ID, : DEBE, :HABER
do begin
if (NOT : DEBE IS NULL) then TMP_SALDO = :TMP_SALDO + : DEBE;
if (NOT :HABER IS NULL) then TMP_SALDO = :TMP_SALDO - :HABER;
UPDATE clientes_cuenta SET SALDO=:TMP_SALDO WHERE ID = :ID;
end
update clientes set saldo_cta = :tmp_saldo
where cod_cliente = : pcod_cliente;
select LIMITE_CTA, OPERA_CTACTE from clientes
where cod_cliente = :PCOD_CLIENTE
into :limitesaldo, :statuscta;
if (:tmp_saldo >= :limitesaldo) then
begin
update clientes set OPERA_CTACTE = '0'
where cod_cliente = :PCOD_CLIENTE;
end
else begin
if (:statuscta = '0') then
begin
update clientes set OPERA_CTACTE = '1'
where cod_cliente = :PCOD_CLIENTE;
end
end
end
El error se produce incluso en el entorno de desarrollo. Este código esta de hace tiempo y nunca tenia problemas, incluso funciona bien, es decir, hace lo que tiene que hacer.
Ademas hay otros SP que estan teniendo el mismo problema y otros que funcionan bien...
¿alguna idea ? Gracias.