-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathersdu2-output-1.tcl
118 lines (86 loc) · 2.32 KB
/
ersdu2-output-1.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package require tclodbc
# ===============================================
proc LogWrite { s } {
# ===============================================
global rf
if {![info exists rf]} { return }
if {$rf==""} { return }
puts $rf $s
}
# ===============================================
proc LogFlush { } {
# ===============================================
global rf
if {![info exists rf]} { return }
if {$rf==""} { return }
flush $rf
}
# ===============================================
proc CreateSp { } {
# ===============================================
global db1
global db2
set ph [info script]
if {$ph==""} {
set ph [ pwd ]
} else {
set ph [file dirname $ph ]
}
foreach {r3} [ db2 "select ID ,NAME from da_cat where id_type = 4" ] {
set id [lindex $r3 0]
set name [lindex $r3 1]
set tempname $name
regsub -all "<" $tempname "(" tempname
regsub -all ">" $tempname ")" tempname
regsub -all "/" $tempname "_" tempname
regsub -all {\\} $tempname "_" tempname
regsub -all {:} $tempname "=" tempname
regsub -all {"} $tempname "'" tempname
set name_file $ph\\${tempname}($id).csv
LogWrite "$name_file\n"
set ff [ open $name_file "w+" ]
puts $ff "-1;NAME;cvalif"
set cnt 0 ;
set s5 [ format "select NAME, id_point from da_param where id_node=%d order by id_point" $id ]
foreach {r5} [ db2 $s5 ] {
incr cnt
set nm [lindex $r5 0]
set pt [lindex $r5 1]
puts $ff "$cnt;${nm};$pt"
LogWrite "--$nm"
}
close $ff
}
return 0 ;
}
# ===============================================
proc main { } {
# ===============================================
global db1
global db2
global rf
# avtorization
set tns "rsdu2"
set usr "rsduadmin" ; # admin nov_ema
set pwd "2017'vf-Dbrsdu#" ; # passme qwertyqaz
# ëîã - ôàéë
set ph [info script]
set ph [file rootname $ph ].log
set rf [ open $ph "w+" ]
set t1 [ clock format [ clock seconds ] -format "%T" ]
puts "\nstart = $t1\n"
LogWrite "--START=$t1\n"
# Óñòàíàâëèâàåì ñîåäèíåíèå ê ÁÄ
database db2 $tns $usr $pwd
db2 set autocommit off
CreateSp
# Çàêðûâàåì ñîåäèíåíèå ê ÁÄ
# db2 commit
db2 disconnect
set t1 [ clock format [ clock seconds ] -format "%T" ]
puts "\nend = $t1"
LogWrite "\n--END=$t1"
close $rf
return 0 ;
}
main