Project

General

Profile

write-trigger-test5.p

Ovidiu Maxiniuc, 12/16/2013 03:21 PM

Download (2.36 KB)

 
1
/* call counter */
2
define var i as integer no-undo init 0.
3
function x return char () :
4
    i = i + 1.
5
    return string(i).
6
end function.
7

    
8

    
9
on find   of book display x() "Session trigger FIND for" book.isbn with no-label no-box.
10
on write  of book old bold display x() "Session trigger WRITE for" book.isbn "old" bold.isbn with no-label no-box.
11
on create of book display x() "Session trigger CREATE for" book.isbn with no-label no-box.
12
on delete of book display x() "Session trigger DELETE for" book.isbn with no-label no-box.
13
on assign of book.isbn old bisbn display x() "Session trigger ASSIGN for" book.isbn "old" bisbn with no-label no-box.
14

    
15
procedure ppp1 :
16
    display x() "    Inside procedure start" with frame f0 with no-box.
17
    do transaction:
18
        display x() "        Inner transaction start" with frame f1 with no-box.
19
        create book.
20
        display x() "        Inner transaction end" with frame f2 with no-box.
21
    end.
22
    book.publisher = "me".
23
    display x() "    Inside procedure end" with frame f3 with no-box.
24
end.
25

    
26
do /*transaction*/:
27
    display x() "  Outer transaction start" with frame f4 with no-box.
28
    run ppp1.
29

    
30
    display x() "  Outer transaction continue" with frame f5 with no-box.
31
    book.isbn = "111".
32
    book.book-id = 111.
33

    
34
    create book.
35
    book.isbn = "222".
36
    book.book-id = 222.
37
    display x() "  Outer transaction end" with frame f6 with no-box.
38
end.
39

    
40
display x() "Top scope continue " with frame f7 with no-box.
41

    
42
find first book where isbn = "222".
43
delete book.
44

    
45
find first book where isbn = "111".
46
delete book.
47

    
48
display x() "Top scope end" with frame f8 with no-box.
49

    
50

    
51

    
52
/*
53
   Expected output:
54

    
55
1          Outer transaction start
56
2            Inside procedure start
57
3                Inner transaction start
58
4        Session trigger CREATE for
59
5                Inner transaction end
60
6            Inside procedure end
61
7          Outer transaction continue
62
8        Session trigger ASSIGN for 111             old
63
9        Session trigger WRITE for 111             old
64
10       Session trigger CREATE for
65
11       Session trigger ASSIGN for 222             old
66
12         Outer transaction end
67
13       Top scope continue
68
14       Session trigger WRITE for 222             old
69
15       Session trigger FIND for 222
70
16       Session trigger DELETE for 222
71
17       Session trigger FIND for 111
72
18       Session trigger DELETE for 111
73
19       Top scope end
74
*/