Re: using TCL with sqlite database...



Jan Van Belle wrote:
However, in the manual they recommend the first approach to the second one.
If I could use variables instead of writing out each command, it would be
much easier ;-)

Variables are also a bit safer. For example your

sqldb eval "insert into $table values ($data)"

will fail if "data" contains something unexpected like "17,19+3", whereas

sqldb eval "insert into $table values (\$data)"

would automatically escape the string correctly [note that in this case
sqlite sees "$data", not "17,19+3" as in the first case].

But the basic restriction is that you can only use variables in those
parts of your SQL where an expression is acceptable (which excludes
table names, trigger names, etc...). IMO one rarely needs such a general
insert proc as your write_sqlite_db; so far I've always been quite happy
with hard-wired table names in my sqlite-procedures.

--
=> Christian Nassau, http://www.nullhomotopie.de


.



Relevant Pages

  • Re: Great SWT Program
    ... (and has a command to toggle display of markup, ... unlike Java's for and while syntax. ... Writing a script to strip the ... prose in a very artificially consistent sort of way, ...
    (comp.lang.java.programmer)
  • Re: minimum valid block size on DVD-RAM
    ... size accepted by DVD (writing) devices when writing ... a DVD-RAM is, like on nearly all other DVDs and CDs, ... I'd now like to know whether most of the available DVD-writers ... Please report me whether command 3 and command 2 succeed ...
    (freebsd-questions)
  • minimum valid block size on DVD-RAM
    ... size accepted by DVD (writing) devices when writing ... a DVD-RAM is, like on nearly all other DVDs and CDs, ... I'd now like to know whether most of the available DVD-writers ... Please report me whether command 3 and command 2 succeed ...
    (freebsd-questions)
  • Re: Great SWT Program
    ... (and has a command to toggle display of markup, ... have to consult the documentation for my shell of choice. ... and a particularly hairy syntax for distinguishing variables ... Writing a script to strip the ...
    (comp.lang.java.programmer)
  • Re: [patch] rm can have undesired side-effects
    ... different part of the disk. ... If writing zeros or whatever to a file (that may or may not overwrite ... separate features should be implemented in separate commands. ... is just not a good command to write a lot of data into a file. ...
    (freebsd-hackers)