Ver Mensaje Individual
  #6  
Antiguo 30-03-2010
Avatar de LuNaTk
LuNaTk LuNaTk is offline
Miembro
 
Registrado: jun 2007
Posts: 19
Reputación: 0
LuNaTk Va por buen camino
Los eventos los tengo programados en botones:

Código Delphi [-]
CDSC_Nivel.Insert;
Código Delphi [-]
CDSC_Nivel.Delete;
Código Delphi [-]
CDSC_Estado.Edit;
Código Delphi [-]
CDSC_Estado.Post;

Y en los eventos del ClientDataSet :

Código Delphi [-]
procedure TFC_Estado.CDSC_EstadoAfterDelete(DataSet: TDataSet);
begin
     CDSC_Estado.ApplyUpdates(0);
end;

Código Delphi [-]
procedure TFC_Estado.CDSC_EstadoAfterPost(DataSet: TDataSet);
begin
     CDSC_Estado.ApplyUpdates(0);
     CDSC_Estado.Refresh;
end;

Código Delphi [-]
procedure TFC_Estado.CDSC_EstadoReconcileError(DataSet: TCustomClientDataSet;
  E: EReconcileError; UpdateKind: TUpdateKind; var Action: TReconcileAction);
begin
 case UpdateKind of
       ukModify:
               begin
                    //ShowMessage(E.message);
                    Application.MessageBox('Error al Modificar el Registro','Error', MB_ICONERROR);
                    Action := raCancel;
               end;
      ukInsert:
               begin
                    //ShowMessage(E.message);
                    Application.MessageBox('Error al Guardar el Registro','Error', MB_ICONERROR);
                    Action := raCancel;
               end;
      ukDelete:
               begin
                    //ShowMessage(E.message);
                    Application.MessageBox('Error al Eliminar el Registro','Error', MB_ICONERROR);
                    Action := raCancel;
               end;
 end;
end;

El problema no creo que sea esta parte, ya que sin el trigger en la tabla, funciona adecuadamente. Pero al agregar el trigger, me devuelve el error y no me actualiza la tabla.

Este es el código de los triggers

Un trigger de insercion que lo unico que hace es agregar registros a otra tabla.
Código:
 
alter trigger tg_i_permiso_nivel
on
c_nivel
after insert
as
--Al insertar un nuevo nivel de usuario se inserta la lista de formas en el proyecto delphi
--Por default todos los permisos estan desactivados y habra que ir activandolos uno a uno.
insert into nivel_permiso
select (select niv_id from inserted),
cfo_id,
cat_id,
0,
0,
0,
0,
0 
from c_forma
insert into cat_permiso
select (select niv_id from inserted),
cat_id,
0
from c_categoria
Y un trigger mas que elimina los registros insertados por el trigger anterior al eliminar el registro de la tabla.

Código:
create trigger tg_d_categoria_forma
on c_nivel
INSTEAD OF delete
as
if not exists(select niv_id from control where niv_id=(select niv_id from deleted))
   begin
   delete from cat_permiso where niv_id=(select niv_id from deleted)
   delete from nivel_permiso where niv_id=(select niv_id from deleted)
      delete from c_nivel where niv_id=(select niv_id from deleted)
   end
else
  raiserror('No se puede eliminar el nivel de usuario porque esta actualmente asignado',16,1)

Última edición por LuNaTk fecha: 30-03-2010 a las 03:14:29. Razón: Mal formato
Responder Con Cita