Re: [sqlite] how to compose the sql sentence?

2009-06-05 Thread liubin liu
Thank you very much! you told me how to do. but I missed the "... defined as UNIQUE ...". Actually my question is just solved by two step: First - CREATE UNIQUE INDEX i_recdata ON rec_data (num, di, time1); Second - INSERT OR REPLACE INTO rec_data (num, di, data, time1, time2, format) VALUES

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread Ibrahim A
Assumptions : Your database scheme contains this declarations CREATE TABLE data ( num INTEGER, di CHAR(4), data CHAR(12), time1 INTEGER, time2 INTEGER, format CHAR(1) ); CREATE UNIQUE INDEX i_data ON data ( num, di, time1 ); You want to do : A)

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread Simon Slavin
On 4 Jun 2009, at 7:39am, liubin liu wrote: > INSERT OR REPLACE INTO data (num, di, time1) VALUES (12, '1290', > '732e4a39', 8323000, 8323255, 22); > > the sqlite3 report a error: > SQL error: 6 values for 3 columns > > Does It mean the method isn't the right way? Here are 6 values: >

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread Martin.Engelschalk
Hi, what do you mean by "command"? The command line tool takes commands entered by the user, such as SQL - statements. These do not have returncodes. If an error occurs, the command line tool will print out the error message. The functions of the sqlite3 library have returncodes, but they can

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread liubin liu
and I think of another question: how to know the return value of a command IN the command-line mode of sqlite3? Martin Engelschalk wrote: > > Hi, > > First, you have to declare the index as unique: > > CREATE UNIQUE INDEX i_data ON data (num, di, time1); > > or - depending on your database

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread liubin liu
Yeah! Thank you very very much! this way could get my goal. but I am afraid the sql will cause some sqlite3 err? Martin Engelschalk wrote: > > Hi, > > First, you have to declare the index as unique: > > CREATE UNIQUE INDEX i_data ON data (num, di, time1); > > or - depending on your

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread Martin.Engelschalk
Hi, First, you have to declare the index as unique: CREATE UNIQUE INDEX i_data ON data (num, di, time1); or - depending on your database design, declare a primary key with these three fields. Second, the error message says it all: You supplied three column - names, but 6 values. Martin

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread liubin liu
the biggest > issue is you only supplied 3 column names but in the values list you have > 6 values. >   > > > --- On Thu, 6/4/09, liubin liu <7101...@sina.com> wrote: > > > From: liubin liu <7101...@sina.com> > Subject: Re: [sqlite] how to compose the

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread Harold Wood
Well you have a column named data and a table named data, but the biggest issue is you only supplied 3 column names but in the values list you have 6 values.   --- On Thu, 6/4/09, liubin liu <7101...@sina.com> wrote: From: liubin liu <7101...@sina.com> Subject: Re: [sqlite] ho

Re: [sqlite] how to compose the sql sentence?

2009-06-04 Thread liubin liu
Thank you a lot! I created a table: CREATE TABLE data ( num INTEGER, di CHAR(4), data CHAR(12), time1 INTEGER, time2 INTEGER, format CHAR(1) ); and create a index: CREATE INDEX i_data ON data (num, di, time1); I want to do: first tell whether there is a record in the table "data" according to

Re: [sqlite] how to compose the sql sentence?

2009-06-03 Thread Simon Slavin
On 3 Jun 2009, at 7:05am, liubin liu wrote: > the first step is to tell if there is the data in the table. > if the answer is not, I want to insert a row of data into the table > if the answer is yes, I need to update the row of data acccording to > the > data inputting from me. INSERT OR

Re: [sqlite] how to compose the sql sentence?

2009-06-03 Thread Harold Wood
look up the insert or replace statement, http://www.sqlite.org/lang_insert.html --- On Wed, 6/3/09, liubin liu <7101...@sina.com> wrote: From: liubin liu <7101...@sina.com> Subject: [sqlite] how to compose the sql sentence? To: sqlite-users@sqlite.org Date: Wednesday, June 3, 2

[sqlite] how to compose the sql sentence?

2009-06-03 Thread liubin liu
the first step is to tell if there is the data in the table. if the answer is not, I want to insert a row of data into the table if the answer is yes, I need to update the row of data acccording to the data inputting from me. -- View this message in context: