Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
sqlite] primary key in another column On 1/26/2018 6:20 PM, Roman Fleysher wrote: > I think I effectively did as you suggested using triggers. I insert NULL into > the ID column to create a row. This triggers the trigger to run update on the > table to populate the columns based on the

Re: [sqlite] primary key in another column

2018-01-26 Thread Igor Tandetnik
On 1/26/2018 6:20 PM, Roman Fleysher wrote: I think I effectively did as you suggested using triggers. I insert NULL into the ID column to create a row. This triggers the trigger to run update on the table to populate the columns based on the just created ID. Is this what you suggested?

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
of Richard Damon [rich...@damon-family.org] Sent: Friday, January 26, 2018 6:50 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column Couldn't you have it access a view which adds the columns by calculation rather than the raw table? (and if you have some tables

Re: [sqlite] primary key in another column

2018-01-26 Thread Richard Damon
] Sent: Friday, January 26, 2018 6:26 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column One question I have, couldn't you just omit the fileName column from the able, and compute it in the select query that is getting the data? On 1/26/18 6:03 PM

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
...@mailinglists.sqlite.org] on behalf of Richard Damon [rich...@damon-family.org] Sent: Friday, January 26, 2018 6:26 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column One question I have, couldn't you just omit the fileName column from the able, and compute

Re: [sqlite] primary key in another column

2018-01-26 Thread Richard Damon
One question I have, couldn't you just omit the fileName column from the able, and compute it in the select query that is getting the data? On 1/26/18 6:03 PM, Roman Fleysher wrote: My implementation of "for Each row" requires all columns to be populated. It is a dumb thing: forEachRow

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
From: sqlite-users [sqlite-users-boun...@mailinglists.sqlite.org] on behalf of Igor Tandetnik [i...@tandetnik.org] Sent: Friday, January 26, 2018 6:10 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column On 1/26/2018 6:03 PM, Roman Fleysher wrote: >

Re: [sqlite] primary key in another column

2018-01-26 Thread Igor Tandetnik
On 1/26/2018 6:03 PM, Roman Fleysher wrote: My implementation of "for Each row" requires all columns to be populated. It is a dumb thing: You said: After table is filled, an operation "for each row" will... I suggest running this UPDATE statement at the end of "table is filled", before "an

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
f Igor Tandetnik [i...@tandetnik.org] Sent: Friday, January 26, 2018 5:56 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column On 1/26/2018 5:47 PM, Roman Fleysher wrote: > I will use this table as a manager. There will be multiple columns holding > various

Re: [sqlite] primary key in another column

2018-01-26 Thread Igor Tandetnik
On 1/26/2018 5:47 PM, Roman Fleysher wrote: I will use this table as a manager. There will be multiple columns holding various file names. The names can be random, but I want humans to be able to easily inspect. After table is filled, an operation "for each row" will get files in some columns

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
qlite-users [sqlite-users-boun...@mailinglists.sqlite.org] on behalf of Igor Tandetnik [i...@tandetnik.org] Sent: Friday, January 26, 2018 5:33 PM To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] primary key in another column On 1/26/2018 4:43 PM, Roman Fleysher wrote: > I would like to use prim

Re: [sqlite] primary key in another column

2018-01-26 Thread Igor Tandetnik
On 1/26/2018 4:43 PM, Roman Fleysher wrote: I would like to use primary key as a way to create unique column entry: CREATE TABLE A( id INTEGER PRIMARY KEY, fileName TEXT NOT NULL) such that file name is always prefix followed by the ID for the content to be: ID fileName 1 prefix_1 2

Re: [sqlite] primary key in another column

2018-01-26 Thread Roman Fleysher
Solved with trigger, but I can not use NOT NULL for the fileName column: CREATE TRIGGER AAA AFTER INSERT ON A BEGIN UPDATE A SET fileName = 'prefix'||NEW.id WHERE id=NEW.id; END; INSERT INTO A (id) VALUES (NULL); INSERT INTO A (id) VALUES (NULL); INSERT INTO A (id) VALUES (NULL); ... Is that