SQL - Recordset cerrado

 
Vista:

Recordset cerrado

Publicado por Xavier Aviles (2 intervenciones) el 28/10/2005 00:54:11
Tengo un store procedure que retorna 2 recordset. (USo SQL 2000) y VB 6.
Al ejecutar en el Query Analizer retorna los dos recordsets. Pero desde Visual BAsic me sale el mensaje de error 3704 "La operacion no esta permitida si el objeto esta cerrado".
He verificado todas las posibles causa y revisado cuidadosamente el llamado al Store Proc.
Copio los tres SP que uso:
Tarbajan en este orden.
LLamo incialmente spReturnMovimientos :
Create Procedure spReturnMovimientos
as
declare @tipomov char(1),@mc varchar(6) ,@secuencia varchar(6), @cod_item varchar(6), @fecmov datetime, @cantidad decimal(9,2)
DECLARE cregistros CURSOR FOR

select tipomov,mc,secuencia,cod_item, fecmov,cantidad from dbinventari
where (tipomov = 'I' or tipomov = 'J' or tipomov = 'P') and status = '0' and ingresado = '1' and
diario= '1'
order by fecmov, tipomov,cast(mc as int), cast(secuencia as int)

delete tmpobs
insert tmpobs
select distinct tipomov,mc,'' from dbinventari
where (tipomov = 'I' or tipomov = 'J' or tipomov = 'P') and
status = '0' and ingresado = '1' and diario= '1'
order by tipomov,mc

OPEN cregistros

FETCH NEXT FROM cregistros
INTO @tipomov ,@mc ,@secuencia , @cod_item,@fecmov ,@cantidad

WHILE @@FETCH_STATUS = 0
BEGIN
Exec VerifyStockToDate @tipomov,@mc,@secuencia,@cod_item,@fecmov
FETCH NEXT FROM cregistros
INTO @tipomov ,@mc ,@secuencia , @cod_item,@fecmov ,@cantidad
END

CLOSE cregistros
DEALLOCATE cregistros

Select distinct inv.tipomov,inv.mc,inv.fecmov,ven.name,fac.refnbr,tmp.obs
from dbinventari inv inner join dbfactur fac
on inv.cod_factur= fac.mc inner join dbvendor ven
on fac.vendorid = ven.vendorid left join tmpobs tmp
on inv.tipomov=tmp.tipomov and inv.mc=tmp.mc
where (inv.tipomov= 'J' or inv.tipomov= 'I' or inv.tipomov= 'P')
and inv.status = '0' and inv.ingresado = '1' and inv.diario= '1'

Select distinct tipomov,mc,fecmov from dbinventari
where (tipomov='S' or tipomov='R' or tipomov='U')
and status = '0' and ingresado = '1' and diario= '1'
GO
*****************************************
Gracias anticipadas
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Recordset cerrado

Publicado por Isaías (5072 intervenciones) el 28/10/2005 01:09:12
Despues del AS, coloca SET NOCOUNT ON.

Sin saber que hace tu codigo, no te recomiendo que utilices CURSORES.

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar