Project

General

Profile

temp-table-index.p

full testcase for temp-table - Ovidiu Maxiniuc, 04/03/2014 03:26 PM

Download (2.72 KB)

 
1
define temp-table tmp-novel
2
    field id as integer
3
    field chapter1 as character
4
    field chapter2 as character
5
    field chapter3 as character
6
    field chapter4 as character
7
    field chapter5 as character
8
    field chapter6 as character
9
    field chapter7 as character
10
    field a-date   as date          init today
11
    field a-int    as integer       init 789846
12
    field a-int64  as int64         init 54698461165469876
13
    field a-logical as logical      init false
14
    field a-datetime as datetime    init now
15
    field a-dtz     as datetime-tz  init ?
16
    index idx_content16 as unique 
17
        /*a-dtz a-date a-datetime  a-int  a-int64 a-logical*/ a-int64
18
        chapter1 chapter2 chapter3 chapter4 chapter5 chapter6
19
    index idx_chapter7 chapter7.
20
    
21
create tmp-novel.
22
chapter1 = "0123456789 234567890 234567890".
23
chapter2 = chapter1 + chapter1.
24
chapter3 = chapter2 + chapter2.
25
chapter4 = chapter3 + chapter3.
26
chapter5 = chapter4 + chapter4.
27
chapter6 = chapter5 + chapter5.
28
chapter7 = chapter1 + chapter2 + chapter3 + chapter4 + chapter5 + chapter6.
29

    
30
/* 1890 characters in both indexes */
31
display "current index size : "
32
    length(chapter1) + length(chapter2) + length(chapter3) +
33
        length(chapter4) + length(chapter5) + length(chapter6)
34
    length(chapter7) skip.
35
            
36
define variable tmp as char no-undo.
37
tmp = chapter1.
38

    
39

    
40
repeat while true on error undo, leave:
41
   
42
    display tmp 
43
            length(tmp) + length(chapter2) + length(chapter3) + 
44
                length(chapter4) + length(chapter5) + length(chapter6).
45
    tmp = tmp + "x".
46
    
47
    /* compute the max for composed (chapter1..6) index */
48
    assign chapter1 = tmp no-error.
49
    validate tmp-novel no-error. /* must validate to update the index */
50

    
51
    IF ERROR-STATUS:ERROR OR ERROR-STATUS:NUM-MESSAGES > 0 THEN DO:
52
        Display "iiiiii" ERROR-STATUS:NUM-MESSAGES + 0.
53
        message "got error for " length(tmp)  length(chapter1).
54
        pause.
55
        leave.
56
    ENd.
57
end.
58
display tmp length(tmp) skip.
59

    
60

    
61

    
62
tmp = chapter7.
63
repeat while true /* on error undo, leave */ :
64

    
65
    display tmp length(tmp) length(chapter7).
66
    tmp = tmp + "x".
67
    
68
    /* compute the max for simple index */
69
    assign chapter7 = tmp no-error.
70
    /* in the case of the uni-fielded index, no validation is necessary */
71
        
72
    IF ERROR-STATUS:ERROR OR ERROR-STATUS:NUM-MESSAGES > 0 THEN DO:
73
        Display "ooooo" ERROR-STATUS:NUM-MESSAGES + 0.
74
        message "got error for " length(tmp)  length(chapter7).
75
        pause.
76
        leave.
77
    ENd.
78
end.
79

    
80
display "maximum index size : "
81
    length(chapter1) + length(chapter2) + length(chapter3) +
82
    length(chapter4) + length(chapter5) + length(chapter6) label "compose index"
83
    length(chapter7) label "single-field index" skip.
84
    
85
    
86