From: Gerhard Reithofer on
Hi TCLers,
I've a strange problem with sqlite3:

% package require sqlite3
3.6.13
% sqlite3 dbh ./filedb
% set res [dbh exists {SELECT * FROM ftab WHERE 1=0}]
no such table: ftab
% puts $res
can't read "res": no such variable
% info patchlevel
8.5.7
%

From the sqlite docs (http://www.sqlite.org):
The difference is that the "exists" method always returns a boolean
value...

Tested on Debian Etch and Ubuntu Karmic (Tcl 8.5.8, sqlite3 3.6.22).

Can anyone confirm this bug (Activetcl dist.)?
Did I oversee something?
It's reused older code which worked in ealier version.

--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
From: Manfred Stelzhammer on
Gerhard Reithofer schrieb:
> Hi TCLers,
> I've a strange problem with sqlite3:
>
> % package require sqlite3
> 3.6.13
> % sqlite3 dbh ./filedb
> % set res [dbh exists {SELECT * FROM ftab WHERE 1=0}]
> no such table: ftab
> % puts $res
> can't read "res": no such variable
> % info patchlevel
> 8.5.7
> %
>
> From the sqlite docs (http://www.sqlite.org):
> The difference is that the "exists" method always returns a boolean
> value...
>
> Tested on Debian Etch and Ubuntu Karmic (Tcl 8.5.8, sqlite3 3.6.22).
>
> Can anyone confirm this bug (Activetcl dist.)?
> Did I oversee something?
> It's reused older code which worked in ealier version.
>
The docu sayes:
always returns a boolean value which is TRUE if a query in the SQL
statement it executes returns one or more rows and FALSE if the SQL
returns an empty set.

In your case the statement is wrong because the table "ftab" doesn't exist.

You can check for errors with "dbh errorcode".
If the command returns "1", there is an error in the command, with "0"
the commando ist ok.


Regards
Manfred
From: Gerhard Reithofer on
Hi Manfred,

On Sun, 25 Apr 2010, Manfred Stelzhammer wrote:
> Gerhard Reithofer schrieb:
> > Hi TCLers,
> > I've a strange problem with sqlite3:
> >
> > % package require sqlite3
> > 3.6.13
> > % sqlite3 dbh ./filedb
> > % set res [dbh exists {SELECT * FROM ftab WHERE 1=0}]

....

> > Tested on Debian Etch and Ubuntu Karmic (Tcl 8.5.8, sqlite3 3.6.22).
> > Can anyone confirm this bug (Activetcl dist.)?
> > Did I oversee something?
> > It's reused older code which worked in ealier version.
> >
> The docu sayes:
> always returns a boolean value which is TRUE if a query in the SQL statement
> it executes returns one or more rows and FALSE if the SQL returns an empty
> set.
>
> In your case the statement is wrong because the table "ftab" doesn't exist.
>
> You can check for errors with "dbh errorcode".
> If the command returns "1", there is an error in the command, with "0" the
> commando ist ok.

thanks, I didn't read the docs thoroughly enough.
I was trying for the check for the existence of a table.

c.l.t - the fastest support ;)

--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
From: Spam on
On Mon, 26 Apr 2010, Gerhard Reithofer wrote:


> thanks, I didn't read the docs thoroughly enough.
> I was trying for the check for the existence of a table.
>
> c.l.t - the fastest support ;)

try selecting for type = table from sqlite_master ...

select * from sqlite_master ;

If the table exists, you'll find it there ..

Cheers,
Rob Sciuk
From: Gerhard Reithofer on
On Sun, 25 Apr 2010, Spam(a)ControlQ.com wrote:

> On Mon, 26 Apr 2010, Gerhard Reithofer wrote:
>
>
> > thanks, I didn't read the docs thoroughly enough.
> > I was trying for the check for the existence of a table.
> >
> > c.l.t - the fastest support ;)
>
> try selecting for type = table from sqlite_master ...
>
> select * from sqlite_master ;
>
> If the table exists, you'll find it there ..
>
> Cheers,
> Rob Sciuk

Thank you very much, that was I'm searching for.

--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at