Ver Mensaje Individual
  #3  
Antiguo 05-02-2010
Avatar de richy08
richy08 richy08 is offline
Miembro
 
Registrado: may 2007
Ubicación: Bucerias, Nayarit Mexico
Posts: 529
Reputación: 17
richy08 Va por buen camino
efectivamente los campos donde recupero y guardo son datetime este es el procedimiento almacenado
Código SQL [-]
et ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[Frm_ProRellExcRatFillExcRat] (@Dtp_ArrDat datetime, @Dtp_deda datetime, @excrat float)
as 
declare 
 @nconf int, @darrivaldate datetime, @ddeparturedate datetime, @nrenpost int, @nrenpost1 int, @fechaAum datetime
begin
    Declare Qry_Busnconf Cursor For
    select nconf, darrivaldate, ddeparturedate from reserve 
    where @Dtp_ArrDat between darrivaldate and ddeparturedate
    open Qry_Busnconf
    FETCH NEXT from Qry_Busnconf into @nconf, @darrivaldate, @ddeparturedate
    while @@fetch_status = 0
    begin
         Declare Qry_Busnrenpost Cursor For
         select nrenpost from posteosgue p, renposteosguecon r 
         where p.npost=r.npost and nconf=@nconf
         and nexcrat is null and dfech=@Dtp_ArrDat

         open Qry_Busnrenpost
            
         FETCH NEXT from Qry_Busnrenpost into @nrenpost

         while @@fetch_status = 0
         begin
            --Qry_ModiExcrat
            update renposteosguecon set nexcrat=@excrat
            where nrenpost=@nrenpost
            --Qry_ModiExcrat

         FETCH NEXT from Qry_Busnrenpost into @nrenpost
         end
         close Qry_Busnrenpost
         deallocate Qry_Busnrenpost
      
             set @fechaAum= (DATEADD(day, 2, @Dtp_ArrDat))
             print @fechaAum
             print @ddeparturedate 
             print '**************'
         if  @fechaAum=@ddeparturedate 
         begin
              print 'adentro'
              print @ddeparturedate
             --print '**************'
             Declare Qry_Busnrenpost1 Cursor For
             select nrenpost from posteosgue p, renposteosguecon r 
             where p.npost=r.npost and nconf=@nconf
             and nexcrat is null and dfech=@ddeparturedate

             open Qry_Busnrenpost1
            
             FETCH NEXT from Qry_Busnrenpost1 into @nrenpost1
             print @nrenpost1
             
             while @@fetch_status = 0
             begin
                print @nrenpost1
                --Qry_ModiExcrat
                update renposteosguecon set nexcrat=@excrat
                where nrenpost=@nrenpost1
                --Qry_ModiExcrat

             FETCH NEXT from Qry_Busnrenpost1 into @nrenpost1
             end
             close Qry_Busnrenpost1
             deallocate Qry_Busnrenpost1
         end;     
    FETCH NEXT from Qry_Busnconf into @nconf, @darrivaldate, @ddeparturedate
    end
    close Qry_Busnconf
    deallocate Qry_Busnconf
end

y lo mando llamar desde delphi con un stored procedured de ado de esta forma

Código Delphi [-]
SP_FillExcrat.Close;
SP_FillExcrat.Prepared:=true;
SP_FillExcrat.Parameters[1].Value:=FormatDateTime('yyyy,mm,dd',Dtp_ArrDat.date);
SP_FillExcrat.Parameters[2].Value:=FormatDateTime('yyyy,mm,dd',Dtp_DeDa.date);
SP_FillExcrat.Parameters[3].Value:=Md_Gral.Qry_KindChan.fieldbyname('Kind').Value;
SP_FillExcrat.ExecProc;

lo extraño es que las primeras insercciones si las hace de manera correcta pero al llegar al if

Código SQL [-]
             set @fechaAum= (DATEADD(day, 2, @Dtp_ArrDat))
             print @fechaAum
             print @ddeparturedate 
             print '**************'
             if  @fechaAum=@ddeparturedate 
             begin

si entra pero el cursor no encuentra ningun registro aunque yo los estoy viendo en la base de datos alguna idea de cual pueda ser la razon gracias por tu tiempo
Responder Con Cita