Subject | Correct use of "UPDATE OR INSERT...." |
---|---|
Author | Eduardo Lopez |
Post date | 2008-01-31T17:27:14Z |
I'm sorry, my mistake... the CORRECT post is this...
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)
);
UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 10);
UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 2 , 'Something else', 15)
UPDATE OR 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: UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', OLD.MY_QTY + 7)
TIA.
Eduardo Lopez
Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar
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)
);
UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', 10);
UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 2 , 'Something else', 15)
UPDATE OR 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: UPDATE OR INSERT INTO MYTABLE (MY_ID, NAME, MY_QTY) VALUES ( 1 , 'Something', OLD.MY_QTY + 7)
TIA.
Eduardo Lopez
Tarjeta de crédito Yahoo! de Banco Supervielle.
Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar