Menu

#8 insert binary file

open
nobody
None
5
2006-11-03
2006-11-03
Anonymous
No

Hi guys.

I have to insert in a table an integer, one binary file
(*.wav) and another text file (*.txt) (3 fields)

This code insert the user "id" but in the "vector" and
"voicefile" fields jut insert the variable name
$vector" and "$voicefile", not the content of this
variables.

What's the problem?.
-------------------------
set fvector [open "tmpwave.mfcc"]
set fvoicefile [open "tmpwave.wav"]

set vector [read $fvector]
set voicefile [read $fvoicefile]

set table "FEATURES"
set lste [list "ID_USERS" "VECTOR" "VOICEFILE"]

SqlInsert fdb "idstmt" $table $lste

idstmt $iduser $vector $voicefile

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

proc ColTypes {db table cols}
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 $cols {
lappend coltypes $coltype([string tolower $i])
}

return $coltypes
}

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

Thank's in advanced.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.