Subject | Correct use of "UPDATE OR INSERT...." |
---|---|
Author | Eduardo Lopez |
Post date | 2008-01-31T16:31:14Z |
Trying to use the new features of Firebird 2.1 RC1 i'm trying to insert or update a record in a simple table.
CREATE TABLE MYTABLE(
MY_ID Integer NOT NULL,
NAME Char(20),
MY_QTY Integer,
CONSTRAINT PK_MY_ID PRIMARY KEY (MY_ID)
);
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 10);
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 2 , 'Something else', 15)
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 7)
The last statement update the record 1 and changes 10 with 7.
How i can perform an arithmetic operation with these values and, por example, add 10 + 7?
I've tried, but no luck: INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', OLD.MY_QTY + 7)
TIA.
Eduardo Lopez
Los referentes más importantes en compra/ venta de autos se juntaron:
Demotores y Yahoo!
Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/
CREATE TABLE MYTABLE(
MY_ID Integer NOT NULL,
NAME Char(20),
MY_QTY Integer,
CONSTRAINT PK_MY_ID PRIMARY KEY (MY_ID)
);
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 10);
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 2 , 'Something else', 15)
INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 7)
The last statement update the record 1 and changes 10 with 7.
How i can perform an arithmetic operation with these values and, por example, add 10 + 7?
I've tried, but no luck: INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', OLD.MY_QTY + 7)
TIA.
Eduardo Lopez
Los referentes más importantes en compra/ venta de autos se juntaron:
Demotores y Yahoo!
Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/