Hello, Gerry.

----- Original Message ----- From: "Gerry Snyder" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Tuesday, November 08, 2005 9:44 PM
Subject: [sqlite] Running Versions 2 and 3 simultaneously -- was: Re: [sqlite] sqlite 2.0 database

1) First of all, according to Dr. Hipp, "You have to load version 3 of the TCL bindings first, then version 2."

Your script does it in the other order.

It doesn't matter.
See test script below. Try to run it.

2) Second, your [pcdb] command generated by version 2 seems to need either one argument (the SQL) or three (SQL, ARRAY-NAME, and CODE).

Your script has two arguments in the "creating tables" section (I got it to work by adding a blank array name).

1) pcdb command in my script has three arguments:
   a) method ("eval");
   b) SQL statement;
   c) script;

2) According to Dr. Hipp: "If you supply the name of an array variable in between the SQL statement and the script, column values are put into elements of the array instead of into local variables."
This means that the name of an array variable is optional.

Read this article more carefully:
http://www.tcl.tk/community/tcl2004/Papers/D.RichardHipp/drh.html

3) But still, after getting past these trivialities, your script has one command simultaneously working with both version 2 and version 3 files. The file formats are incompatible.

Yes. It's working. It's a fact. All questions to Dr.Hipp.

Something is very, very wrong here. What makes you think it is working?

Test script (see below). It copies data from sqlite2 to sqlite3 database.
This test script works with:
Tcl 8.4.
SQLite 2.8.16.
SQLite 3.2.7.

Based on the second point, I suspect [pcdb] somehow got set up as version 3, probably because of the first point.

You need to carefully examine what is going on. Your script is not doing what you seem to think it is.

Gerry


#!/bin/sh\
exec wish "$0" "$@"

package require Tclx
package require sqlite3
package require sqlite

sqlite pcdb pcdatabase
sqlite3 pcdb3 newpcdatabase

# creating and filling table in the old DB:
pcdb eval {create table t1 (a int)}
loop i 0 5 {
pcdb eval "insert into t1 values ($i)"
}

# creating table in the new DB:
pcdb eval {select sql from sqlite_master} {
   pcdb3 eval $sql
}
pcdb3 close

# filling table of the new DB:
pcdb eval {attach 'newpcdatabase' as newpcdb}
pcdb eval {select name from sqlite_master where type='table'} {
  pcdb eval "insert into newpcdb.'$name' select * from '$name' "
}
pcdb eval {detach newpcdb}
pcdb close
exit

Reply via email to