
newbie tcl & sql question
My guess would be the select did not return any rows, therefore category was
never created.
I'd like to see the results of:
#!/bin/sh
# the next line restarts using tclsh \
load fbsql.dll
sql connect localhost root "test"
sql selectdb test
array set category {}
sql startquery "select * from mt_category" -array category
puts {category:}
parray category
puts {-------}
sql endquery
sql disconnect
Quote:
> >Hi Bingo,
> >I don't know much about the sql startquery stuff, but it looks like it's
> >the line after the "startquery" that is causing problems (the 'puts
> >"$category"'). It looks as if you pass in the variable "category" into
> >startquery as an array, but you try and reference the whole array with
> >the puts. Instead of 'puts "$category"', try:
> >puts [array get category]
> >That will put out each index and value in the array "category". If the
> >category array is not populated by your query (i.e. there are no results
> >that match the sql statement), then you will get an empty line instead of
> >an error.
> >I could be wrong, since I don't know what the the sql calls do, but
> >that's what I would try if I had to debug your code.
> .
> .
> .
> >> the error:
> >> can't read "category": no such variable
> .
> .
> .
> I salute a valiant speculation--but feel compelled to note
> that it's unlikely to be fruitful. While I don't know FastBase,
> and my first thought was the same as yours, I'm certain that
> Tcl will report
> can't read "category": variable is array
> in the situation where category is an array and someone tries to
> puts $category
> So what *is* the solution? That'll have to wait the appearance
> of more FastBase expertise here, I suspect.
> --
> Business: http://www.Phaseit.net
> Personal: http://starbase.neosoft.com/~claird/home.html
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester | "The man who fights for his ideals is |
+--------------------------------+---------------------------------------+