Re: [sqlite] Expose struct Mem and struct Vdbe to other application

2014-09-23 Thread James K. Lowden
On Tue, 23 Sep 2014 14:12:19 -0500 "dave" wrote: > sounds like you are trying to 'bind' your column buffers once for > the statement, sort of like we do with, say ODBC. (and sort of like > we do in sqlite for parameters). To wit there is not a means of > doing that, but are you sure these column

Re: [sqlite] An order by problem, maybe a bug?

2014-09-21 Thread James K. Lowden
On Sat, 20 Sep 2014 20:21:29 +0100 Simon Slavin wrote: > > Your suggestion essentially amounts to "names are not > > decomposable, so keep one version for the user and one for the > > system." > > Sorry, I don't think I got that across effectively. If I make up a > database that stores names, I

Re: [sqlite] An order by problem, maybe a bug?

2014-09-20 Thread James K. Lowden
On Fri, 19 Sep 2014 17:40:52 +0100 Simon Slavin wrote: > > Problems arising from the schema you suggest: > > > > 1. select by last name > > 2. select by first name > > 3. duplicate detection[1] > > 4. "however they want" is unknown and idiosyncratic > > 5. "whatever order" may be more than

Re: [sqlite] An order by problem, maybe a bug?

2014-09-20 Thread James K. Lowden
On Fri, 19 Sep 2014 11:42:26 -0700 Roger Binns wrote: > You do realise there are more people in the US than just those born > in the country with good old fashioned roman alphabet 26 ascii > letters? Yes. Did I mention ASCII? --jkl ___ sqlite-use

Re: [sqlite] An order by problem, maybe a bug?

2014-09-19 Thread James K. Lowden
On Fri, 19 Sep 2014 02:02:30 +0100 Simon Slavin wrote: > By the way I wanted to warn you about starting any project with first > name, middle name and last name fields. This leads to problems, and > I would go to some lengths to avoid it if possible. It would be > better to provide two columns:

Re: [sqlite] Create join and add unique column

2014-09-16 Thread James K. Lowden
On Tue, 16 Sep 2014 16:38:09 +0200 RSmith wrote: > On 2014/09/16 15:32, Paul Sanderson wrote: > > select _rowid_, * from tab3 does the trick - thanks all > > Indeed, and if you are pedantic or do not work in a table with > rowids, the solution is to explicitly give the table definition Or not u

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread James K. Lowden
On Tue, 16 Sep 2014 08:59:31 +0200 Jean-Christophe Deschamps wrote: > This would means that if ever an SQL statement encounters divide by > zero, the application will crash with no way handle the situation > gracefully, nor to locate the source of the problem. Seriously, what are you talking a

Re: [sqlite] Divide by 0 not giving error

2014-09-16 Thread James K. Lowden
On Tue, 16 Sep 2014 01:42:11 +0100 Simon Slavin wrote: > > Whether or not something "is an error" is a matter of definition. > > SQLite defines division by zero to be NULL. It's very unusual in > > that regard. > MySQL does it too unless ERROR_FOR_DIVISION_BY_ZERO mode is enabled: ... > Postgre

Re: [sqlite] Divide by 0 not giving error

2014-09-15 Thread James K. Lowden
On Mon, 15 Sep 2014 21:13:01 +0100 Simon Slavin wrote: > > I suppose we then get into a discussion of what is the 'correct > > result'. I completely understand that NULL is unknown, but I've > > always thought that there is a difference between unknown and > > 'error'. > > It is not an error to

Re: [sqlite] presentation about ordering and atomicity of filesystems

2014-09-14 Thread James K. Lowden
On Sat, 13 Sep 2014 15:43:00 -0400 Richard Hipp wrote: > There were often restrictions on the permitted values for block > sizes. And you couldn't ask the operating system to tell you whether > a file was text or binary or sequential or random-access or what its > block-size was; you just had t

Re: [sqlite] presentation about ordering and atomicity of filesystems

2014-09-13 Thread James K. Lowden
On Sat, 13 Sep 2014 01:07:59 +0100 Simon Slavin wrote: > > Implement a block-transaction store on the device > > itself: no inodes, no directories, just writeable blocks managed in > > transactions. Build your DBMS on that. > > That would be ... erm ... perhaps a new disk volume format. Wher

Re: [sqlite] presentation about ordering and atomicity of filesystems

2014-09-12 Thread James K. Lowden
On Fri, 12 Sep 2014 19:38:53 +0100 Simon Slavin wrote: > I don't think it can be done by trying to build it on top of an > existing file system. I think we need a file system (volume format, > drivers, etc.) built from the ground up with > atomicity/ACID/transactions in mind. Since the greatest

Re: [sqlite] Window functions?

2014-09-11 Thread James K. Lowden
On Wed, 27 Aug 2014 18:25:28 -0600 "Keith Medcalf" wrote: > >> select id, category_id, name, min(price) as minprice > >>from cat_pictures > >> group by category_id; > > >This peculiar behavior is very unique to SQLite. > > Not really. Sybase, SQL Server and DB2 do (or did do) the same thi

Re: [sqlite] SQLite version 3.8.6 coming soon

2014-08-08 Thread James K. Lowden
On Wed, 6 Aug 2014 20:56:24 -0400 Richard Hipp wrote: > > http://www.perfectyourenglish.com/vocabulary/backward-backwards.htm > > > > Two countries divided by a common tongue. > > > Except, I speak Southern English, not British English. And I can > promise you that we southerners prefer to add th

Re: [sqlite] SQLite version 3.8.6 coming soon

2014-08-06 Thread James K. Lowden
On Wed, 6 Aug 2014 07:40:43 -0400 Richard Hipp wrote: > > > > PS: backward compatibility, no s, no? > > > > A google search shows that you see it both ways - with and without the > "s". I've always used the "s". http://www.perfectyourenglish.com/vocabulary/backward-backwards.htm Two countries

Re: [sqlite] Expected behaviour of COUNT with no GROUP BY?

2014-08-04 Thread James K. Lowden
On Mon, 04 Aug 2014 18:36:24 +0200 RSmith wrote: > > I guess I still find the combination of COUNT > > without a GROUP BY to be unintuitive, but at least I know why now. > > As far as I know, there is no requirement for a group by clause for > any of the functions really, a table or any SELECT

Re: [sqlite] Only allow child record if another field in parent is false.

2014-07-31 Thread James K. Lowden
On Fri, 1 Aug 2014 09:26:14 +1200 Richard Warburton wrote: > This way, you can't change the leaver field if enrolmentItems are > attached, and you can't add an enrolmentItem if leaver is set to 1. IIUC, you have tables A and B, and the rules are you can add/delete rows in B while A.bo

Re: [sqlite] Counting changes in a INSERT/REPLACE

2014-07-30 Thread James K. Lowden
On Tue, 29 Jul 2014 16:49:04 -0400 "jose isaias cabrera" wrote: > BEGIN; > INSERT OR REPLACE INTO A > SELECT * FROM client.A WHERE id = 1 AND Date != '2014-06-22'; > INSERT OR REPLACE INTO A > SELECT * FROM client.A WHERE id = 2 AND Date != '2014-06-22'; > ... > ... >

Re: [sqlite] sqlite bug after CREATE UNIQUE INDEX

2014-07-30 Thread James K. Lowden
On Wed, 30 Jul 2014 09:10:29 +0400 Pavel Pimenov wrote: > CREATE TABLE fly_hash_block(tth_id integer PRIMARY KEY NOT NULL, tth > number NOT NULL); > INSERT INTO fly_hash_block VALUES(1,1); > INSERT INTO fly_hash_block VALUES(2,2); > INSERT INTO fly_hash_block VALUES(3,2); > *CREATE UNIQUE INDEX i

Re: [sqlite] Variable values in Views

2014-07-28 Thread James K. Lowden
On Mon, 28 Jul 2014 14:53:34 +0100 Jonathan Moules wrote: > Fair question, but I'm doing log analysis. Each set of tables will be > for a given server that's being analysed. The application that uses > the data is a read-only web-app, so my database needs to be optimised > for SELECT queries. Wh

Re: [sqlite] SQL Join question

2014-07-28 Thread James K. Lowden
On Mon, 28 Jul 2014 16:20:38 -0400 Igor Tandetnik wrote: > On 7/28/2014 4:10 PM, Drago, William @ MWG - NARDAEAST wrote: > > Can someone tell me what the purpose of line 2 is in the following > > example? It seems redundant to me since what is wanted from the > > Customers table is specified on l

Re: [sqlite] ISO time leap second.

2014-07-28 Thread James K. Lowden
On Mon, 28 Jul 2014 16:32:42 -0500 Nico Williams wrote: > The word "solar" does not appear on > http://sqlite.org/lang_datefunc.html . Instead it's explicitly stated > that "Universal Coordinated Time (UTC) is used". Quite. > Still, ISTM that "UTC is used" implies handling of leap seconds, a

Re: [sqlite] Addressing columns in an attached db

2014-07-23 Thread James K. Lowden
On Wed, 23 Jul 2014 20:00:52 -0600 "Keith Medcalf" wrote: > BEGIN; > INSERT OR REPLACE INTO LSOpenProjects > SELECT * FROM client.LSOpenProjects as A > WHERE A.ProjID <= 133560 AND > Date != A.Date AND > A.login = 'user1'; > END; > > I presume that LSOpenProje

Re: [sqlite] Hexadecimal integer literals

2014-07-23 Thread James K. Lowden
On Wed, 23 Jul 2014 07:07:25 -0400 Richard Hipp wrote: > Hex literals are useful in conjunction with the bit-wise AND and OR > operators (& and |) and in applications that make use of bit fields. ... > The current SQLite implementation (on the "hex-literal" branch) works > by converting hex liter

Re: [sqlite] Importing a cvs file

2014-07-20 Thread James K. Lowden
On Sat, 19 Jul 2014 17:34:42 +0100 Simon Slavin wrote: > > Better might be to use ASCII as designed. It defines position 30 > > as a record separator. > > I'm clarifying that only to stop someone writing wrong code, not to > be annoying. > > ASCII 30 is Record Separator. Use this where you mi

Re: [sqlite] Importing a cvs file

2014-07-19 Thread James K. Lowden
On Fri, 18 Jul 2014 07:53:57 -0700 Jonathan Leslie wrote: > What I do is I never use a CSV file as a "Comma separated Values" > file but rather as a "Character separated Values"  file, but rather > use a Character, º (0186), a legal character but not one on the > keyboard, as the separator charac

Re: [sqlite] Selecting from view gives bad column information when view name is used in quotes in select statement

2014-07-14 Thread James K. Lowden
On Sun, 13 Jul 2014 22:45:27 +0200 Clemens Ladisch wrote: > > There is no contract of which column names should be returned, no > > "incorrect" headers and no guarantee, and no obligation from the > > standard or any other requirement. > > But these particular column names do not look as if they

Re: [sqlite] Selecting from view gives bad column information when view name is used in quotes in select statement

2014-07-14 Thread James K. Lowden
On Sun, 13 Jul 2014 22:54:52 +0100 Simon Slavin wrote: > > sqlite> select "TestView"."id", "TestView"."data2" from TestView; > > TestViewTestView > > -- -- > > 1 Miranda ... > It's also not 'wrong' with regard to the SQL specification. SQL does > not define any com

Re: [sqlite] think I need better error-handling guidance in the C API

2014-07-06 Thread James K. Lowden
On Sat, 5 Jul 2014 17:48:41 +0100 Klaas V wrote: > James K. Lowden wrote: > > >If the answer to every question, concern, and suggestion is that it > >already works for millions of programs, there is no point in > >discussion or further development.  Just use what's

Re: [sqlite] Building for vxWorks

2014-07-04 Thread James K. Lowden
On Fri, 4 Jul 2014 09:52:00 + Andy Ling wrote: > #if OS_VXWORKS && USING_DOSFS > if ( errno == S_dosFsLib_FILE_NOT_FOUND ) > #else > if( errno==ENOENT ) > #endif If I might suggest, unless ENOENT is defined: #if OS_VXWORKS && USING_DOSFS # define ENOENT S_dosFsLib_FILE_NOT_FOUND #en

Re: [sqlite] think I need better error-handling guidance in the C API

2014-07-04 Thread James K. Lowden
On Thu, 03 Jul 2014 19:00:21 +0200 RSmith wrote: > > A vague citation to a million anonymous programs of unknown quality > > is not a convincing reason to think otherwise. And you and I both > > know that a random sample of 1 million programs will contain > > roughly 999000 crappy ones. :-) > >

Re: [sqlite] Problem with many connections

2014-07-02 Thread James K. Lowden
On Wed, 2 Jul 2014 17:18:23 +0100 Simon Slavin wrote: > I hope SQLite4 changes this and if there are statements still open > either returns an error code or automatically closes any open > statements. Or both. Me too. I can't think of any other application I use that doesn't free all resources

[sqlite] Aggragate functions

2014-07-01 Thread James Nash
to distinguish 0.0 from null is small and good programming should deal with the question reason - mathematically the sum is not defined if there is no data. ___ James Nash +46 70-160 29 54, home +46 8-437 541 01

Re: [sqlite] Adding WHERE to query --> database disk image is malformed

2014-06-30 Thread James K. Lowden
On Tue, 24 Jun 2014 22:06:15 -0700 Jerry Krinock wrote: > > The most likely explanation is that it got processed by something > > which thought it should be treated as ASCII text and was doing a > > spurious LF-to-CR translation. If there was only one 0x0A byte in > > the "good" file, then that i

Re: [sqlite] Sequential numbers

2014-06-30 Thread James K. Lowden
On Tue, 24 Jun 2014 21:02:22 +0100 "Dave Wellman" wrote: > 2) Assuming that my processing follows this pattern: empty table > T1 completely, insert a number of rows, insert/select from T1 into > T2. On the 'select' processing will the 'rowid' > ** always ** start at 1? http://www.schemaman

Re: [sqlite] Help on forming the correct aggregation statement with a Union clause

2014-05-19 Thread James K. Lowden
On Mon, 19 May 2014 21:58:58 -0500 Wendy wrote: > I'm still not getting the results I need for this query: anyone with > any idea, help greatly appreciated. > > "SELECT AwayTeam As 'Team', CASE WHEN (AwayTeamScore > HomeTeamScore) > THEN 3 WHEN (AwayTeamScore=HomeTeamScore) THEN 1 ELSE 0 END AS

Re: [sqlite] Pre-preparing querys

2014-05-19 Thread James K. Lowden
On Mon, 19 May 2014 20:35:54 -0400 Richard Hipp wrote: > > > On 19 May 2014, at 10:21pm, Roger Binns > > > wrote: > > > > > > > It seems like most language wrappers for SQLite include some > > > > sort of statement cache because it is generally useful. It > > > > seems like the sort of thing th

Re: [sqlite] Pre-preparing querys

2014-05-19 Thread James K. Lowden
On Mon, 19 May 2014 22:26:29 +0100 Simon Slavin wrote: > On 19 May 2014, at 10:21pm, Roger Binns wrote: > > > It seems like most language wrappers for SQLite include some sort of > > statement cache because it is generally useful. It seems like the > > sort of thing that would be helpful withi

Re: [sqlite] how to write this commands?

2014-05-19 Thread James K. Lowden
On Mon, 19 May 2014 09:55:25 +0300 Paul wrote: > > UPDATE adla1 > > SET pflopf = ( > > SELECT pflopf > > FROM adl > > WHERE adl.ref = adla1.ref) > > WHERE ( > > SELECT COUNT(*) > > FROM ( > > SELECT 1 FROM adl > > WHERE adl.ref = adla1.ref > > LIMIT 2 > > ) > > ) = 1; > > > > Not all sure

Re: [sqlite] Is sqlite case-sensitive?

2014-05-18 Thread James K. Lowden
On Sun, 18 May 2014 19:15:18 +0200 RSmith wrote: > > As Igor says, http://sqlite.org/c3ref/prepare.html would be > > appropriate. However, a database connection is required for this. > > But of course What kind of syntactical correctness can you hope > to check without a connection? You co

Re: [sqlite] how to write this commands?

2014-05-16 Thread James K. Lowden
On Thu, 15 May 2014 18:02:43 +0300 Paul wrote: > > update adla1 set PFLOPF=(SELECT pflopf from adl where > > adla1.ref=adl.ref) where select count(adl.ref) from adl=1; > > A bit optimized version... > > UPDATE adla1 > SET pflopf = (SELECT pflopf FROM adl WHERE adl.ref = adla1.ref) > WHERE (SE

Re: [sqlite] Using SQLite's VFS in C++

2014-05-13 Thread James K. Lowden
On Tue, 13 May 2014 13:43:09 +0200 Ralf wrote: > A "File" splits its content into several fixed-sized encrypted blocks > and stores those blocks on some kind of storage. > At any point in time, it is guaranteed, that no other process will > interfere and use those blocks, so we don't need any loc

Re: [sqlite] select 1 where 1 - 1;

2014-05-04 Thread James K. Lowden
On Fri, 2 May 2014 21:09:46 +0200 Petite Abeille wrote: > > On May 2, 2014, at 8:54 PM, Richard Hipp wrote: > > > I'm guessing that Mr. Abeille is upset that SQLite ? > > ? doesn?t even bother with SQL syntax and will happily accept any old > junk as a sorry excuse for a query. > > select 1

Re: [sqlite] BLOBs and NULLs

2014-04-21 Thread James K. Lowden
On Mon, 21 Apr 2014 13:30:15 + "Drago, William @ MWG - NARDAEAST" wrote: > Should I split this table up into smaller tables to eliminate the > NULLs (e.g. use one table each for IL, Phase, RL, Isolation)? I'm not > sure what the best design choice would be. While Dr. Hipp's answer focussed o

Re: [sqlite] WITHOUT ROWID problem and large number of row updating

2014-04-16 Thread James K. Lowden
On Wed, 16 Apr 2014 10:24:51 -0700 Joseph Yesselman wrote: > sql = "CREATE TABLE two_way(" \ > "id VARCHAR(50) NOT NULL," \ > "names VARCHAR(2000)," \ > "rs VARCHAR(3000)," \ > "ds VARCHAR(2000)," \ > "sugs VARCHAR(2000), " \ > "PRIMARY KEY (id));"; ... > if names is currentl

Re: [sqlite] deleting dupicate rows

2014-04-16 Thread James K. Lowden
On Wed, 16 Apr 2014 16:27:01 +0100 Simon Slavin wrote: > If you really want to do it in the TABLE definition, use the SQLite > shell tool to '.dump' the table as a set of SQL commands, edit the > dump file to add that constraint, then use the SQLite tool to '.read' > the SQL command file. Why no

Re: [sqlite] Bug with some combination of unique/partial indices

2014-04-13 Thread James K. Lowden
On Sun, 13 Apr 2014 06:55:09 -0400 Richard Hipp wrote: > The following simplified test case causes an assertion fault: > > CREATE TABLE t1(a,b); > CREATE UNIQUE INDEX t1ab ON t1(a,b); > CREATE INDEX t1b ON t1(b) WHERE b=1; > INSERT INTO t1(a,b) VALUES(123,456); > UPDATE OR REPLACE t1 SET b=789;

Re: [sqlite] about the apparently arriving soon "threads"

2014-04-09 Thread James K. Lowden
On Wed, 9 Apr 2014 19:07:27 +0200 big stone wrote: > Threading Plumbery is managed via DOS ".bat commands, as below : > - a "main.bat" dos command : > . pre-clears the 4 "ok finished" files, > . launch the 4 threads, > . then check every 2 seconds that all "ok finished" files are > generated.

Re: [sqlite] comma-separated string data

2014-04-04 Thread James K. Lowden
On Fri, 4 Apr 2014 14:20:57 -0400 "peter korinis" wrote: > How do you 'parse' a table entry like: "4,66,51,3009,2,678, ." to > extract these values and use them in an SQL statement, perhaps a > WHERE id='66'? http://www.schemamania.org/sql/#lists HTH, really. --jkl _

[sqlite] Improve documentation of collation callback?

2014-04-03 Thread James Berry
specified what the int lengths represent: bytes, characters? (3) Nor is it specified what the function result is: <0, 0, >0? or -1, 0, 1? (4) Also, I assume that since lengths are given it should never be relied on that the data pointers are null-terminated… is that correct? Thanks!

Re: [sqlite] SQLite3_create_collation

2014-04-02 Thread James Berry
On Apr 2, 2014, at 1:26 PM, Donald Steele wrote: > What I’m talking about that is part of Xcode is the SQLite framework not > APIs. The access to SQLite is done with the Obj C APIs as defined by SQLite. > I am a fairly new developer and may be having some problems keeping up with > folks with

Re: [sqlite] SQLite3_create_collation

2014-04-02 Thread James Berry
nt API that uses SQLite internally but doesn’t expose any SQLite API? Please be clear on this point: if you’re using Core Data then you probably want to be asking questions on a Core Data list, as using SQLite API directly will be problematic. James > > > On Apr 2, 2014, at 12:5

Re: [sqlite] SQLite3_create_collation

2014-04-02 Thread James Berry
On Apr 2, 2014, at 7:36 AM, James Berry wrote: > On Apr 2, 2014, at 7:28 AM, Donald Steele wrote: > >> I read some where in my searches that Apple has “canned” versions of that >> method but I can’t find those either. >> >> Could someone direct me to some b

Re: [sqlite] SQLite3_create_collation

2014-04-02 Thread James Berry
> > Could someone direct me to some basic tutorials or explanations where I can > get a better understanding before I dive in to create my own collation? Can you give us some examples of the data that’s not sorting properly? Is the issue that mixed alpha and numeric fields don’t sort as you

Re: [sqlite] Using a customized collate function to mimic integer array type.

2014-03-21 Thread James K. Lowden
On Fri, 21 Mar 2014 09:35:19 -0500 Ben Peng wrote: > I have an application where data stored in columns can be lists of > integers (e.g. 158;42;76). I cannot really split such record into > multiple records (one for 158, one for 42 etc) and I am currently > storing them as VARCHAR because they re

Re: [sqlite] Once again about random values appearance

2014-02-16 Thread James K. Lowden
> On Fri, Feb 14, 2014 at 6:35 AM, James K. Lowden > wrote: > > > > > select id, (select id from TestTable where id = abs(random() % > > > > 100)) as rndid from TestTable where id=rndid > > > > On Thu, 13 Feb 2014 07:26:55 -0500 > > Richard Hipp w

Re: [sqlite] Once again about random values appearance

2014-02-13 Thread James K. Lowden
> > select id, (select id from TestTable where id = abs(random() % 100)) > > as rndid from TestTable where id=rndid On Thu, 13 Feb 2014 07:26:55 -0500 Richard Hipp wrote: > It is undefined behavior, subject to change depending the specific > version of SQLite, compile-time options, optimization

Re: [sqlite] Field not editable

2014-02-13 Thread James K. Lowden
On Thu, 13 Feb 2014 10:01:28 + Simon Slavin wrote: > Your question is an example of a long term discussion about whether > your entire business philosophy should be encoded within your SQL > databases, with numerous FOREIGN KEYs, CONSTRAINTs and TRIGGERs used > to enforce how you run the busi

Re: [sqlite] Field not editable

2014-02-13 Thread James K. Lowden
On Thu, 13 Feb 2014 21:40:53 +0100 Zsbán Ambrus wrote: > > I want the name of the country can not be changed. > > You can put all the tables you want to be not changable to a separate > database file which you attach as read-only. Use the ATTACH statement > with the URI filename syntax, as docu

Re: [sqlite] Proposed enhancement to the sqlite3.exe command-line shell

2014-02-11 Thread James K. Lowden
On Tue, 11 Feb 2014 16:49:50 -0500 Stephen Chrzanowski wrote: > I don't like the idea of letting the software decide what should be > done based on a configuration file. Hmm, isn't it the other way around? Does the user tell the software what to do via a configuration file? ~/.sqliterc alr

Re: [sqlite] Proposed enhancement to the sqlite3.exe command-line shell

2014-02-10 Thread James K. Lowden
On Mon, 10 Feb 2014 10:23:57 -0500 Richard Hipp wrote: > Proposed Change To Address The Problem: Thank you for addressing this. I for one think you're getting a lot of unhelpful advice. A database application that loses data? As a feature? > (1) Detect double-click launch by looking at argc

Re: [sqlite] help needed for major SQLite problem

2014-02-10 Thread James K. Lowden
On Mon, 10 Feb 2014 16:20:40 -0500 C M wrote: > But this must be a fairly commonly sought need. The solution you > propose where I occasionally export a copy of the db to Dropbox is > great *for backup purposes* but seems to exclude the possibility of > syncing across multiple computers. So wh

Re: [sqlite] FW: Need Help with Golf Handicap Calculation

2014-02-09 Thread James K. Lowden
On Sat, 8 Feb 2014 19:47:44 + Ed Tenholder wrote: > Query: SELECT MAX(ScoreDate),AVG((Score-Rating)*(113.0/Slope))*.96 > FROM (SELECT * FROM (SELECT * FROM (SELECT > ScoreDate,Score,Rating,Slope FROM Scores WHERE Player="Joe Smith" > ORDER BY ScoreDate ASC LIMIT 3) ORDER BY ScoreDate DESC L

Re: [sqlite] Memory-mapped I/O [was: SQLite 3.7.17 preview - 2x faster?]

2014-02-09 Thread James K. Lowden
On Sat, 8 Feb 2014 08:26:43 -0500 Richard Hipp wrote: > > > The memory-mapped I/O is only enabled for windows, linux, mac > > > OS-X, and solaris. We have found that it does not work on > > > OpenBSD, for reasons we have not yet been able to uncove; but as > > > a precaution, memory mapped I/O >

Re: [sqlite] Troubleshooting nested query performance issue

2014-02-03 Thread James K. Lowden
On Mon, 3 Feb 2014 23:49:14 +0100 Petite Abeille wrote: > > I have a query > > Not directly related to your question, but? why oh why do people > molest their queries by gratuitously and pointlessly aliasing > perfectly good table name to meaningless random one letter codes?!? > Masochism? Hey

Re: [sqlite] Fine tuning table indexes

2014-02-02 Thread James K. Lowden
On Sat, 1 Feb 2014 11:21:45 -0500 Stephen Chrzanowski wrote: > Would be interesting to see when and where that single index comes > into play when multiple indexes are defined. create table T (t int primary key, a int , b int); create index Ta on T(a); create index Tb on T(b); select * from T w

Re: [sqlite] Boolean and DataReader

2014-01-30 Thread James K. Lowden
On Thu, 30 Jan 2014 10:49:39 -0500 Stephen Chrzanowski wrote: > What I might suggest you do is instead of checking GetBoolean (Since > it is extremely picky apparently) is use GetInteger != 0. If the > result is ZERO this will return FALSE. (1 != 0 = TRUE; 0 != 0 = > FALSE) If the result is any

Re: [sqlite] Keeping Track of Records of IDs in one table. Possible?

2014-01-29 Thread James K. Lowden
On Wed, 29 Jan 2014 23:37:43 + Simon Slavin wrote: > By the way, once you have this working I would suggest (from my > experience) that you change your database design a little. Instead > of having a table containing just your open jobs, have a table > containing all jobs, and add a "status"

Re: [sqlite] How should I use parenthesis?

2014-01-27 Thread James K. Lowden
On Mon, 27 Jan 2014 18:57:26 +0100 Jean-Christophe Deschamps wrote: > ( > select * from A where x in (subselectA) > left outer join > select * from B where y in (subselectB) > ) > > union all > > ( -- <-- error > select * from B where y in (subselectC) > left outer join > select * from A where

Re: [sqlite] "Common Table Expression"

2014-01-25 Thread James K. Lowden
On Sat, 25 Jan 2014 11:56:32 +0200 Elefterios Stamatogiannakis wrote: > Wouldn't it be better instead of creating a new concept "row > constructor", to use the existing row constructors, also known as > virtual tables? Perhaps. I didn't make up the term; it exists in various other DBMSs, some

Re: [sqlite] "Common Table Expression"

2014-01-24 Thread James K. Lowden
On Fri, 24 Jan 2014 23:51:11 +0100 Petite Abeille wrote: > > It's exactly the same as "SELECT ?", but a little bit easier to > > write. (It behaves like with INSERT, but is now available in every > > place where a SELECT would be allowed.) > > Hmmm? seems rather pointless to me. > > select 1 as

Re: [sqlite] SELECTing from another SELECT

2014-01-23 Thread James K. Lowden
On Thu, 23 Jan 2014 13:28:50 -0600 John McKown wrote: > > SELECT * FROM A WHERE projid = (SELECT projid FROM B WHERE ptask = > > 'a'); > > > > This only returns one record (record 1) where it should return all > > the records with ptask = 'a'. > > No, it is working properly. The reason is that

Re: [sqlite] Mutally dependent JOIN clauses

2014-01-17 Thread James K. Lowden
On Fri, 17 Jan 2014 11:37:59 +0100 Rob Golsteijn wrote: > SELECT * FROM (C LEFT JOIN >    A ON A.a*A.a + B.b*B.b = C.c*c.c) > LEFT JOIN B ON A.a*A.a + B.b*B.b = C.c*c.c; > > The "C LEFT JOIN A" part is to be evaluated first; produces output > for all value in C (only value 5). E

Re: [sqlite] Mutally dependent JOIN clauses

2014-01-16 Thread James K. Lowden
On Thu, 16 Jan 2014 09:47:58 -0500 Igor Tandetnik wrote: > On 1/16/2014 5:21 AM, Rob Golsteijn wrote: > > SELECT * FROM C > > LEFT JOIN A ON A.a*A.a + B.b*B.b = C.c*c.c > > LEFT JOIN B ON A.a*A.a + B.b*B.b = C.c*c.c; > > I'm not sure how SQLite interprets this query. In any case, it >

Re: [sqlite] "Common Table Expression"

2014-01-04 Thread James K. Lowden
On Wed, 1 Jan 2014 23:23:04 +0100 Petite Abeille wrote: > Yes, a ?with? clause is just syntax sugar providing named subqueries. > But this sugar open the door to drastically different ways to write > queries, bringing structure, clarity of thoughts and purpose to > otherwise labyrinthine construc

Re: [sqlite] "Common Table Expression"

2014-01-04 Thread James K. Lowden
On Thu, 2 Jan 2014 01:29:52 + Simon Slavin wrote: > Hmm. Even > > update t set i = i + 1 - 1 > > with i being UNIQUE might be a good test case. Well, that actually works: sqlite> create table t (t int primary key); sqlite> insert into t values (1); sqlite> insert into t values (2); sqlit

Re: [sqlite] "Common Table Expression"

2014-01-01 Thread James K. Lowden
On Wed, 1 Jan 2014 11:04:57 +0100 big stone wrote: > You're right : > *"*CTEs ... add exactly zero to SQLite's capability." > > This is also right : > "C Language ... add exactly zero to Intel X86 processor capability". Dennis Ritchie said C is an idealized assembler over an idealized machine.

Re: [sqlite] "Common Table Expression"

2014-01-01 Thread James K. Lowden
On Tue, 31 Dec 2013 22:20:15 + Simon Slavin wrote: > > Meanwhile, here's a much more important failing that cannot be > > worked around within SQL without a temporary table: > > > > sqlite> create table i ( i int primary key ); > > sqlite> insert into i values (1); > > sqlite> in

Re: [sqlite] "Common Table Expression"

2013-12-31 Thread James K. Lowden
On Tue, 31 Dec 2013 20:43:20 +0100 big stone wrote: > To get CTE in SQLite, I guess we must answer by the example the fears > expressed by Simon and Rsmith. > > I propose the following method : > - unproven-demand : ... > - code size + performance increase fear : It seems to me you have mor

Re: [sqlite] "Common Table Expression"

2013-12-31 Thread James K. Lowden
On Thu, 26 Dec 2013 20:23:33 +0100 big stone wrote: > Indeed, '1' CTE can be replaced by the creation of 'N' temporary > views (or tables), and their deletion after the CTE request. > > CTE is : > - a syntaxic simplification : >. the SQL creator don't have to care about those intermediate >

Re: [sqlite] Bug in SQLITE regarding HAVING?

2013-12-23 Thread James K. Lowden
On Mon, 23 Dec 2013 23:50:30 +0100 "E.Pasma" wrote: > > . See if you can make the simplest possible SELECT that comes up > > with unexpected results. > > select 0 as depth > from(select 1 as depth) > group by null > having depth < 1 > ; > This returns no rows. Thus the HAVING clause refer

Re: [sqlite] GROUP BY months and years using integer data

2013-12-22 Thread James K. Lowden
On Sun, 22 Dec 2013 05:35:55 +0200 RSmith wrote: > Similarly any attribute can be Boolean if it is found to be an > attribute of an object. Giuseppe is not Boolean, but he is human and > likely male, so that: (Giuseppe = Human) is true or 1, and > (Giuseppe = Female) is false or 0. > > For RDBMS

Re: [sqlite] GROUP BY months and years using integer data

2013-12-21 Thread James K. Lowden
On Sat, 21 Dec 2013 17:30:50 +0200 RSmith wrote: > Just move the scope of the grouping and use Nulls in stead of 0's, > like this: > > SELECT stats.which_year AS year, > SUM(CASE WHEN stats.which_month = 1 THEN stats.quantity ELSE NULL > END) AS gen, ELSE NULL is the default sqlite> create t

Re: [sqlite] virtual tables and group by: how could we prevent to retrieve all rows from a vtab and sort them later ?

2013-12-20 Thread James K. Lowden
On Thu, 19 Dec 2013 12:03:48 +0100 Clemens Ladisch wrote: > > Is there a way to force rows to be dispatched (using the group by) > > and aggregated on the fly instead of being stored, sorted and then > > aggregated? > > SQLite can optimize GROUP BY this way only if it can prove that the > table

Re: [sqlite] order by col desc limit 1 logically equivalent to max(col)

2013-12-19 Thread James K. Lowden
On Thu, 19 Dec 2013 15:14:24 +0100 Dominique Devienne wrote: > The selling point of SQL is to declaratively tell the engine what you > need, and let it choose the optimal implementation. So saying that > ORDER BY doesn't know about LIMIT as a matter of fact seems > completely wrong to me. It may

Re: [sqlite] nested query doesn't like aggregates in subquery?

2013-12-19 Thread James K. Lowden
On Thu, 19 Dec 2013 16:56:18 -0500 Simon wrote: > select datetime(bucket*plen,'unixepoch','-5 hour') dt, >(select price from last_trades where tid=opentr) open, Unless I misread it, that subquery returns the price for every row in last_trades whose tid is equal to opentr. If that's not

[sqlite] SQL_STATIC unterminated strings, and sqlite3_result_text

2013-12-15 Thread James K. Lowden
http://www.sqlite.org/c3ref/result_blob.html I found a documentation typo and have a question about SQLITE_STATIC. The documentation for sqlite3_result_text says, "If the 3rd parameter is non-negative, then it must be the byte offset into the string where the NUL terminator would appea

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-12-07 Thread James K. Lowden
On Thu, 05 Dec 2013 17:52:47 -0700 Warren Young wrote: > To prove my point, I decided to divide the SQLite commands[1] into > those that modify the DB and those that do not: > > Has side effects Limited side effects No side effects > ~~ ~~

Re: [sqlite] prepared statemnt for column names and sorting preference

2013-12-07 Thread James K. Lowden
On Thu, 5 Dec 2013 13:48:36 +0400 d b wrote: > Now, I want to write prepared statement for above query. > > select * from emp order by ? ?; //I want to substitute column name > and sorting preference. Remember that parameters stand for data, not SQL. You can use a placeholder anywhere your

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-12-07 Thread James K. Lowden
On Wed, 04 Dec 2013 12:04:07 -0700 Warren Young wrote: > > Determinism is a property of a function; there is no such > > thing as a function that is sometimes deterministic and sometimes > > not. > > databases are about as far from side-effect-free as you can get. I'm not sure what you're refer

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-12-03 Thread James K. Lowden
On Tue, 3 Dec 2013 11:29:03 -0800 Scott Hess wrote: > Probably we should add a new API that allows the application > > to state auxiliary properties about application-defined functions > > (such as whether or not it is "constant", whether or not it can > > return NULL, whether or not it might cha

Re: [sqlite] Percentile function in SQLite 3.8.0 (for the .NET version)

2013-12-01 Thread James K. Lowden
On Fri, 29 Nov 2013 15:38:51 -0800 Hayden Livingston wrote: > I want to find the 25th %ile latency for this rowset. > > (A) How do I create a Percentile Query? http://www.schemamania.org/sql/#rank.rows Rank the rows, multiply the rank by 100, and divide by their count. Choosing the 25th percen

Re: [sqlite] Big number of tables

2013-12-01 Thread James K. Lowden
On Fri, 29 Nov 2013 13:33:59 + Carlos Ferreira wrote: > If I have to create more than 1000 empty tables to initialize my > application document it takes a while.. Why ship an application with logic to create 1000 empty tables? Why not ship 1000 empty tables in a predefined database? --jk

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-11-26 Thread James K. Lowden
On Mon, 25 Nov 2013 19:44:15 +0100 Luuk wrote: > On 25-11-2013 13:41, Simon Slavin wrote: > > I'm wondering whether there's an argument that it should be > > evaluated just once for a transaction. > > I'm still thinking about this question, > > i can think of some benefits if its evaluated just

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-11-24 Thread James K. Lowden
On Sun, 24 Nov 2013 16:53:01 +0200 RSmith wrote: > Similarly if one was to add a function which returns a date-dependant > value, such as 'dayOfWeek(x)' and mark it as deterministic for inside > a single query, that would make sense, even though it would be very > indeterministic (or referentiall

Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.

2013-11-24 Thread James K. Lowden
On Sun, 24 Nov 2013 09:17:20 -0500 Doug Currie wrote: > in computer science we have referential transparency > > http://en.wikipedia.org/wiki/Referential_transparency_ > (computer_science) > > and pure functions > > http://en.wikipedia.org/wiki/Pure_function https://en.wikipedia.org/wiki/Dete

Re: [sqlite] Questions about "INTEGER PRIMARY KEY AUTOINCREMENT" and "UPDATE"

2013-11-22 Thread James K. Lowden
On Thu, 21 Nov 2013 07:29:49 -0600 John McKown wrote: > To get more to your question, what I would do is have another, > boolean, column in my table. I would call it something like > "being_edited". When a user wants to edit a car, I would start a > transaction (BEGIN TRANSACTION). I would then S

Re: [sqlite] What is wrong with this trigger?

2013-11-16 Thread James K. Lowden
On Sun, 10 Nov 2013 14:36:06 -0800 Igor Korot wrote: > Well from strictly mathematical point of view maximum or minimum of > nothing is nothing. And since nothing is 0, than it is zero. Who is the oldest female US president? You largest of a set must be a member of that set. Actually, I susp

Re: [sqlite] executing queries on normalized database

2013-11-16 Thread James K. Lowden
On Sun, 10 Nov 2013 14:54:17 +0400 dd wrote: > After applying normalization, there are twelve tables with foreign > key support. Well done. > For insert/delete operations, it has to execute twelve queries > instead of two. Is it recommended way? Yes. In a user-defined transaction. Each

Re: [sqlite] executing queries on normalized database

2013-11-16 Thread James K. Lowden
On Mon, 11 Nov 2013 18:35:31 +0400 dd wrote: > Can I conclude this way: Foreign keys works pretty well when > application deals with parent keys only. But, application may need to > execute more queries when dealing with child key/tables. Constraints express rules that the DBMS enforces for you.

<    1   2   3   4   5   6   7   8   9   10   >