RE: [sqlite] Query on database operations.

2006-11-30 Thread Kalyani Tummala
Hi Nicolas, Thanks for the reply. My database is fixed in the number of tables and fields. I mean Schema cannot be altered once it is created. But the database records might grow even more than 20K in number. I have tried select query with and without indexes. Selection without indexes is very

RE: [sqlite] Query on database operations.

2006-11-30 Thread Kalyani Tummala
Hi John, Thanks for your help. I have another doubt? If I turn off the sql compiler, should I have to fix my insert,delete,select,update operations? My operations are almost fixed in nature. Can you tell me how exactly I do this? -Original Message- From: John Stanton [mailto:[EMAIL

Re: [sqlite] Re: sqlite_open

2006-11-30 Thread John Stanton
Dave Dyer wrote: At 08:04 PM 11/30/2006, John Stanton wrote: Those are Macintosh issues, not Sqlite, and you need to handle them in your application. Yes indeed. I'm only suggesting that sqlite would be a better substrate if it provided a supported way to tell me "I can't open the

[sqlite] Re: sqlite_open

2006-11-30 Thread Dave Dyer
At 08:04 PM 11/30/2006, John Stanton wrote: >Those are Macintosh issues, not Sqlite, and you need to handle them in your >application. Yes indeed. I'm only suggesting that sqlite would be a better substrate if it provided a supported way to tell me "I can't open the database" rather than "there

Re: [sqlite] Re: sqlite_open

2006-11-30 Thread John Stanton
Those are Macintosh issues, not Sqlite, and you need to handle them in your application. Dave Dyer wrote: t ??? Sqlite is agnostic about file names. Give it a pathname to suit the underlying file system and it is happy. You might be using some wrapper that messes with pathnames, but that

[sqlite] Re: sqlite_open

2006-11-30 Thread Dave Dyer
>>t >??? Sqlite is agnostic about file names. Give it a pathname to suit the >underlying file system and it is happy. You might be using some wrapper that >messes with pathnames, but that is not Sqlite. No, no wrappers. The mac these days is pretty confused about what kind of a system it

Re: [sqlite] sqlite_open

2006-11-30 Thread drh
John Stanton <[EMAIL PROTECTED]> wrote: > Unix has an API call which establishes > file existance efficiently. On Windows I recall that I had to open it. > SQLite contains the sqlite3OsFileExists(const char *zFilename) function that is cross-platform. Since this function does not begin with

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Cnichols
So GROUP BY will separate the the grouping done by sum()? So that also means I could factor in all discounts not just static ones? Like so? Modifier 0 = Percent Of and 1 = Static amount? Also which statement is going to be more efficient the UPDATE or the REPLACE? REPLACE INTO MemberAccounts

Re: [sqlite] Re: sqlite_open

2006-11-30 Thread John Stanton
Dave Dyer wrote: I discovered when I started testing my model that it created a file called ' .db'. It took me a while to figure out the error. Now, I test for empty databases and empty fields before trying to use them. :-) It goes deeper. I did install a "file exists" check pretty early

[sqlite] Re: REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Igor Tandetnik
Cnichols <[EMAIL PROTECTED]> wrote: So the sum() function brings the multiple discounts together for a member in the UPDATE statement? So I have a question regarding this then the Discount.Modifier stands for 0 = percent of a value or 1 = static The update you constructed would work for all

[sqlite] Re: sqlite_open

2006-11-30 Thread Dave Dyer
> > > I discovered when I started testing my model that it created a file called ' > .db'. It took me a while to figure out the error. Now, I test for empty >databases and empty fields before trying to use them. :-) It goes deeper. I did install a "file exists" check pretty early in the

[sqlite] Re: REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Igor Tandetnik
Cnichols <[EMAIL PROTECTED]> wrote: Thanks alot the UPDATE works great! Although the REPLACE INTO still only executes the last row of a multi discount. I see. MA to DA is a one-to-many relation, too. You need to move all the tables into an inner select: the goal is to use SUM aggregate to

[sqlite] Re: REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Igor Tandetnik
Cnichols <[EMAIL PROTECTED]> wrote: Thanks alot the UPDATE works great! Although the REPLACE INTO still only executes the last row of a multi discount. I see. MA to DA is a one-to-many relation, too. You need to move all the tables into an inner select: the goal is to use SUM aggregate to

Re: [sqlite] Re: sqlite_open

2006-11-30 Thread Rich Shepard
On Thu, 30 Nov 2006, Dave Dyer wrote: In my particular case, sqlite created an empty database. Since my application expected database a with an established schema, I was left wondering why my schema didn't seem to exist, and since this was a first port to a new platform (Macintosh) there were

Re: [sqlite] sqlite_open

2006-11-30 Thread John Stanton
Once it is explained a bug becomes a feature and at worst an annoyance. :-) It is a tiny change to Sqlite to make it the way you want it to work. In my systems I have not changed Sqlite but instead put a jacket around sqlite3_open and tested first for the existence of the file if I don't want

Re: [sqlite] sqlite_open

2006-11-30 Thread Cnichols
I disagree I myself see this as a feature. I think the programmer should be responsible for file checking because if it is not a SQLite database SQLite will inform you. Dave Dyer wrote: > > > It would have saved me 2 days of chasing bogons if sqlite_open > had an alternative form which only

[sqlite] sqlite_open

2006-11-30 Thread Dave Dyer
It would have saved me 2 days of chasing bogons if sqlite_open had an alternative form which only worked if the database file exists and is well-formed. The fact that a mistyped file name becomes a new database is a bug.

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Cnichols
So the sum() function brings the multiple discounts together for a member in the UPDATE statement? So I have a question regarding this then the Discount.Modifier stands for 0 = percent of a value or 1 = static The update you constructed would work for all static values since sums groups all the

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Clark Christensen
DOH! I stand corrected. Guess I should RTFM before I speak :-)) Thanks! -Clark - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: sqlite-users@sqlite.org Sent: Thursday, November 30, 2006 4:52:25 PM Subject: Re: [sqlite] REPLACE INTO Only Executes last SELECT?

Re: [sqlite] Size of INDEX in database

2006-11-30 Thread drh
Dr Gerard Hammond <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a SELECT call I can issue to the SQLite engine to determine > the number of bytes that INDEXs occupy. No. But you can download the sqlite3_analyzer utility from http://www.sqlite.org/download.html and use it to get detailed

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread drh
Clark Christensen <[EMAIL PROTECTED]> wrote: > I don't think SQLite supports "REPLACE INTO..." I'm pretty sure "REPLACE" = > is a conflict action in SQLite. > > Perhaps "INSERT OR REPLACE INTO Memb= > erAccounts (MemberId, Balance) SELECT..." will do what you want? > I went to the extra

[sqlite] Size of INDEX in database

2006-11-30 Thread Dr Gerard Hammond
Hi, Is there a SELECT call I can issue to the SQLite engine to determine the number of bytes that INDEXs occupy. -- Cheers, Dr Gerard Hammond PowerPC Mac the world's most advanced obsolete computer. - To

Re: [sqlite] problem with Triggers

2006-11-30 Thread Dennis Cote
chetana bhargav wrote: Hi, I was trying out to test some trigger stuff, basically if I have 2 connections open, and one of the connection registered a user defined function to be invoked. Now when the other connection inserts into table was trying to see if the first functions registered

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Cnichols
Thanks alot the UPDATE works great! Although the REPLACE INTO still only executes the last row of a multi discount. Igor Tandetnik wrote: > > Cnichols <[EMAIL PROTECTED]> wrote: >> I have a complex SQL statement which attempts to update all Member >> Accounts balance with a discount if there

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Cnichols
REPLACE is just an alias for INSERT OR REPLACE. This SQL Statement works off a Primary key as stated here. http://www.sqlite.org/cvstrac/wiki?p=UnsupportedSqlUpdateWithFrom I have an SQL statement that works using this concept. This SQL Statement will update all accounts for members with an

[sqlite] Re: REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Igor Tandetnik
Clark Christensen wrote: I don't think SQLite supports "REPLACE INTO..." Does too. http://www.sqlite.org/lang_replace.html Igor Tandetnik - To unsubscribe, send email to [EMAIL PROTECTED]

[sqlite] Re: REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Igor Tandetnik
Cnichols <[EMAIL PROTECTED]> wrote: I have a complex SQL statement which attempts to update all Member Accounts balance with a discount if there anniversary falls between last handled date and the current day. REPLACE INTO MemberAccounts (MemberId, Balance) SELECT DA.MemberId, (MA.Balance -

Re: [sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Clark Christensen
I don't think SQLite supports "REPLACE INTO..." I'm pretty sure "REPLACE" is a conflict action in SQLite. Perhaps "INSERT OR REPLACE INTO MemberAccounts (MemberId, Balance) SELECT..." will do what you want? -Clark - Original Message From: Cnichols <[EMAIL PROTECTED]> To:

[sqlite] REPLACE INTO Only Executes last SELECT?

2006-11-30 Thread Cnichols
I have a complex SQL statement which attempts to update all Member Accounts balance with a discount if there anniversary falls between last handled date and the current day. REPLACE INTO MemberAccounts (MemberId, Balance) SELECT DA.MemberId, (MA.Balance - D.Amount) AS Amount FROM

[sqlite] Re: Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Igor Tandetnik
Thomas Zangl <[EMAIL PROTECTED]> wrote: Compare with this program: string userInput; string sql = "update UserPrefs set innocuousPref=? where userid=123;"; sqlite3_stmt* stmt; sqlite3_prepare(db, sql.c_str(), -1, , 0); sqlite3_bind_text(stmt, 1, userInput.c_str(), -1, SQLITE_STATIC);

Re: [sqlite] Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Trevor Talbot
On 11/30/06, Thomas Zangl <[EMAIL PROTECTED]> wrote: char* sql_parameter_search = '%test%' This is not valid C. If you want help with your code, paste EXACTLY what you're using please! - To unsubscribe, send email

Re: [sqlite] problem with Triggers

2006-11-30 Thread chetana bhargav
But should it cause the prepare's to fail, because of not having the function registered. ... Chetana. - Original Message From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: sqlite-users@sqlite.org Sent: Thursday, November 30, 2006 11:43:34 PM Subject: Re: [sqlite] problem with Triggers

Re: [sqlite] problem with Triggers

2006-11-30 Thread drh
chetana bhargav <[EMAIL PROTECTED]> wrote: > Hi, > > I was trying out to test some trigger stuff, basically > if I have 2 connections open, and one of the connection > registered a user defined function to be invoked. Now > when the other connection inserts into table was trying > to see if

Re: [sqlite] How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread John Stanton
As Igor very astutely pointed out, the other very strong benefit of this approach is that you always bind to a compiled SQL statement and quarantine your application from the possibility of having a malicious SQL attack. You win on all counts. John Stanton wrote: Sqlite3_exec is merely a

[sqlite] problem with Triggers

2006-11-30 Thread chetana bhargav
Hi, I was trying out to test some trigger stuff, basically if I have 2 connections open, and one of the connection registered a user defined function to be invoked. Now when the other connection inserts into table was trying to see if the first functions registered function is called or not.

Re: [sqlite] Query on database operations.

2006-11-30 Thread John Stanton
You might find that a version of Sqlite which omits the compiler might fit your application. You get a smaller footprint, but at the cost of having to use pre-compiled SQL, which means that you cannot dynamically create SQL. Kalyani Tummala wrote: Hi, This mail is a bit lengthy. I thank

Re: [sqlite] How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread John Stanton
Sqlite3_exec is merely a wrapper around sqlite3_prepare. The name on sqlite3_prepare is a little misleading. It is actually sqlite3_compile and compiles your SQL into an internal metacode and applies syntax rules. Incorrect SQL will fail on sqlite3_prepare and you can make your program more

Re: [sqlite] Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Thomas Zangl
Vitali Lovich schrieb: Regarding your code snippet: // SQL Statement is: "SELECT * FROM table WHERE name LIKE ?" search = '%test%'; sqlite3_bind_text(prepared_statement, 0,search , search , SQLITE_STATIC); First I'm not sure what language you're using - it seems Perl-like. Anyways, the

Re: [sqlite] How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread drh
Thomas Zangl <[EMAIL PROTECTED]> wrote: > > I am quite sure that my version is safe Famous last words. :-) -- D. Richard Hipp <[EMAIL PROTECTED]> - To unsubscribe, send email to [EMAIL PROTECTED]

Re: [sqlite] Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Vitali Lovich
Regarding your code snippet: // SQL Statement is: "SELECT * FROM table WHERE name LIKE ?" search = '%test%'; sqlite3_bind_text(prepared_statement, 0,search , search , SQLITE_STATIC); First I'm not sure what language you're using - it seems Perl-like. Anyways, the documentation for

Re: [sqlite] Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Thomas Zangl
Igor Tandetnik schrieb: Hi! Compare with this program: string userInput; string sql = "update UserPrefs set innocuousPref=? where userid=123;"; sqlite3_stmt* stmt; sqlite3_prepare(db, sql.c_str(), -1, , 0); sqlite3_bind_text(stmt, 1, userInput.c_str(), -1, SQLITE_STATIC); sqlite3_step(stmt);

[sqlite] Re: How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Igor Tandetnik
Thomas Zangl <[EMAIL PROTECTED]> wrote: I am currently in doubt if the usage of sqlite3_prepare(...) makes my application safer. It is usually recommended to preapre a SQL statement before using it. In my case, I have no need to re-use them so a simple sqlite3_exec would be sufficient. On the

Re: [sqlite] Query on database operations.

2006-11-30 Thread Nicolas Williams
On Thu, Nov 30, 2006 at 08:03:00PM +0530, Kalyani Tummala wrote: > With indexes on every column(searched), the following is the heap size > for different database operations on a database with 100 records and 6 > tables with an avg of 10 to 15 fields each. You can probably get by quite well

Re: [sqlite] Query on database operations.

2006-11-30 Thread drh
"Kalyani Tummala" <[EMAIL PROTECTED]> wrote: > > Heap memory is highly variant on size and number of records. I tried > modifying the page size(SQLITE_DEFAULT_PAGE_SIZE and > SQLITE_MAX_PAGE_SIZE ) in pager.h from 512 to 2048 but found no > reduction in heap size. > Try changing

[sqlite] How safe is sqlite3_prepare compared to sqlite3_exec?

2006-11-30 Thread Thomas Zangl
Dear List! I am currently in doubt if the usage of sqlite3_prepare(...) makes my application safer. It is usually recommended to preapre a SQL statement before using it. In my case, I have no need to re-use them so a simple sqlite3_exec would be sufficient. On the other side I have been