"Andy Goth" <[EMAIL PROTECTED]> wrote:
> On Fri, 05 Oct 2007 15:20:41 +0000, drh wrote
> > "Andy Goth" <[EMAIL PROTECTED]> wrote:
> > > http://wiki.tcl.tk/2633
> >
> > I suggest you go head and write a short TCL procedure to
> > accomplish the same thing.
>
> Like this?
>
> proc sql_expand {varname} {
> upvar 1 $varname var
> set result [list]
> foreach elem $var {
> lappend result '[string map {' ''} $elem]'
> }
> return [join $result ,]
> }
>
> $ set x {1 2 3}
> $ db eval "insert into xyzdata values ([sql_expand x])"
> (expands to)
> $ db eval "insert into xyzdata values ('1','2','3')"
>
> Is there any problem with the spurious quotes around the values? Will that
> interfere with integer primary key or anything like that?
What you have will work. The '...' will not effect integer values.
But you might change the routine as follows:
proc sql_expand {varname} {
upvar 1 $varname var
set result [list]
foreach elem $var {
if {[string is double -strict $elem]} {
lappend result $elem
} else {
lappend result '[string map {' ''} $elem]'
}
}
return [join $result ,]
}
--
D. Richard Hipp <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------