Hi All,

I'm trying to determine the datatype of a given column using Tcl and the 
following code snippet...

set dataType [$db onecolumn "select typeof($colName) from $table"]

This works correctly as long as $colName (the name of the current column) 
doesn't contain a space.  When the column name contains a space (such as 
"ASSEMBLY NUMBER"), the above code fails with:

Error: near "NUMBER": syntax error

Obviously, the "NUMBER" text depends on the column name.  Now, that's easily 
fixed by wrapping the variable name in single-quotes, like this:

set dataType [$db onecolumn "select typeof('$colName') from $table"]

While that fixes the issue with the space, the single-quote wrapper causes the 
"typeof" function to return "text" for all column types, which is incorrect.  

So, how can I get the correct column types returned for all columns, while at 
the same time properly handle column names containing spaces?

Thanks for any insight.

Jeff

Reply via email to