RE: [sqlite] Limit statement size?

2007-01-29 Thread Joe Wilson
--- RB Smissaert <[EMAIL PROTECTED]> wrote:
> Thanks, that is how I understood it to be.
> I must be overlooking something simple here.

Check your SELECT sub-statement within the REPLACE statement to see 
what rows it returns.

.header on
.mode tabs

create table t1(id primary key, e2_a, e2_b, e3_a, e3_b);
insert into t1 values(3, 30,31, 23,230);
insert into t1 values(4, 40,41, 24,240);
insert into t1 values(5, 50,51, 25,250);

create table e2(id primary key, a, b);
insert into e2 values(3, 300, 310);
insert into e2 values(4, 400, 410);
insert into e2 values(5, 500, 510);

create table e3(id primary key, a, b);
insert into e3 values(3, 23.1, 230.1);
insert into e3 values(4, 24.1, 240.1);
insert into e3 values(5, 25.1, 250.1);

select * from t1 order by id;

replace into t1(id, e2_a, e2_b, e3_a, e3_b)
  select t1.id, e2.a, e2.b, e3.a, e3.b
  from t1, e2, e3 
  where t1.id = e2.id and t1.id = e3.id;

select * from t1 order by id;

id  e2_ae2_be3_ae3_b
3   30  31  23  230
4   40  41  24  240
5   50  51  25  250

id  e2_ae2_be3_ae3_b
3   300 310 23.1230.1
4   400 410 24.1240.1
5   500 510 25.1250.1


> 
> RBS
> 
> -Original Message-
> From: Gerry Snyder [mailto:[EMAIL PROTECTED] 
> Sent: 29 January 2007 23:52
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Limit statement size?
> 
> RB Smissaert wrote:
> > Had a go at this, but sofar I haven't been able yet to get it to work.
> > I get no error, but A3Test115_J remains just at it is.
> > I couldn't find much information about INSERT OR REPLACE in the SQLite
> > documentation. What exactly should it do?
> 
> It will try to do an INSERT. If the PATIENT_ID field is already in the 
> file, it will delete the old conflicting entry before inserting.
> 
> The best write-up is at:
> 
> http://sqlite.org/lang_conflict.html
> 
> 
> HTH,
> 
> Gerry



 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] SQLite documentation

2007-01-29 Thread P Kishor

On 1/29/07, Clark Christensen <[EMAIL PROTECTED]> wrote:

Puneet,

How about "make doc"?  If you have TCL, that seems to generate the
HTML output in ./doc.  If you don't, I'd be happy to send it to you.


Thanks Clark. I had, and it did. Me happy.

I am wondering though, how would I have known this if Clark hadn't
shown me how? I did ./configure --help, and that didn't seem to point
me anywhere. I poked around on sqlite.org, and didn't find anything
there as well. Maybe I missed something obvious...




- Original Message 
From: P Kishor <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, January 29, 2007 10:13:05 AM
Subject: [sqlite] SQLite documentation

Isn't there a way to generate html documentation for SQLite from the
source files? I have a www folder with a bunch of Tcl files (which
seem like I need to run them through Tcl to get html out), but no
html. I am missing something obvious, so please point me in the right
direction.




--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
-
collaborate, communicate, compete
=

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] SQLite documentation

2007-01-29 Thread Clark Christensen
Puneet,

How about "make doc"?  If you have TCL, that seems to generate the HTML output 
in ./doc.  If you don't, I'd be happy to send it to you.

 -Clark

- Original Message 
From: P Kishor <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, January 29, 2007 10:13:05 AM
Subject: [sqlite] SQLite documentation

Isn't there a way to generate html documentation for SQLite from the
source files? I have a www folder with a bunch of Tcl files (which
seem like I need to run them through Tcl to get html out), but no
html. I am missing something obvious, so please point me in the right
direction.

-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
-
collaborate, communicate, compete
=

-
To unsubscribe, send email to [EMAIL PROTECTED]
-





-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Limit statement size?

2007-01-29 Thread RB Smissaert
Thanks, that is how I understood it to be.
I must be overlooking something simple here.

RBS

-Original Message-
From: Gerry Snyder [mailto:[EMAIL PROTECTED] 
Sent: 29 January 2007 23:52
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Limit statement size?

RB Smissaert wrote:
> Had a go at this, but sofar I haven't been able yet to get it to work.
> I get no error, but A3Test115_J remains just at it is.
> I couldn't find much information about INSERT OR REPLACE in the SQLite
> documentation. What exactly should it do?

It will try to do an INSERT. If the PATIENT_ID field is already in the 
file, it will delete the old conflicting entry before inserting.

The best write-up is at:

http://sqlite.org/lang_conflict.html


HTH,

Gerry


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Limit statement size?

2007-01-29 Thread Gerry Snyder

RB Smissaert wrote:

Had a go at this, but sofar I haven't been able yet to get it to work.
I get no error, but A3Test115_J remains just at it is.
I couldn't find much information about INSERT OR REPLACE in the SQLite
documentation. What exactly should it do?


It will try to do an INSERT. If the PATIENT_ID field is already in the 
file, it will delete the old conflicting entry before inserting.


The best write-up is at:

http://sqlite.org/lang_conflict.html


HTH,

Gerry

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Limit statement size?

2007-01-29 Thread RB Smissaert
Had a go at this, but sofar I haven't been able yet to get it to work.
I get no error, but A3Test115_J remains just at it is.
I couldn't find much information about INSERT OR REPLACE in the SQLite
documentation. What exactly should it do?

RBS

-Original Message-
From: Joe Wilson [mailto:[EMAIL PROTECTED] 
Sent: 28 January 2007 20:37
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] Limit statement size?

I forgot to specify the unique key for the table to be updated 
in the first attempt at INSERT OR REPLACE.

Please try this...

insert or replace into A3Test115_J(
  PATIENT_ID, ---<---
  ENTRY_ID_E2, 
  READ_CODE_E2, 
  TERM_TEXT_E2,
  ...
  NUMERIC_VALUE_E15
 )
 select
  t1.PATIENT_ID,  ---<---
  g2.ENTRY_ID,
  g2.READ_CODE,
  g2.TERM_TEXT,
  ...
  g15.NUMERIC_VALUE
 from 
  A3Test115_J t1, 
  GROUP_2 g2, 
  GROUP_3 g3,
  ... 
  GROUP_15 g15
 where
  t1.PATIENT_ID = g2.PID
  and t1.PATIENT_ID = g3.PID
  and t1.PATIENT_ID = g4.PID
  and t1.PATIENT_ID = g5.PID
  ...
  and t1.PATIENT_ID = g15.PID

--- RB Smissaert <[EMAIL PROTECTED]> wrote:

> Thanks, will have a look at that.
> It definitely looks better.
> 
> RBS


 


Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Hexadecimal literals or MAX_INTEGER definition?

2007-01-29 Thread Brodie Thiesfield
Does sqlite support numeric literals in hexadecimal?
e.g.INSERT INTO table(mask) VALUES (0x);

Additionally, is there a constant like MAX_INTEGER defined which I can
use as the maximum value that an INTEGER field supports (assuming that
types actually exist)?

Regards,
Brodie

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Memory database to file

2007-01-29 Thread David Champagne
Hi,

I've got an application that creates a database with a large number of records 
(millions), and the indexation of the tables is taking a long time.  Once the 
database is initially created, it is never modified.  No records are added or 
deleted.  So, in the case where a user has sufficient memory, I want to offer 
the option to create the entire database in memory, including the indexes, and 
then serialize that to disk.  I am not sure if this is really going to work or 
if it will be more effcient.  I am using the "ATTACH DATABASE" command to 
create a copy of my ":memory:" database.  I can copy copy the tables (see 
below), and I can get a list of the indxes (see further below), but I don't 
know how to copy the indexes.  Also, does anyone know if this method is really 
going to be faster (memory db -> disk db) than doing everything with a disk db? 
 Would the indexes really be copied or just re-created?

//get the list of tables
sql_cmd = "SELECT name FROM SQLITE_MASTER WHERE type = 'table'";
rc = sqlite3_prepare( m_db, sql_cmd.c_str(),(int)sql_cmd.length(), ,  
);

std::vector tables;
rc = sqlite3_step(stmt);
while ( rc != SQLITE_DONE && rc != SQLITE_ERROR )
{
  tables.push_back((const char*) sqlite3_column_text ( stmt,0 ));
  rc = sqlite3_step(stmt);
}
sqlite3_finalize(stmt); 

//get the list of indexes
sql_cmd = "SELECT name, tbl_name FROM SQLITE_MASTER WHERE type = 'index'";
rc = sqlite3_prepare( m_db, sql_cmd.c_str(),(int)sql_cmd.length(), ,  
);

std::vector> indexes;
rc = sqlite3_step(stmt);
while ( rc != SQLITE_DONE && rc != SQLITE_ERROR )
{
  indexes.push_back(std::pair((const char*) sqlite3_column_text 
( stmt,0 ), (const char*) sqlite3_column_text ( stmt,1 )));
  rc = sqlite3_step(stmt);
}
sqlite3_finalize(stmt);

rc = sqlite3_exec(m_db,"begin;", callback, 0, );

//copy the tables
for (vector::const_iterator it = tables.begin(); it != tables.end(); 
it++)
{
  string sTable = *it;
  sql_cmd = "CREATE TABLE dbdisk." + sTable + " AS SELECT * FROM " + sTable + 
";";
  rc = sqlite3_exec(m_db,sql_cmd.c_str(), callback, 0, );
}

//copy the indexes
for (vector>::const_iterator it = indexes.begin(); it 
!= indexes.end(); it++)
{
  string sIndex = (*it).first;
  string sTable = (*it).second;
  //to be filled in
}

rc = sqlite3_exec(m_db,"commit;", callback, 0, );


 

Don't get soaked.  Take a quick peak at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] SQLite documentation

2007-01-29 Thread P Kishor

Isn't there a way to generate html documentation for SQLite from the
source files? I have a www folder with a bunch of Tcl files (which
seem like I need to run them through Tcl to get html out), but no
html. I am missing something obvious, so please point me in the right
direction.

--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
-
collaborate, communicate, compete
=

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Obtaining randomness on win32

2007-01-29 Thread drh
Marco Bambini <[EMAIL PROTECTED]> wrote:
> I really think that this article
> http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx
> worths a read.
> 
> It talks about the general rand function and the problem of  
> distribution...

SQLite has always used an RC4-based PRNG, not rand(), for exactly
the reasons cited in the article referenced above.  Thanks for the
link though.

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



AW: [sqlite] Obtaining randomness on win32

2007-01-29 Thread Christian Schwarz
> randomness as you need.  But I do not know how to do this on
> win32 and wince.  The current implementation seeds the random

As Michael already suggested, you should use the CryptoAPI
(CryptAquireContext, CryptGenRandom). This API is supported by all 32
bit desktop versions and by Windows CE starting with version 2.10.

Christian

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Obtaining randomness on win32

2007-01-29 Thread drh
John Stanton <[EMAIL PROTECTED]> wrote:
> Have you considered an option where the user can supply the seed so that 
> an application can implement a complete sequence from the pseudo random 
> number generator?
> 

When testing (-DSQLITE_TEST=1) the seed is always 256 bytes of 0x00.  
That way the same random sequence is generated on multiple runs of 
the same test.

If users need to set their own seeds in a standard build, they can 
overload the sqlite3OsRandomSeed() interface using the redefinable I/O 
mechanism.  Let's avoid adding yet another API where it is not absolutely
necessary.

--
D. Richard Hipp  <[EMAIL PROTECTED]>



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Obtaining randomness on win32

2007-01-29 Thread Nuno Lucas

On 1/29/07, Michael Ruck <[EMAIL PROTECTED]> wrote:

On Windows itself you could use the CryptAcquireContext, CryptGenRandom
and CryptReleaseContext. I think that doesn't work on WinCE though.


It will work on Windows CE since version 2.10, as long as the OS was
built with support for it (for those not aware, last Windows CE
version is 6.0).

A link to MSDN is:
http://msdn2.microsoft.com/en-us/library/ms884454.aspx

As the link says, if that function is not available, CeGenRandom() can
be used instead, but it's only available since Windows CE 4.1.

If you intend to use /dev/urandom instead of /dev/random, then I would
think CeGenRandom may be enough for the Windows CE implementation (the
current sqlite port only compiles out of the box for WinCE 4.x+,
anyway).


Regards,
~Nuno Lucas

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Obtaining randomness on win32

2007-01-29 Thread Marco Bambini

I really think that this article
http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx
worths a read.

It talks about the general rand function and the problem of  
distribution...

---
Marco Bambini
http://www.sqlabs.net
http://www.sqlabs.net/blog/
http://www.sqlabs.net/realsqlserver/



On Jan 29, 2007, at 5:14 PM, [EMAIL PROTECTED] wrote:


The pseudo-random number generator (PRNG) in SQLite is becoming more
important so it seem good to make sure it is well seeded.  On
Unix this is easy - just open /dev/urandom and read out as much
randomness as you need.  But I do not know how to do this on
win32 and wince.  The current implementation seeds the random
number generator on these platforms by grabbing a copy of the
current system time.  See the sqlite3WinRandomSeed() function
in os_win.c for details.  This is not a very good method for
seeding a PRNG.

Can someone with more knowledge of win32 and wince please suggest
a better method for seeding the PRNG on those platforms?

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-- 
---

To unsubscribe, send email to [EMAIL PROTECTED]
-- 
---





-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Obtaining randomness on win32

2007-01-29 Thread John Stanton
Have you considered an option where the user can supply the seed so that 
an application can implement a complete sequence from the pseudo random 
number generator?


This might help with Win32. 
http://msdn2.microsoft.com/en-us/library/aa387694.aspx


[EMAIL PROTECTED] wrote:

The pseudo-random number generator (PRNG) in SQLite is becoming more
important so it seem good to make sure it is well seeded.  On
Unix this is easy - just open /dev/urandom and read out as much
randomness as you need.  But I do not know how to do this on
win32 and wince.  The current implementation seeds the random
number generator on these platforms by grabbing a copy of the
current system time.  See the sqlite3WinRandomSeed() function
in os_win.c for details.  This is not a very good method for
seeding a PRNG.

Can someone with more knowledge of win32 and wince please suggest
a better method for seeding the PRNG on those platforms?

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



AW: [sqlite] Obtaining randomness on win32

2007-01-29 Thread Michael Ruck
I'm not sure if this helps, but QueryPerformanceCounter could be
a source of semirandom 64-bit integers. It returns the processors
running time in nanoseconds. I'm not aware of anything, which returns
really random values.

On Windows itself you could use the CryptAcquireContext, CryptGenRandom 
and CryptReleaseContext. I think that doesn't work on WinCE though.

Michael

> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Gesendet: Montag, 29. Januar 2007 17:15
> An: sqlite-users@sqlite.org
> Betreff: [sqlite] Obtaining randomness on win32
> 
> The pseudo-random number generator (PRNG) in SQLite is 
> becoming more important so it seem good to make sure it is 
> well seeded.  On Unix this is easy - just open /dev/urandom 
> and read out as much randomness as you need.  But I do not 
> know how to do this on
> win32 and wince.  The current implementation seeds the random 
> number generator on these platforms by grabbing a copy of the 
> current system time.  See the sqlite3WinRandomSeed() function 
> in os_win.c for details.  This is not a very good method for 
> seeding a PRNG.
> 
> Can someone with more knowledge of win32 and wince please 
> suggest a better method for seeding the PRNG on those platforms?
> 
> --
> D. Richard Hipp  <[EMAIL PROTECTED]>
> 
> 
> --
> ---
> To unsubscribe, send email to [EMAIL PROTECTED]
> --
> ---
> 
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Obtaining randomness on win32

2007-01-29 Thread drh
The pseudo-random number generator (PRNG) in SQLite is becoming more
important so it seem good to make sure it is well seeded.  On
Unix this is easy - just open /dev/urandom and read out as much
randomness as you need.  But I do not know how to do this on
win32 and wince.  The current implementation seeds the random
number generator on these platforms by grabbing a copy of the
current system time.  See the sqlite3WinRandomSeed() function
in os_win.c for details.  This is not a very good method for
seeding a PRNG.

Can someone with more knowledge of win32 and wince please suggest
a better method for seeding the PRNG on those platforms?

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] enforcing Foreign Keys

2007-01-29 Thread Clark Christensen
To unsubscribe, send email to [EMAIL PROTECTED]

- Original Message 
From: Mag Gam <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Saturday, January 27, 2007 9:13:11 AM
Subject: Re: [sqlite] enforcing Foreign Keys

So...anyone?


On 1/25/07, Martin Jenkins <[EMAIL PROTECTED]> wrote:
>
> Dan McDaniel wrote:
> > Can someone tell me how to unsubscribe. I have sent
> > two messages to the link and have had no luck thank
> > you.
> > --- Mag Gam <[EMAIL PROTECTED]> wrote:
> >
> Send a mail to [EMAIL PROTECTED] - it has directions on how
> to unsubscribe if the standard method fails. I just tried it and
> (assuming all the timestamps are correct) got a response back in a
> fraction over a minute.
>
> Martin
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>




-
To unsubscribe, send email to [EMAIL PROTECTED]
-