I have tcl 8.2.3 with tclhttpd 3.0.3 and tclodbc 2.2 on my Windows 98
machine, and the same packages & versions on a UNIX machine too.

>From within a normal tcl script, I can issue commands like

set PhoneNo [string trim [db "SELECT Customers.Phone FROM Customers WHERE
Customers.CompanyName= '$CoName' "] {\{ \}}] }

with SQL embedded in a tcl command, and tcl substitutes for the variable
$CoName before throwing the SQL at my database and all is happy.

I am trying to embed this into a .tml page under tcl-httpd though, and I'm
having problems. In my file form1.tml, I have:

[proc prologParse {In2} {global SQL PhoneNo; set PrologBit2 {parse('};
append PrologBit2 $In2; append PrologBit2 {', S)}; prolog $PrologBit2; set
SQL $prolog_variables(S); db $SQL}]

So, In2 is what comes from the form on the client's web page (e.g. "How many
customers have we got?"); this is built into a Prolog statement:

parse('How many customers have we got?', S)

which is passed to SICStus prolog for parsing. The (prolog) variable S
becomes instantiated to the SQL equivalent of the English question. The
(tcl) variable SQL is then set to be equivalent to prolog's S, and this
*should* then be used to query the database using tclodbc by the last
command of the procedure:

db $SQL

However, tcl doesn't seem to want to substitute my variable:

07001 -3010 {[Microsoft][ODBC Microsoft Access Driver] Too few parameters.
Expected 1.}
    while executing
"db $SQL"
    (procedure "prologParse" line 1)
    invoked from within
"prologParse [lindex [ncgi::nvlist] 1]"

It's trying to execute just "db $SQL" instead of "db SELECT * FROM thingy".
I've a feeling this is something silly that I should have spotted, and if so
I apologise, but if anyone has a suggestion, I'm all ears. Thanks in
advance.

Cheers!


Tim Morley

Reply via email to