[sqlite] Extra functions for portability

2008-03-03 Thread Brodie Thiesfield
Hi, My database layer needs to support PostgreSQL, MS SQL Server and SQLite and as much as possible I try to use the same SQL statements without modification. I found that for some of my uses, I needed extra functions or aliases to builtin sqlite functions and so I wrote them. Since others may fin

Re: [sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key?

2008-03-03 Thread drh
"Paul Hilton" <[EMAIL PROTECTED]> wrote: > > Here is the problem: I want Slot created to disambiguate the Primary Key, So > that for every value of Group the value of Slot starts at 1 and counts up. These are two different things: (1) Slot needs to disambiguate the PRIMARY KEY (2) Slot nee

Re: [sqlite] Cross DB triggers?

2008-03-03 Thread Scott Hess
On Mon, Mar 3, 2008 at 3:09 PM, Jeff Hamilton <[EMAIL PROTECTED]> wrote: > I have a setup with two databases that have tables which refer to each > other. I'd like to create triggers to handle cleanup when items are > deleted from one database that are referred to from the second > database. I

Re: [sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key?

2008-03-03 Thread Dennis Cote
Paul Hilton wrote: > > Thanks for the suggestion, > > However it doesn't solve my problem, perhaps because of something I failed > to say. > > I am intending to use these 'Slot' numbers to schedule experiments between > talkers and listeners. > The 'Slot' refers to a time slot. > I would like

Re: [sqlite] Question on Queries

2008-03-03 Thread Mike McGonagle
Thanks for everybody's input, I will test these things out tonight... On Mon, Mar 3, 2008 at 3:53 PM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > > SELECT data FROM LIST l > > INNER JOIN MAIN m ON l.mid = m.id > > WHERE m.name = "something"; > > The two statements are not equivalent: they produce

Re: [sqlite] Cross DB triggers?

2008-03-03 Thread Ken
I don't believe that this type of trigger is allowed. Jeff Hamilton <[EMAIL PROTECTED]> wrote: Hi all, I have a setup with two databases that have tables which refer to each other. I'd like to create triggers to handle cleanup when items are deleted from one database that are referred to from t

[sqlite] Cross DB triggers?

2008-03-03 Thread Jeff Hamilton
Hi all, I have a setup with two databases that have tables which refer to each other. I'd like to create triggers to handle cleanup when items are deleted from one database that are referred to from the second database. My attempts at doing this have all failed, either with SQL parse errors or wit

Re: [sqlite] Question on Queries

2008-03-03 Thread Igor Tandetnik
Scott Baker <[EMAIL PROTECTED]> wrote: > Mike McGonagle wrote: >>> -- Compound Query >>> SELECT data FROM LIST WHERE mid = (SELECT id FROM MAIN WHERE name = >>> "something") ORDER BY ord; >>> >>> -- Individual Queries >>> SELECT id FROM MAIN WHERE name = "something"; >>> SELECT data FROM LIST WHERE

Re: [sqlite] Question on Queries

2008-03-03 Thread Clark Christensen
I'm sure the real experts will chime-in, but it looks like you might be executing the subquery once for every row in main. Maybe if you use a join, it would go faster select L.data from list L, main m where m.name='something' and L.mid = m.id; Or, maybe you could just use i

Re: [sqlite] Question on Queries

2008-03-03 Thread Scott Baker
Mike McGonagle wrote: > Oh, I forgot to mention (if it matters), the "MAIN" table has about 3000 > rows in it, while the "LIST" table has about 6 rows. > Mike > > > On Mon, Mar 3, 2008 at 3:32 PM, Mike McGonagle <[EMAIL PROTECTED]> wrote: > >> Hello all, >> I was working with some queries la

Re: [sqlite] "database is locked" on clean install, empty database?

2008-03-03 Thread Sean Rhea
On Mon, Mar 3, 2008 at 12:59 PM, Andreas Kupries <[EMAIL PROTECTED]> wrote: > Is the database file by chance in a NFS mounted directory ? That was it. Thanks! Sean -- "Humanity has advanced, when it has advanced, not because it has been sober, responsible, and cautious, but because it has been

Re: [sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key?

2008-03-03 Thread Paul Hilton
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dennis Cote Sent: Monday, March 03, 2008 4:17 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key? Pau

Re: [sqlite] Question on Queries

2008-03-03 Thread Mike McGonagle
Oh, I forgot to mention (if it matters), the "MAIN" table has about 3000 rows in it, while the "LIST" table has about 6 rows. Mike On Mon, Mar 3, 2008 at 3:32 PM, Mike McGonagle <[EMAIL PROTECTED]> wrote: > Hello all, > I was working with some queries last night, and ran accross something th

[sqlite] Question on Queries

2008-03-03 Thread Mike McGonagle
Hello all, I was working with some queries last night, and ran accross something that I don't quite understand. Basically, this is what I have... *** CREATE TABLE MAIN ( id integer primary key autoincrement not null, name varchar(30), [other fields left out, as they are no

Re: [sqlite] "database is locked" on clean install, empty database?

2008-03-03 Thread Dennis Cote
Sean Rhea wrote: > sqlite> create table foo (node_id, timestamp, tput); > SQL error: database is locked > > What am I doing wrong? > Sean, Ensure that you have write privileges for the database file and the directory it is in. SQLite needs to create a journal file in the same directory for yo

Re: [sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key?

2008-03-03 Thread Dennis Cote
Paul Hilton wrote: > Hello, > > I have source tables Talker and Listener, each with fields ID (PK, Integer) > and Group (Integer): > > CREATE TABLE Talker (ID INTEGER, Group INTEGER, Primary Key (ID)); > Ditto Listener > > I would like to make a table Communications with fields Group (PK, Intege

Re: [sqlite] "database is locked" on clean install, empty database?

2008-03-03 Thread Andreas Kupries
> > I must be missing something: > > $ sudo apt-get install sqlite3 > ... > Selecting previously deselected package sqlite3. > ... > Setting up sqlite3 (3.3.8-1.1) ... > $ ls -l test.db > ls: test.db: No such file or directory > $ sqlite3 test.db > SQLite version 3.3.8 > Enter ".help" for instruc

[sqlite] "database is locked" on clean install, empty database?

2008-03-03 Thread Sean Rhea
I must be missing something: $ sudo apt-get install sqlite3 ... Selecting previously deselected package sqlite3. ... Setting up sqlite3 (3.3.8-1.1) ... $ ls -l test.db ls: test.db: No such file or directory $ sqlite3 test.db SQLite version 3.3.8 Enter ".help" for instructions sqlite> create table

[sqlite] Can I automatically create a 'disambiguation' number in a second field of a primary key?

2008-03-03 Thread Paul Hilton
Hello, I have source tables Talker and Listener, each with fields ID (PK, Integer) and Group (Integer): CREATE TABLE Talker (ID INTEGER, Group INTEGER, Primary Key (ID)); Ditto Listener I would like to make a table Communications with fields Group (PK, Integer), Slot(PK, Integer) TalkerID (Integ

Re: [sqlite] How to recover from database corruption? (and why does it happen?)

2008-03-03 Thread Luca Olivetti
En/na Luca Olivetti ha escrit: > En/na Luca Olivetti ha escrit: > >> Hello, >> I'm using sqlite 3.3.8 under linux (mandriva 2007.1). > > [...] > >> 1) is sqlite suitable when you have multiple threads accessing the same >> database? Or should I delegate the access in a single thread and >> seria

Re: [sqlite] Does sqlite3_prepare() clean up after itself if itfails?

2008-03-03 Thread drh
"Scott Hess" <[EMAIL PROTECTED]> wrote: > > True, but my code snippet didn't check for NULL. If, for some reason, > SQLite returned a partial statement handle with an error code, then > I'd expect you would want to pass it back to sqlite3_finalize(). > Since sqlite3_finalize() explicitly handles

Re: [sqlite] Does sqlite3_prepare() clean up after itself if itfails?

2008-03-03 Thread Scott Hess
On Mon, Mar 3, 2008 at 10:47 AM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > Scott Hess <[EMAIL PROTECTED]> wrote: > > On Mon, Mar 3, 2008 at 10:16 AM, Igor Tandetnik > > <[EMAIL PROTECTED]> wrote: > >> Jerry Krinock <[EMAIL PROTECTED]> wrote: > >> > The Blob Example [1] contains code [2] in w

Re: [sqlite] Does sqlite3_prepare() clean up after itself if itfails?

2008-03-03 Thread Igor Tandetnik
Scott Hess <[EMAIL PROTECTED]> wrote: > On Mon, Mar 3, 2008 at 10:16 AM, Igor Tandetnik > <[EMAIL PROTECTED]> wrote: >> Jerry Krinock <[EMAIL PROTECTED]> wrote: >> > The Blob Example [1] contains code [2] in which, if >> sqlite3_prepare() > fails, the subsequent call to >> sqlite3_finalize() is

Re: [sqlite] Does sqlite3_prepare() clean up after itself if it fails?

2008-03-03 Thread Scott Hess
On Mon, Mar 3, 2008 at 10:16 AM, Igor Tandetnik <[EMAIL PROTECTED]> wrote: > Jerry Krinock <[EMAIL PROTECTED]> wrote: > > The Blob Example [1] contains code [2] in which, if sqlite3_prepare() > > fails, the subsequent call to sqlite3_finalize() is skipped. Is this > > OK? > > If sqlite3_prepar

Re: [sqlite] Does sqlite3_prepare() clean up after itself if it fails?

2008-03-03 Thread Igor Tandetnik
Jerry Krinock <[EMAIL PROTECTED]> wrote: > The Blob Example [1] contains code [2] in which, if sqlite3_prepare() > fails, the subsequent call to sqlite3_finalize() is skipped. Is this > OK? If sqlite3_prepare fails, you don't get a valid sqlite3_stmt handle, so there's nothing to call sqlite3_fi

[sqlite] Does sqlite3_prepare() clean up after itself if it fails?

2008-03-03 Thread Jerry Krinock
The Blob Example [1] contains code [2] in which, if sqlite3_prepare() fails, the subsequent call to sqlite3_finalize() is skipped. Is this OK? Does sqlite3_prepare() free up any memory it may have allocated if it fails? I've read the documentation for these two functions but still don't

Re: [sqlite] Does or will Sqlite provide a DUMP mechanism?

2008-03-03 Thread Rich Rattanni
It should be easy to write your own dump feature. The table create statements are saved in sqlite_master, and likewise for the schema. Without looking at the code for sqlite3 (the command line utility) or tksqlite, I would bet that is how they implement their dump feature. On Mon, Mar 3, 2008 at

Re: [sqlite] Does or will Sqlite provide a DUMP mechanism?

2008-03-03 Thread Dennis Cote
Abshagen, Martin RD-AS2 wrote: > Can a backup mechanism be implemented by means of the current Sqlite-API? Well, no, but the database is a single file, so you can back it up by copying the file. If you are concerned about other processes accessing the database while you are copying it, have you

Re: [sqlite] [newbie] SQLite and VB.Net?

2008-03-03 Thread Samuel Neff
ADO.NET is part of the .NET framework. There are no additional depencencies and with SQLite there is nothing to setup outside your own application. The performance impact of using ADO.NET vs direct is miniscule and greatly outweighed by the improved efficiency in development. Sam On Sun, Mar 2

Re: [sqlite] PRAGMA auto_vacuum

2008-03-03 Thread Dennis Cote
Raviv Shasha wrote: > > Sqlite_exec (pDB, "PRAGMA auto_vacuum = 1", NULL, 0, &errMsg); > Raviv, That is correct, but you should not the following detail from http://www.sqlite.org/pragma.html > Therefore, auto-vacuuming must be turned on > before any tables are created. It is not possible to

Re: [sqlite] error downloading extensions / contributions

2008-03-03 Thread Dennis Cote
Paulo van Breugel wrote: > > I have two problems concerning the contributed file > extension-function.c. First is that I can't download it from the > 'Contributed files' page on www.sqlite.org. More in general, when trying > to download a contributed file (extension-functions.c) from the > Con

Re: [sqlite] since when was fts3 included in binary?

2008-03-03 Thread Dennis Cote
Rael Bauer wrote: >> According to the web page, 3.5.3. > > Which web page is that? > Probably http://www.sqlite.org/changes.html HTH Dennis Cote ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo

Re: [sqlite] C++ api - callbacks problem

2008-03-03 Thread Dennis Cote
Toby Roworth wrote: > > Looking at the API reference. it would apear you can send an extra > "custom" argument to the callback fro sqlite3_exec, using the 4th > parameter - how does this work, It works well. :-) > and inperticular, could I pass an object > through to the call back, Yes. >

Re: [sqlite] Retrieve Rownumber in sqlite

2008-03-03 Thread Dennis Cote
Kalyani Phadke wrote: > In SQL Server2005, Row_number() function is used to retrieve the > sequential number of a row within a partition of a result set, starting > at 1 for the first row in each partition. Which is very useful when > implementing paging through a large number records in Table. Is

Re: [sqlite] Hierarchical Deletion via a Trigger?

2008-03-03 Thread Klemens Friedl
2008/2/22, Dennis Cote <[EMAIL PROTECTED]>: http://article.gmane.org/gmane.comp.db.sqlite.general/17286/match=managing+trees+database > for a method I use to manage trees in SQLite that works very well. another method is to implement it like this (or similar): http://www.codeproject.com/KB/databas

Re: [sqlite] Update fail without ERRORS

2008-03-03 Thread Dennis Cote
[EMAIL PROTECTED] wrote: > > When I execute the code, sqlraw > function print the pSql string, and this is the same I pass. > The > Database descriptor is the same returned from open function, and status > code is OK!!! > > But table value isn't updated. > The code looks OK except for the ty

Re: [sqlite] Hierarchical Deletion via a Trigger?

2008-03-03 Thread Dennis Cote
Thufir wrote: > > But isn't recursion, for better or worse, part of the SQL:2003 standard? > It's an optional part of the SQL:1999 standard that is not widely implemented. Dennis Cote ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlit

[sqlite] Does or will Sqlite provide a DUMP mechanism?

2008-03-03 Thread Abshagen, Martin RD-AS2
Hello all, I am new to Sqlite and I would like to backup Sqlite databases at runtime. Appearently Sqlite does not (yet?) provide a functionality such as mysqlhotcopy. My questions are: Can a backup mechanism be implemented by means of the current Sqlite-API? And if not so: Does anybody plan to add

Re: [sqlite] SQLite Crashes

2008-03-03 Thread Shawn Wilsher
> I put a pointer to the mozilla bug report here: I probably should have mentioned our bug report as well. It's bug 408518 [1]. > These stack traces don't make any sense to me either. The definition > of sqlite3_enable_shared_cache() in SQLite cvs is: That, and as far as I can tell it's ever c

Re: [sqlite] IF...THEN constructs

2008-03-03 Thread BareFeet
Hi Jason, > I'm used to doing stored procedures for web apps, which > conditionally execute statements based on state and/or the > presence of variables. As others have pointed out, SQLite doesn't (currently at least) offer stored procedures, so no branching in SQL such as if/then etc. But SQ

[sqlite] PRAGMA auto_vacuum

2008-03-03 Thread Raviv Shasha
Hi all, I'll appreciate if anyone can send me the correct syntax for executing PRAGMA auto_vacuum = 1 command. In the sqlite documentation there is only a list of all available PRAGMA commands, but I didn't find any code examples. Do I need to execute the PRAGMA auto_vacuum via sqlite_

[sqlite] error downloading extensions / contributions

2008-03-03 Thread Paulo van Breugel
Hi, I have two problems concerning the contributed file extension-function.c. First is that I can't download it from the 'Contributed files' page on www.sqlite.org. More in general, when trying to download a contributed file (extension-functions.c) from the Contributed files page (http://www.s

Re: [sqlite] bus error with SQLite 3.5.6

2008-03-03 Thread Dan
On Mar 3, 2008, at 12:03 PM, P Kishor wrote: > Dan, > > > On 3/2/08, Dan <[EMAIL PROTECTED]> wrote: >> >> Hi, >> >> I tried this script here with the latest CVS version and >> it didn't crash: >> >>CREATE TABLE pages(page_id INTEGER PRIMARY KEY, page_name TEXT, >> page_text TEXT); >>C

[sqlite] Why do I get disk error?

2008-03-03 Thread Anton Klotz
Hi, I have a question about an error message which I cannot explain: SQL error (10): disk I/O error insert into merged_devices_lay (cell_num_sch, cell_num_lay, inst_num, sub_inst_num, sub_inst_name) values (57451, 218, 26396, 26396, 'X6/X7/X11/M107'); Under which circumstances does such an e

Re: [sqlite] since when was fts3 included in binary?

2008-03-03 Thread Rael Bauer
> According to the web page, 3.5.3. Which web page is that? -Rael - Never miss a thing. Make Yahoo your homepage. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mail

Re: [sqlite] Hierarchical Deletion via a Trigger?

2008-03-03 Thread Thufir
On Fri, 22 Feb 2008 10:46:00 -0500, Igor Tandetnik wrote: > It's impossible in pure SQL, unless the DBMS supports special syntax for > recursive queries, and/or recursive triggers. But isn't recursion, for better or worse, part of the SQL:2003 standard? -Thufir _