Jump to content


Photo

Trigger after update para limpiar campo fecha


  • Please log in to reply
4 replies to this topic

#1 luk2009

luk2009

    Advanced Member

  • Moderadores
  • PipPipPip
  • 2040 posts
  • LocationSanto Domingo

Posted 01 February 2011 - 08:12 PM

puse esto en ibexpert, para ver que tal


sql
  1. CREATE TRIGGER cobros_aiu0 FOR cobros
  2. active after INSERT OR UPDATE POSITION 0
  3. AS
  4. BEGIN
  5. IF (NEW.ESTATUS='LLAMAR') THEN
  6. NEW.FECHA_COBRO =' ';
  7. ELSE
  8. NEW.FECHA_LLAMADA=' ';
  9. END



y me sale el siguiente error:

This column cannot be updated because it is derived from an SQL function or expression.
attempted update of read-only column.


Dos preguntas:
a) cual es la forma correcta de limpiar un campo fecha?
b) Porque me da ese error?


  • 0

#2 luk2009

luk2009

    Advanced Member

  • Moderadores
  • PipPipPip
  • 2040 posts
  • LocationSanto Domingo

Posted 01 February 2011 - 08:27 PM

lo puse before insert  asi:



sql
  1. CREATE OR ALTER TRIGGER COBROS_BIU0 FOR COBROS
  2. ACTIVE BEFORE INSERT OR UPDATE POSITION 0
  3. AS
  4. BEGIN
  5. IF (NEW.ESTATUS='LLAMAR') THEN
  6. NEW.FECHA_COBRO =NULL;
  7. ELSE
  8. NEW.FECHA_LLAMADA=NULL;
  9. END
  10. ^
  11.  
  12.  
  13. SET TERM ; ^



y funciona correctamente.

cualquier llamada de atencion será escuchada calmadamente  8o| (li)
  • 0

#3 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14459 posts
  • LocationMéxico

Posted 01 February 2011 - 08:36 PM

cualquier llamada de atencion será escuchada calmadamente  8o| (li)


A veces lo más sencillo es lo más dificil amigo Luciano, usted no se fije (y)

Salud OS
  • 0

#4 Rolphy Reyes

Rolphy Reyes

    Advanced Member

  • Moderadores
  • PipPipPip
  • 2092 posts
  • LocationRepública Dominicana

Posted 02 February 2011 - 07:52 AM

Saludos.

Tomar en cuenta lo siguiente:

OLD Context Variables Now Read-only
D. Yemanov
The set of OLD context variables available in trigger modules is now read-only. An attempt to assign a value
to OLD.something will be rejected.
Note
NEW context variables are now read-only in AFTER-triggers as well.


Página 96.
  • 0

#5 luk2009

luk2009

    Advanced Member

  • Moderadores
  • PipPipPip
  • 2040 posts
  • LocationSanto Domingo

Posted 02 February 2011 - 10:00 AM

Gracias rolphy por la informacion
  • 0




IP.Board spam blocked by CleanTalk.