Re: [sqlite] Update Query

2012-05-29 Thread Pavel Ivanov
On Tue, May 29, 2012 at 6:05 AM, IQuant wrote: >>CREATE VIEW TICKMAX >>AS >> SELECT ASK, BID, TRADEPRICE, TIMESTAMP, SYMBOL >>    FROM TICKDATA >>   WHERE TIMESTAMP = MAX(TIMESTAMP) >>GROUP BY SYMBOL; > > Trying to work through your suggestions: > I'm getting "Misuse of

Re: [sqlite] Update Query

2012-05-29 Thread IQuant
Keith, Trying to work through your suggestions: I'm getting "Misuse of aggregate max()" >CREATE VIEW TICKMAX >AS > SELECT ASK, BID, TRADEPRICE, TIMESTAMP, SYMBOL >FROM TICKDATA > WHERE TIMESTAMP = MAX(TIMESTAMP) >GROUP BY SYMBOL; ___

Re: [sqlite] Update Query

2012-05-28 Thread Simon Slavin
On 29 May 2012, at 1:16am, IQuant wrote: > I may try a 2 pass approach: Pass 1 update query to record the rowid > of the previous symbol record and pass 2 use a join for performing the > IQ calcs. Yep. Just do it in your programming language. One SELECT to find the

Re: [sqlite] Update Query

2012-05-28 Thread IQuant
Not sure how to combine the subqueries. Our TickData table looks close to: TimeStamp, Symbol, Ask, Bid, Last ... IQ_A, IQ_B, IQ_T, IQ_X We need to update the IQ fields with calculations always made between the current record and previous symbol record ordered by timestamp. I don't know how to

Re: [sqlite] Update Query

2012-05-24 Thread Keith Medcalf
l Message- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of > To: General Discussion of SQLite Database > Subject: Re: [sqlite] Update Query > > > > > Simon. > ___ > sq

Re: [sqlite] Update Query

2012-05-24 Thread Simon Slavin
On 25 May 2012, at 3:04am, IQuant wrote: > update TICKDATA set IQ_A = ROUND(ASK - ( > select t2.ASK from TICKDATA t2 > where t2.SYMBOL = TICKDATA.SYMBOL and t2.TIMESTAMP < > TICKDATA.TIMESTAMP ORDER BY T2.SYMBOL, t2.timestamp DESC LIMIT 1),4), > IQ_B = ROUND(BID - ( >

Re: [sqlite] Update Query

2012-05-24 Thread IQuant
Thanks for your suggestion Igor Tandetnik: Scope creep expanded the original query to the actual trading instruments and the refactored code has evolved to:: update TICKDATA set IQ_A = ROUND(ASK - ( select t2.ASK from TICKDATA t2 where t2.SYMBOL = TICKDATA.SYMBOL and t2.TIMESTAMP <

Re: [sqlite] Update query along with limit option

2009-04-19 Thread thirunavukarasu selvam
Thanks for ur equivalent query. Its working as expected using rowid will not be prob rightAs long as its value is unique. Regards, Thiru. On Sun, Apr 19, 2009 at 8:33 PM, Igor Tandetnik wrote: > "thirunavukarasu selvam" > wrote in message >

Re: [sqlite] Update query along with limit option

2009-04-19 Thread thirunavukarasu selvam
status is basically used for display Always new row is added with status 0 Once its been displayed the status has to be changed to 1. Its just to track of rows displayed and new added rows. On Sun, Apr 19, 2009 at 12:51 PM, John Machin wrote: > On 19/04/2009 5:06 PM,

Re: [sqlite] Update query along with limit option

2009-04-19 Thread Igor Tandetnik
"thirunavukarasu selvam" wrote in message news:5b5250670904190006h7faba51ejbd9c392c0584c...@mail.gmail.com > I need a help in using update query along with limit option. > I tried the following query > update table-name SET status='1' where status='0' limit 2 > status - column

Re: [sqlite] Update query along with limit option

2009-04-19 Thread John Machin
On 19/04/2009 5:06 PM, thirunavukarasu selvam wrote: > I tried the following query > update table-name SET status='1' where status='0' limit 2 > status - column name. What is "status - column name" meant to do? > I am using sqlite-amalgamation-3.6.13.tar.gz source from sqlite.org. > > I

[sqlite] Update query along with limit option

2009-04-19 Thread thirunavukarasu selvam
Hello all, Am new to sqlite. I need a help in using update query along with limit option. I tried the following query update table-name SET status='1' where status='0' limit 2 status - column name. I need to update the value of status columns having value 0 to value 1. That too for only 2

Re: [sqlite] UPDATE query: why is that code sooo slow?

2005-01-22 Thread D. Richard Hipp
On Sat, 2005-01-22 at 11:50 -0500, Luc Vandal wrote: > Perhaps Iâm not doing things correctly, but this code will take about 1 > minute to execute (2400 records on a total of around 44000 records): > > for(INT nCurrRow=1;nCurrRow<=nRows;nCurrRow++) >

Re: [sqlite] UPDATE query: why is that code sooo slow?

2005-01-22 Thread Clay Dowling
Gwendolynn ferch Elydyr wrote: I seem to recall that there was a significant performance difference between using sqlite3_exec vs prepared statements. You might try using sqlite3_prepare/bind/finalize. I would add that you need to do all of your database retreiving before starting the updating.

RE: [sqlite] UPDATE query: why is that code sooo slow?

2005-01-22 Thread Gwendolynn ferch Elydyr
On Sat, 22 Jan 2005, Luc Vandal wrote: Wrap he updates in a transaction. I'm already doing that (unless I'm doing it wrong?): nRet = sqlite3_exec( m_pDB, _T("BEGIN;"), 0, 0, ); ... nRet = sqlite3_exec( m_pDB, _T("COMMIT;"), 0, 0, ); I seem to recall that there was a significant performance

Re: [sqlite] UPDATE query: why is that code sooo slow?

2005-01-22 Thread Scott Wilkinson
Luc Vandal wrote: Hi, Perhaps I’m not doing things correctly, but this code will take about 1 minute to execute (2400 records on a total of around 44000 records): Wrap he updates in a transaction. See http://www.sqlite.org/lang_transaction.html for the syntax. -- Scott Wilkinson MICROS

[sqlite] UPDATE query: why is that code sooo slow?

2005-01-22 Thread Luc Vandal
Hi, Perhaps I’m not doing things correctly, but this code will take about 1 minute to execute (2400 records on a total of around 44000 records): Basically, I’m getting records that need to be updated. Then, I go through each record and update it. Should be fast IMHO but I don’t see why it’s