Re: [sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread Simon Slavin
On 29 Feb 2012, at 12:36pm, hsymington wrote: > Thanks Simon; this does sound like a less headache-driven way of doing it. I > was simplifying things slightly for an example; the actual situation is more > complicated. Okay, that explains it. I'm going to let the

Re: [sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread hsymington
Simon Slavin-3 wrote: > >> Background: I've got a database schema in the form of a text file, which >> some software reads and converts to a SQLite database. I also need php to >> be >> able to read that text file and convert it into a MySQL database. I'm >> trying >> to work out how to define

Re: [sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread Simon Slavin
On 29 Feb 2012, at 11:06am, hsymington wrote: > Simon Slavin-3 wrote: > >>> CREATE TRIGGER UpdateSaleItemDescription BEFORE INSERT ON SaleItem >>> BEGIN >>> SET NEW.SaleItem_Description='Fish'; >>> END; >> >> Yes. You can look at values using 'new.' but you cannot

Re: [sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread hsymington
Simon Slavin-3 wrote: > >> CREATE TRIGGER UpdateSaleItemDescription BEFORE INSERT ON SaleItem >> BEGIN >> SET NEW.SaleItem_Description='Fish'; >> END; > > Yes. You can look at values using 'new.' but you cannot change them. > However, you do not need to. To perform such an operation as you

Re: [sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread Simon Slavin
On 29 Feb 2012, at 10:46am, hsymington wrote: > CREATE TRIGGER UpdateSaleItemDescription BEFORE INSERT ON SaleItem > BEGIN > SET NEW.SaleItem_Description='Fish'; > END; > > [snip] > Is it correct that I can't do the first, or am I misreading the syntax? Yes. You

[sqlite] SET NEW.FieldName in trigger

2012-02-29 Thread hsymington
Hi - In MySQL, I can do CREATE TRIGGER UpdateSaleItemDescription BEFORE INSERT ON SaleItem BEGIN SET NEW.SaleItem_Description='Fish'; END; and I can't do CREATE TRIGGER UpdateSaleItemDescription AFTER INSERT ON SaleItem BEGIN UPDATE SaleItem SET SaleItem_Description='Fish' WHERE