trigger5.test 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # The author disclaims copyright to this source code. In place of
  2. # a legal notice, here is a blessing:
  3. #
  4. # May you do good and not evil.
  5. # May you find forgiveness for yourself and forgive others.
  6. # May you share freely, never taking more than you give.
  7. #
  8. #***********************************************************************
  9. #
  10. # This file tests the triggers of views.
  11. #
  12. set testdir [file dirname $argv0]
  13. source $testdir/tester.tcl
  14. ifcapable {!trigger} {
  15. finish_test
  16. return
  17. }
  18. # Ticket #844
  19. #
  20. do_test trigger5-1.1 {
  21. execsql {
  22. CREATE TABLE Item(
  23. a integer PRIMARY KEY NOT NULL ,
  24. b double NULL ,
  25. c int NOT NULL DEFAULT 0
  26. );
  27. CREATE TABLE Undo(UndoAction TEXT);
  28. INSERT INTO Item VALUES (1,38205.60865,340);
  29. CREATE TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW
  30. BEGIN
  31. INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES ('
  32. || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');';
  33. END;
  34. DELETE FROM Item WHERE a = 1;
  35. SELECT * FROM Undo;
  36. }
  37. } {{INSERT INTO Item (a,b,c) VALUES (1,38205.60865,340);}}
  38. integrity_check trigger5-99.9
  39. finish_test