xref: /sqlite-3.40.0/test/trigger5.test (revision 00afe0b3)
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
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15
16# Ticket #844
17#
18do_test trigger5-1.1 {
19  execsql {
20    CREATE TABLE Item(
21       a integer PRIMARY KEY NOT NULL ,
22       b double NULL ,
23       c int NOT NULL DEFAULT 0
24    );
25    CREATE TABLE Undo(UndoAction TEXT);
26    INSERT INTO Item VALUES (1,38205.60865,340);
27    CREATE TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW
28    BEGIN
29      INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES ('
30       || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');';
31    END;
32    DELETE FROM Item WHERE a = 1;
33    SELECT * FROM Undo;
34  }
35} {{INSERT INTO Item (a,b,c) VALUES (1,38205.60865,340);}}
36
37integrity_check trigger5-99.9
38
39finish_test
40