This file is indexed.

/usr/lib/tcltk/tclodbc2.5/sqlutil.tcl is in tclodbc 2.5.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# require tcl 8.0 because of namespaces
if {$tcl_version < "8.0"} {
    return
}

#package provide tclodbc 2.4

namespace eval tclodbc {;
####################################################################
#
# Procedure SqlInsert
# 
# Return command for creating a insert statement for given table
# and columns. Mode determines the action for the command. Useful
# modes are e.g. eval, return and puts.
# 
# Parameters:
# db         : database object
# stmt       : statement name
# table      : table name
# columns    : column names
# ?mode?     : mode, default is eval       

namespace export SqlInsert
proc SqlInsert {db stmt table columns {mode eval}} {
    set sql "INSERT INTO $table ([join $columns ,]) VALUES ([SqlParams $columns , no])"
    set coltypes [ColTypes $db $table $columns]
    $mode "$db statement $stmt \{$sql\} \{$coltypes\}"
}
# end proc SqlInsert

####################################################################
#
# Procedure SqlUpdate
# 
# Return command for creating a update statement for given table
# and columns. Mode determines the action for the command. Useful
# modes are e.g. eval, return and puts. 
# 
# Parameters:
# db         : database object
# stmt       : statement name
# table      : table name
# datacols   : data column names
# keycols    : key column names
# ?mode?     : mode, default is eval       

namespace export SqlUpdate
proc SqlUpdate {db stmt table datacols keycols {mode eval}} {
    set sql "UPDATE $table SET [SqlParams $datacols ,] WHERE [SqlParams $keycols]" 
    set coltypes [ColTypes $db $table [concat $datacols $keycols]]
    $mode "$db statement $stmt \{$sql\} \{$coltypes\}"
}
# end proc SqlUpdate

####################################################################
#
# Procedure SqlSelect
# 
# Return command for creating a select statement for given table
# and columns. Mode determines the action for the command. Useful
# modes are e.g. eval, return and puts.
# 
# Parameters:
# db         : database object
# stmt       : statement name
# table      : table name
# datacols   : data column names
# keycols    : key column names
# ?mode?     : mode, default is eval       

namespace export SqlSelect
proc SqlSelect {db stmt table datacols keycols {mode eval}} {
    set sql "SELECT [join $datacols ,] FROM $table WHERE [SqlParams $keycols]" 
    set coltypes [ColTypes $db $table $keycols]
    $mode "$db statement $stmt \{$sql\} \{$coltypes\}"
}
# end proc SqlSelect

####################################################################
#
# Procedure SqlDelete
# 
# Create command for creating a delete statement for given table
# and columns. 
# 
# Parameters:
# db         : database object
# stmt       : statement name
# table      : table name
# keycols    : key column names
# ?mode?     : mode, default is eval       

namespace export SqlDelete
proc SqlDelete {db stmt table keycols {mode eval}} {
    set sql "DELETE FROM $table WHERE [SqlParams $keycols]" 
    set coltypes [ColTypes $db $table $keycols]
    $mode "$db statement $stmt \{$sql\} \{$coltypes\}"
}
# end proc SqlDelete

####################################################################
#
# Procedure ColTypes
# 
# Return list of column types for given columns. This list can
# be used as statement argument specification.
# 
# Parameters:
# db         : database object
# table      : table name
# columns    : column names

namespace export ColTypes
proc ColTypes {db table columns} {
    set coldefs [$db columns $table]
    foreach i $coldefs {
	set colname [string tolower [lindex $i 3]]
	set coltype($colname) [list [lindex $i 4] [lindex $i 6]]

	# precision may be empty for certain datatypes
	if {[lindex $i 8] != {}} {
	    lappend coltype($colname) [lindex $i 8]
	}
    }

    foreach i $columns {
	lappend coltypes $coltype([string tolower $i])
    }

    return $coltypes
}
# end proc ColTypes

####################################################################
#
# Private utility procedures

proc SqlParams {columns {separator { AND }} {assign yes}} {
    foreach i $columns {
	if {$assign} {
	    lappend marks ${i}=?
	} else {
	    lappend marks ?
	}
    }
    return [join $marks $separator]
}

}; # end namespace tclodbc