Prev: FlushChannel: damaged channel list
Next: transparency
From: Llerena on 6 Nov 2006 12:19 Hi all I have to insert in a table an integer, one binary file (*.wav) and another text (*.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. *NOTE: I can connect to the database without problems and Query any table... ok 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.
From: Manfred Stelzhammer on 6 Nov 2006 13:34 > idstmt $iduser $vector $voicefile > What does this command "idstmt" do? regards Manfred
From: Llerena on 7 Nov 2006 03:40 "idstmt" - this is the statement generated by SqlInsert On Nov 6, 6:34 pm, Manfred Stelzhammer <stelzham...(a)antispam.at> wrote: > > idstmt $iduser $vector $voicefileWhat does this command "idstmt" do? > > regards > Manfred
From: Manfred Stelzhammer on 7 Nov 2006 14:56 I tried your script, with some small changes, on a firebird database und tclodbc 2.3 and it worked. I have in the database the sams as in the file. Did you copy the script from your scriptfile in the newsgroup? If yes, it isn't possible the script is running. It would be easier to find a error, when the script you write in an newsgroup is running until the error. regards Manfred ##script start package require tclodbc database fdb obst3 set fvector [open "tmpwave.mfcc"] set fvoicefile [open "tmpwave.wav"] set vector [read $fvector] set voicefile [read $fvoicefile] set iduser 1 set table "FEATURES" set lste [list "ID_USERS" "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 $columns ,]) VALUES ([SqlParams $columns , no])" set coltypes [ColTypes $db $table [string tolower $columns]] $mode "$db statement $stmt \{$sql\} \{$coltypes\}" } SqlInsert fdb "idstmt" $table $lste idstmt "$iduser $vector $voicefile" ##script end
From: Llerena on 8 Nov 2006 04:26
Hi Manfred. I copy your script like you left here, jus with the database connection change (database fdb vrsys) and recive this error: Too many arguments while executing "idstmt "$iduser $vector $voicefile"" (file "tmp.tcl" line 52) The I put the "puts" commando to SqlInser procedure to view the complete statement (SqlInsert fdb "idstmt" $table $lste puts) and look like this: fdb statement idstmt {INSERT INTO FEATURES (ID_USERS,VECTOR,VOICEFILE) VALUES (?,?,?)} {{4 10 0} {-1 2147483647} {-4 2147483647}} I think it's ok, but what's the real problem? Best Regard's Me |