This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Question regarding mysqltcl and moreresult

Help for those learning Tcl or writing their own scripts.
Post Reply
k
keung
Voice
Posts: 5
Joined: Mon Apr 30, 2012 8:30 pm

Question regarding mysqltcl and moreresult

Post by keung »

As I haven't been able to track down a more suitable forum for this API, I hope it's okay that I ask this here.

I have been playing around abit lately with the mysqltcl API, but I've stumbled upon something that I do not understand. From what I can gather from the manual and this example, using mysql::moreresult should return true if there are more data available from a SELECT statement. This is the code I'm running:

Code: Select all

set sqlLink [::mysql::connect -host $sqlHostname -user $sqlUsername -password $sqlPassword -db $sqlDatabase]
set sql "SELECT * FROM tcltest"
set query [::mysql::query $sqlLink $sql]

puts "moreresult: [::mysql::moreresult $query]"

if {[::mysql::moreresult $query]} {

        puts [::mysql::fetch $query]
        puts [::mysql::fetch $query]
        puts [::mysql::fetch $query]

}
I know that the test table only holds three rows, which is why I've conveniently lined up three fetch's in a row. But, the thing is, this does not have the outcome I expect. This is what I get when I run the tcl:

Code: Select all

keung@coeus:~/tcl$ ./mysql.tcl
moreresult: 0
Now, if I remove the if-statement completely, this is the result:

Code: Select all

keung@coeus:~/tcl$ ./mysql.tcl
moreresult: 0
1 keung gnuek ungke
2 bla inst prep
3 eon pondus m
Does anyone know what I am doing wrong? :)
Post Reply