RE: [sqlite] outputting select in cpp file?
Check out the callback parameter to sqlite_exec (the third parameter). The quickstart gives an example of this: http://www.sqlite.org/quickstart.html Alternatively, check out sqlite3_prepare, sqlite3_bind, and sqlite3_step, sqlite3_result*, and sqlite3_finalize. All of these functions are documented here: http://www.sqlite.org/capi3ref.html Pat -Original Message- From: Keiichi McGuire [mailto:[EMAIL PROTECTED] Sent: Friday, July 28, 2006 3:36 PM To: sqlite-users@sqlite.org Subject: [sqlite] outputting select in cpp file? This sounds like a very simple problem, but I cannot figure it out! Basically what I have is this settings table that has a boolean data type, and I want to check it via a cpp program. sqlite_exec(db,"select flag from setting",0,0,); and I want to be able to return a 0, or a 1 according to what I put into the flag entry. Thanks! -Keiichi
[sqlite] Re: Project
I found to give a preference to select and a delay to insert. :D On 7/27/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote: If a SQLite Db is LOCKED can i exec an TRIGER?
Re: [sqlite] Sqlite flash and mallocs.
[EMAIL PROTECTED] wrote: > > Is it normal it takes 13,000 mallocs > That depends on your database schema and the data you are storing. -- D. Richard Hipp <[EMAIL PROTECTED]>
[sqlite] outputting select in cpp file?
This sounds like a very simple problem, but I cannot figure it out! Basically what I have is this settings table that has a boolean data type, and I want to check it via a cpp program. sqlite_exec(db,"select flag from setting",0,0,); and I want to be able to return a 0, or a 1 according to what I put into the flag entry. Thanks! -Keiichi
[sqlite] Sqlite flash and mallocs.
I am saving a simple database (4-5 tables and few records inside). The total size of the database once flashed is 9216 bytes. I execute the following query: snprintf(query, MAX_SQLITE_QUERY_LEN, "attach database %s as %s;" "BEGIN;" "create table if not exists %s.%s as select * from %s;" "delete from %s.%s;" "insert into %s.%s select * from %s;" "COMMIT;" "detach database %s", database, database, database, table, table, database, table, database, table, table, database ); Is it normal it takes 13,000 mallocs Our mallocs is not the fastest and well, as you can imagine it takes forever to flash it (even if it works!). Mario Hebert Legerity
Re: [sqlite] "SQL Error: near 'Table': Syntax error"
On 7/27/06, Peter van Dijk <[EMAIL PROTECTED]> wrote: Using double quotes to quote identifiers in sqlite is dangerous, as mistyping a fieldname will not yield an error. Currently the only safe way to quote identifiers is using backticks, as in MySQL. Sadly you are almost correct. :-( Using the MS Access style square brackets for quoting also produces correct error message for incorrect column names. Unfortunately, an sqlite extension causes it to misinterpret non-existent column names as string literals when they are quoted using SQL standard double quotes. The following trace shows the results for various styles of quotes. SQLite version 3.2.8 Enter ".help" for instructions sqlite> create table t (a); sqlite> insert into t values(1); sqlite> select a from t; 1 sqlite> select c from t; SQL error: no such column: c sqlite> select "a" from t; 1 sqlite> select "c" from t; c sqlite> select 'a' from t; a sqlite> select 'c' from t; c sqlite> select `a` from t; 1 sqlite> select `c` from t; SQL error: no such column: c sqlite> select [a] from t; 1 sqlite> select [c] from t; SQL error: no such column: c I'm sure this extension seemed like a good idea when it was introduced, but this example shows the dangers of changing standard functionality to "improve" it. Now we are stuck using the non-standard quote characters introduced for compatibility with other non-standard implementations in order to get reliable error detection. Consequently, the SQL using these non-standard quotes will not be portable to other standard conforming implementations. The moral of this story is: stick to the standard unless you have a *VERY* good reason to deviate. Dennis Cote
Re: [sqlite] SQLite browser/manager + Deep SQL - testers please
thanks - Original Message - From: "Dennis Cote" <[EMAIL PROTECTED]> To:Sent: Friday, July 28, 2006 12:00 PM Subject: Re: [sqlite] SQLite browser/manager + Deep SQL - testers please On 7/28/06, Me <[EMAIL PROTECTED]> wrote: Also - How do I get it listed in the wiki - ManagementTools? It's a wiki... Just go to the page click the edit link and add it yourself. HTH Dennis Cote No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.4/402 - Release Date: 7/27/2006
Re: [sqlite] User function in WHERE clause
O.K. This is what I need. Thanks -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5543377 Sent from the SQLite forum at Nabble.com.
Re: [sqlite] SQLite browser/manager + Deep SQL - testers please
On 7/28/06, Me <[EMAIL PROTECTED]> wrote: Also - How do I get it listed in the wiki - ManagementTools? It's a wiki... Just go to the page click the edit link and add it yourself. HTH Dennis Cote
Re: [sqlite] User function in WHERE clause
On 7/28/06, Stan <[EMAIL PROTECTED]> wrote: But there are my problems: 1) Return value xFunc is void? I have to return integer. 2) Where are described parameters in xFunc? E.g. what is it "sqlite3_context"? Stan, Check out section 2.3 User defined funcion s on this page http://www.sqlite.org/capi3.html HTH Dennis Cote
Re: [sqlite] WHERE with user function
On 7/28/06, Stan <[EMAIL PROTECTED]> wrote: Is there any example (tutorial or explanation) in C or C++ for similar problem? Stan, All the built in functions in sqlite use exactly the same API that is available to you. The source file func.c conatins many examples of user defined functions and returning values from these functions. You can view the file here http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/func.c=1.132 or download one of the source packages at http://www.sqlite.org/download.html. HTH Dennis Cote
[sqlite] SQLite browser/manager + Deep SQL - testers please
Windows SQLite browser/manager. Four query views. View/Edit four simultaneous queries or same table in various sort orders. No limitation how a table is arranged for editing as long as the Primary Key is in the query. Transactions supported. Deep SQL: Work on blob-stored SQLite databases - down to any level. Edit blobs as if a local file - Excel®, Word®, Photoshop®, etc... Save queries, Lookup list, Ditto columns and save column view widths. Table tool: create, rename and drop. Column tool: add, drop, rename, reorder and redefine (change type, default, check(), constraints). Index tool: create, rename and drop. www.sqlight.com I'd appreciate it anyone has the time to test. Also - How do I get it listed in the wiki - ManagementTools? Windows Only! [EMAIL PROTECTED] StanDurham
[sqlite] Re: User function in WHERE clause
Stan <[EMAIL PROTECTED]> wrote: Thanks for answer. Yes, I have read this many times, but... ...I'm dumb maybe. I understand first 5 parameters in the "sqlite3_create_function". xStep and xFinal will be NULL. But there are my problems: 1) Return value xFunc is void? I have to return integer. sqlite3_result_int 2) Where are described parameters in xFunc? E.g. what is it "sqlite3_context"? An opaque handle you pass to sqlite3_result_* and sqlite3_user_data. The second parameter of xFunc is the number of values in the array pointed to by the third parameter. The third is an array of sqlite3_value* pointers, each representing a parameter to the function from SQL invocation. You can read the actual values using sqlite3_value_* functions. Igor Tandetnik
Re: [sqlite] WHERE with user function
Stan uttered: Hi, I need user function for WHERE clause. But I don't know what type of parameters to use for such function: SELECT * FROM Table WHERE MYFUNC(ColumnName, IntValue). Above all - how to returm value to WHERE and what type? Is there any example (tutorial or explanation) in C or C++ for similar problem? You've checked out the API reference? http://www.sqlite.org/capi3ref.html#sqlite3_create_function Thanks Stan -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: [sqlite] User function in WHERE clause
Thanks for answer. Yes, I have read this many times, but... ...I'm dumb maybe. I understand first 5 parameters in the "sqlite3_create_function". xStep and xFinal will be NULL. But there are my problems: 1) Return value xFunc is void? I have to return integer. 2) Where are described parameters in xFunc? E.g. what is it "sqlite3_context"? Thanks for your time. Stan -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5542532 Sent from the SQLite forum at Nabble.com.
[sqlite] Re: User function in WHERE clause
Stan <[EMAIL PROTECTED]> wrote: Thanks for tip. I'm happy to see it's possible. Alas, I'm rather confused. I have read documentation, but I'm not sure what parameters to use What parameters your function needs to take depends entirely on what said function is supposed to do. and what return value for WHERE clause. Return an integer: 0 means false, any non-zero value means true. And how to include MYFUNC to SQLite ? Have you read the documentation Jay Sprankle pointed you to? http://sqlite.org/capi3ref.html#sqlite3_create_function Igor Tandetnik
Re: [sqlite] insert default values
On 2006-0728 16:47:21, Nemanja Corlija wrote: > You can get that with this query: > select seq from sqlite_sequence where name='test' [...] > > There is also a last_insert_rowid() [...] > sqlite_sequence is really the way to go. very useful comments from everybody, thanks! Mario -- Power corrupts. Absolute power is kind of neat.
[sqlite] Please un subscribe me from sqlite. Dont send me email
Please un subscribe me from sqlite From: "Rob Richardson" <[EMAIL PROTECTED]> Reply-To: sqlite-users@sqlite.org To:Subject: [sqlite] The meaning of times in julianday() Date: Fri, 28 Jul 2006 10:50:52 -0400 Greetings! My test query is: select tag_key,value, datetime(value_timestamp, 'localtime') AS localtime, datetime(value_timestamp) AS UTCtime from trend_view where trend_key=1 and value_timestamp >= julianday('2006-07-27 10:08:32.000') order by value_timestamp desc My table has records recorded every hour, roughly on the hour. This program that generated this query wanted to get the last 24 hours' worth of data. It was run at 10:08 on June 28th. The earliest data returned was recorded at 11:01 UTC on June 27th, or 7:01 AM EDT on June 27th. That's too far back by four hours (the difference between EDT and UTC time). When I changed the query to use julianday('2006-07-27 10:08:32.000', 'utc'), the earliest data returned was recorded at 15:01 UTC on June 27th, which is 11:01 EDT on June 27th, which is what I want. When I changed the query to use julianday('2006-07-27 10:08:32.000', 'localtime'), the earliest data returned was recorded at 07:01 UTC on June 27th, which is 03:01 AM EDT on June 27th, which is far too much. So, I conclude the following: If no modifier is provided to the julianday() method, the given date is assumed to be UTC. If the 'utc' modifier is used, the given date is assumed to be local time. It is converted to UTC before the comparison is made. If the 'localtime' modifier is used, the given date is assumed to be UTC time, and it is converted to local time before the comparison is made. Are those conclusions correct? And I presume the datetime() method operates the same way? Thanks again! Rob Richardson RAD-CON INC. _ Who will win Bollywoods most coveted IIFA awards? You decide! Cast your vote! http://server1.msn.co.in/sp06/IIFA2006/static/weekend.asp
[sqlite] The meaning of times in julianday()
Greetings! My test query is: select tag_key,value, datetime(value_timestamp, 'localtime') AS localtime, datetime(value_timestamp) AS UTCtime from trend_view where trend_key=1 and value_timestamp >= julianday('2006-07-27 10:08:32.000') order by value_timestamp desc My table has records recorded every hour, roughly on the hour. This program that generated this query wanted to get the last 24 hours' worth of data. It was run at 10:08 on June 28th. The earliest data returned was recorded at 11:01 UTC on June 27th, or 7:01 AM EDT on June 27th. That's too far back by four hours (the difference between EDT and UTC time). When I changed the query to use julianday('2006-07-27 10:08:32.000', 'utc'), the earliest data returned was recorded at 15:01 UTC on June 27th, which is 11:01 EDT on June 27th, which is what I want. When I changed the query to use julianday('2006-07-27 10:08:32.000', 'localtime'), the earliest data returned was recorded at 07:01 UTC on June 27th, which is 03:01 AM EDT on June 27th, which is far too much. So, I conclude the following: If no modifier is provided to the julianday() method, the given date is assumed to be UTC. If the 'utc' modifier is used, the given date is assumed to be local time. It is converted to UTC before the comparison is made. If the 'localtime' modifier is used, the given date is assumed to be UTC time, and it is converted to local time before the comparison is made. Are those conclusions correct? And I presume the datetime() method operates the same way? Thanks again! Rob Richardson RAD-CON INC.
Re: [sqlite] insert default values
On 7/28/06, Mario Frasca <[EMAIL PROTECTED]> wrote: On 2006-0728 16:07:47, Nemanja Corlija wrote: > You can insert default value like this: > insert into test (f) values (NULL); > > Inserting NULL into autoincrement field just increments it. While > omitting value for any other field uses default for that field, if one > is defined. next question: is there a way to ask which was the last (autoincremented) value inserted in the table? or is there a guarantee that this works, as it seems... select max(f) from test; You can get that with this query: select seq from sqlite_sequence where name='test' 'test' is the name of your table and "seq" field keeps the last/highest value that was inserted in AUTOINCREMENT field. This will only work if you define your table to use true AUTOINCREMENT field, like we did in this example. If you use just INTEGER PRIMARY KEY, without AUTOINCREMENT, that table doesn't have a record in sqlite_sequence table. For the later case "select max(f) from test;" would work. Though that's not what we have here. There is also a last_insert_rowid() function that is like an alias for sqlite_last_insert_rowid() API function and it works per db connection. I don't think this this is very useful with true AUTOINCREMENT fields, so sqlite_sequence is really the way to go. -- Nemanja Corlija <[EMAIL PROTECTED]>
RE: [sqlite] Can I use internal variables in SQL scripts?
Christian, Thank you for your reply. I will be happy to develop stored procedure capability for SQLite in my copious spare time. :-) Don't hold your breath. RobR -Original Message- From: Christian Smith [mailto:[EMAIL PROTECTED] Sent: Friday, July 28, 2006 10:10 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Can I use internal variables in SQL scripts? No, because SQLite has no stored procedure capabilities. SQLite has only simple SQL statements. I'm sure the community would welcome such an addition, should you or anyone else fancy contributing them:)
Re: [sqlite] insert default values
Hi Gerry, yes, your help was quite useful... now we have two problems here, I would say: the first one is that, of all the things you have tried, only one is correct but two more are accepted without causing an error. On 2006-0728 06:55:22, Gerry Snyder wrote: > sqlite> create table test(f int auto_increment primary key, v int > default 0); -- no error, not working (I would expect either a syntax error or a 'auto_increment only on integer') > -- > sqlite> create table test(f integer auto_increment primary key, v int > default 0); -- no error, not working (I would expect either a syntax error or complete equivalence with the working version) > -- > sqlite> create table test(f integer primary key auto_increment, v int > default 0); > SQL error: near "auto_increment": syntax error > > sqlite> create table test(f int autoincrement primary key, v int default 0); > SQL error: near "autoincrement": syntax error > - > sqlite> create table test(f int primary key autoincrement, v int default 0); > SQL error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY > -- > sqlite> create table test(f integer primary key autoincrement, v int > default 0); -- all right, this is the only working one, thanks a lot! the next problem is that I still would like to insert into test () values (); or maybe insert into test default values; here sqlite does respond clearly: sqlite> insert into test () values (); SQL error: near ")": syntax error sqlite> insert into test default values; SQL error: near "default": syntax error is it possible to do this in sqlite? Mario -- Gotta run, my government's collapsing.
Re: [sqlite] insert default values
On 7/28/06, Gerry Snyder <[EMAIL PROTECTED]> wrote: Finally, get it right: sqlite> create table test(f integer primary key autoincrement, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; 1|1 2|2 3| Not sure why the last row is not 3|0. Because NULL is allowed for field in question. You can insert default value like this: insert into test (f) values (NULL); Inserting NULL into autoincrement field just increments it. While omitting value for any other field uses default for that field, if one is defined. -- Nemanja Corlija <[EMAIL PROTECTED]>
Re: [sqlite] Can I use internal variables in SQL scripts?
Rob Richardson uttered: In SQL Server, I can write a stored procedure that looks something like this: [snip] Other features available in SQL Server stored procedures include while loops, temporary tables, and the FETCH command to retrieve data from a resultset one row at a time. I have SQLite Explorer and SQLiteSpy. Does either one have similar capabilities? No, because SQLite has no stored procedure capabilities. SQLite has only simple SQL statements. I'm sure the community would welcome such an addition, should you or anyone else fancy contributing them:) Thanks very much! Rob Richardson RAD-CON, Incv. -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: [sqlite] insert default values
Mario Frasca wrote: and how do I insert a 'all-default' record? After getting everything else right (see my previous post): sqlite> insert into test (f) values (NULL); sqlite> select * from test; 1|1 2|2 3| 4|0 And this answers my previous comment, too. Inserting a NULL into v overrides the default. Gerry
Re: [sqlite] insert default values
Gerry Snyder uttered: Finally, get it right: sqlite> create table test(f integer primary key autoincrement, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; 1|1 2|2 3| Not sure why the last row is not 3|0. Because you've explicitly inserted a NULL. The default value is only used if the column is not explicitly specified in the insert. HTH, Gerry -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \
Re: [sqlite] insert default values
Mario Frasca wrote: I'm trying to use default values and autoincrementing primary keys. [EMAIL PROTECTED]:~$ sqlite3 /data/mariof/test.db_scia.db SQLite version 3.3.4 Enter ".help" for instructions sqlite> create table test(f int auto_increment primary key, v int default 0); The above is not correct syntax for what you want. sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (NULL); sqlite> select * from test; |1 |2 |1 | First, recreating your example: $ sqlite3 SQLite version 3.3.6 Enter ".help" for instructions sqlite> create table test(f int auto_increment primary key, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; |1 |2 | -- Next, showing that f is really not what you want: sqlite> select oid,f,v from test; 1||1 2||2 3|| sqlite> drop table test; -- Next, correcting int to integer (no change.. yet) sqlite> create table test(f integer auto_increment primary key, v int default 0) ; sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; |1 |2 | sqlite> drop table test; -- Now, correcting the order: sqlite> create table test(f integer primary key auto_increment, v int default 0); SQL error: near "auto_increment": syntax error Now correct the spelling of autoincrement: sqlite> create table test(f int autoincrement primary key, v int default 0); SQL error: near "autoincrement": syntax error - Now correct the order again: sqlite> create table test(f int primary key autoincrement, v int default 0); SQL error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY -- Finally, get it right: sqlite> create table test(f integer primary key autoincrement, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (NULL); sqlite> select * from test; 1|1 2|2 3| Not sure why the last row is not 3|0. HTH, Gerry
[sqlite] Can I use internal variables in SQL scripts?
In SQL Server, I can write a stored procedure that looks something like this: CREATE PROCEDURE MyProc AS DECLARE @someVariable INT SELECT @someVariable = someColumn FROM someTable WHERE someConditionThatReturnsOneRow SELECT someOtherColumn FROM someOtherTable WHERE thePrimaryKey = @someVariable END PROCEDURE Other features available in SQL Server stored procedures include while loops, temporary tables, and the FETCH command to retrieve data from a resultset one row at a time. I have SQLite Explorer and SQLiteSpy. Does either one have similar capabilities? Thanks very much! Rob Richardson RAD-CON, Incv.
[sqlite] WHERE with user function
Hi, I need user function for WHERE clause. But I don't know what type of parameters to use for such function: SELECT * FROM Table WHERE MYFUNC(ColumnName, IntValue). Above all - how to returm value to WHERE and what type? Is there any example (tutorial or explanation) in C or C++ for similar problem? Thanks Stan -- View this message in context: http://www.nabble.com/WHERE-with-user-function-tf2015394.html#a5539399 Sent from the SQLite forum at Nabble.com.
Re: [sqlite] Problem parsing comments from SQL?
Jeff Nokes <[EMAIL PROTECTED]> wrote: > Hi, > I've run into a weird situation where SQLite seems to not like in-line > comments depending on where they are placed. This is not the SQLite core but the sqlite command-line shell. The command line shell accumulates input until it sees a line that ends with a semicolon. If an input line ends with a semicolon and the accumulated input passes the sqlite3_complete() test, only then is the input passed into the sqlite core to be processed. By putting comments after the semicolons, you are hiding the semicolons from the command-line shell and causing the input processing to be deferred. To insure that input has been processed, put a semicolon on a line by itself. Extra semicolons will not hurt anything. -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] Another question about RAM
"Sarah" <[EMAIL PROTECTED]> wrote: > Can anyone give me some guide? > SQLite memory requirements depends on how it is compiled and how it is used. You should use experiments to determine how much memory is required for your particular project. If SQLITE_ENABLE_MEMORY_MANAGEMENT is defined when you compile, then the global variable contains the highwater mark of your total heap memory utilization. > > - Original Message - > From: "Sarah" <[EMAIL PROTECTED]> > To:> Sent: Thursday, July 27, 2006 3:47 PM > Subject: [sqlite] Another question about RAM > > > > Hi, all > > > > I want to build SQLite on the uc/os-II kernel in an embedded device. > > > > Because uc/os-II doesn't provide malloc(), free() to manage memory, instead, > > it divides the memory into fixed-length blocks and provides OSMemGet() and > > OSMemPut() to > > get and put fixed-length memory block. > > > > In order to port SQLite, I have to wrap uc/os-II with a set of standard > > memory management APIs(malloc, free...). > > So I need to decide in advance that which 'fixed length' will be better. > > That is to say, when using malloc() to > > allocate memory in SQLite, how much memory is needed in most cases? what > > does it depend on? > > > > Thanks. > > > >
Re: [sqlite] sqlite using whole-file (not byte-range) locking
Adam Megacz <[EMAIL PROTECTED]> wrote: > I'm interested in using SQLite with AFS (the Andrew FileSystem). > Unlike NFS, AFS has solid, reliable support for *whole-file* advisory > locking across the network. > > AFS does some very sophisticated caching, so an SQLite database in AFS > accessed by a single reader/writer would be very efficient. A second > reader/writer would cause performance to degrade by breaking callbacks > quite often, but as long as whole-file locking is used, no corruption > should occur. > > I think a scenario where a database is accessed mostly by a single > process but occasionally updated by other clients (for example, for > administration) would work really well. In a lot of applications > (like the one I'm considering) this would eliminate the need for an > "administration API" implemented on the main reader/writer -- > administration could be done using the sqlite3 binary directly on the > database across AFS. > > I read through the locking code: > > http://www.srcdoc.com/sqlite_3.2.2/os__unix_8c-source.html#l00911 > > It looks like it would be possible to do the locking with whole-file > locks on three separate files (less elegant, certainly) rather than > byte range locks if one gave up support for old versions of Windows. > > Does this sound like it would work? Can anybody see any way to do it > with less than three files? AFS offers both read-locks and > exclusive-write-locks on all platforms via fcntl(). > In the latest versions of SQLite (3.3.0 and later) you can provide SQLite with customized locking code at run-time. So you can easily add AFS support that uses whole-file locking instead of the goofy byte-range stuff I have to do for Win95. I expect that code to handle additional locking styles (such as separate lock-file locks for broken NFS systems or for file systems that do not support any kind of locking natively) will be added to the standard SQLite distribution in the near future. If you can wait, you might want to add AFS locking to that module as another option. -- D. Richard Hipp <[EMAIL PROTECTED]>
Re: [sqlite] Another question about RAM
Sarah wrote: >> Because uc/os-II doesn't provide malloc(), free() to manage memory, >> instead, it divides the memory into fixed-length blocks and >> provides OSMemGet() and OSMemPut() to get and put fixed-length >> memory block. >> >> In order to port SQLite, I have to wrap uc/os-II with a set of >> standard memory management APIs(malloc, free...). So I need to >> decide in advance that which 'fixed length' will be better. That is >> to say, when using malloc() to allocate memory in SQLite, how much >> memory is needed in most cases? what does it depend on? I suspect nobody really knows. I don't know your platform but you might have some luck compiling a debugging malloc library that gives you some stats. http://www-128.ibm.com/developerworks/linux/library/l-debug/ describes a couple - the MEMWATCH or YAMD tools might do what you want. There might be some utility in building sqlite on a Linux box with the above libraries. You could put a thin wrapper around calls to malloc, run some queries and dump the stats to a file for analysis. Martin
Re: [sqlite] Another question about RAM
Can anyone give me some guide? - Original Message - From: "Sarah" <[EMAIL PROTECTED]> To:Sent: Thursday, July 27, 2006 3:47 PM Subject: [sqlite] Another question about RAM > Hi, all > > I want to build SQLite on the uc/os-II kernel in an embedded device. > > Because uc/os-II doesn't provide malloc(), free() to manage memory, instead, > it divides the memory into fixed-length blocks and provides OSMemGet() and > OSMemPut() to > get and put fixed-length memory block. > > In order to port SQLite, I have to wrap uc/os-II with a set of standard > memory management APIs(malloc, free...). > So I need to decide in advance that which 'fixed length' will be better. That > is to say, when using malloc() to > allocate memory in SQLite, how much memory is needed in most cases? what does > it depend on? > > Thanks. > >
[sqlite] insert default values
I'm trying to use default values and autoincrementing primary keys. [EMAIL PROTECTED]:~$ sqlite3 /data/mariof/test.db_scia.db SQLite version 3.3.4 Enter ".help" for instructions sqlite> create table test(f int auto_increment primary key, v int default 0); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (2); sqlite> insert into test (v) values (1); sqlite> insert into test (v) values (NULL); sqlite> select * from test; |1 |2 |1 | I'm not a great fan of the auto_increment feature, I like sequences a lot better, but as sqlite recognizes it, does it also implement it? the documentation states "the requested feature was added in 3.1", I'm testing with 3.3.4... and how do I insert a 'all-default' record? sqlite> insert into test default values; SQL error: near "default": syntax error sqlite> insert into test () values (); SQL error: near ")": syntax error actually, missing auto_increment and sequences, inserting an 'all default' record is just a style exercise, not really particularly useful... thanks, Mario Frasca -- Die Welt wird nicht bedroht von den Menschen, die böse sind, sondern von denen, die das Böse zulassen -- Albert Einstein
Re: [sqlite] User function in WHERE clause
Thanks for tip. I'm happy to see it's possible. Alas, I'm rather confused. I have read documentation, but I'm not sure what parameters to use and what return value for WHERE clause. Can you be so kind and show me a skeleton (C++) function for this: SELECT * FROM Table WHERE MYFUNC(ColumnName, IntValue) ? And how to include MYFUNC to SQLite ? ... you see - troubles of a beginner :-). Thanks Stan -- View this message in context: http://www.nabble.com/User-function-in-WHERE-clause-tf2009603.html#a5535131 Sent from the SQLite forum at Nabble.com.