Subject | Borland Interbase 5.6 do that !! (BIG BUG?) and IB6 dialect 1 ? |
---|---|
Author | ivpi |
Post date | 2001-05-16T17:37:50Z |
In my opinion it is a bug :
Please Try :
***************************************************Database DDL****start here
/* Extract Database c:\deposito\test.gdb */
CREATE DATABASE "c:\deposito\test.gdb" PAGE_SIZE 1024
;
/* Table: MYTABLE, Owner: SYSDBA */
CREATE TABLE MYTABLE (ID INTEGER NOT NULL,
F1 NUMERIC(9, 2),
F2 NUMERIC(15, 3),
PRIMARY KEY (ID));
SET TERM ^ ;
/* Triggers only will work for SQL triggers */
CREATE TRIGGER T1 FOR MYTABLE
ACTIVE BEFORE INSERT POSITION 10
as
begin
new.f1 = new.f2 ;
end
^
CREATE TRIGGER T2 FOR MYTABLE
ACTIVE BEFORE UPDATE POSITION 10
as
begin
new.f1 = new.f2 ;
end
^
COMMIT WORK ^
SET TERM ; ^
/* Grant permissions for this database */
***************************************************Database DDL****end here
Now insert data that activate the trigger :
insert into mytable ( id , f2 ) values ( 1 , 23.44)
insert into mytable ( id , f2 ) values ( 2 , 100 )
And finally select:
select * from mytable
ID F1 F2
=========== =========== ======================
1 0.02 23.440
2 0.10 100.000
Please note that F1 is DIVIDED BY 1000 !! .
But changhe the trigger in this way :
Alter TRIGGER T1 FOR MYTABLE
ACTIVE BEFORE INSERT POSITION 10
as
begin
new.f1 = new.f2 * 1 ;
end
and inser new data:
insert into mytable ( id , f2 ) values ( 3 , 23.44)
now select :
select * from mytable
ID F1 F2
=========== =========== ======================
1 0.02 23.440
2 0.10 100.000
3 23.44 23.440
The result is GOOD !!!!! .
Is this a bug or i'm wrong in doing a implicit casting ?
Note that if you use: f1 = cast ( f2 as decimal (9,2)
Please Try :
***************************************************Database DDL****start here
/* Extract Database c:\deposito\test.gdb */
CREATE DATABASE "c:\deposito\test.gdb" PAGE_SIZE 1024
;
/* Table: MYTABLE, Owner: SYSDBA */
CREATE TABLE MYTABLE (ID INTEGER NOT NULL,
F1 NUMERIC(9, 2),
F2 NUMERIC(15, 3),
PRIMARY KEY (ID));
SET TERM ^ ;
/* Triggers only will work for SQL triggers */
CREATE TRIGGER T1 FOR MYTABLE
ACTIVE BEFORE INSERT POSITION 10
as
begin
new.f1 = new.f2 ;
end
^
CREATE TRIGGER T2 FOR MYTABLE
ACTIVE BEFORE UPDATE POSITION 10
as
begin
new.f1 = new.f2 ;
end
^
COMMIT WORK ^
SET TERM ; ^
/* Grant permissions for this database */
***************************************************Database DDL****end here
Now insert data that activate the trigger :
insert into mytable ( id , f2 ) values ( 1 , 23.44)
insert into mytable ( id , f2 ) values ( 2 , 100 )
And finally select:
select * from mytable
ID F1 F2
=========== =========== ======================
1 0.02 23.440
2 0.10 100.000
Please note that F1 is DIVIDED BY 1000 !! .
But changhe the trigger in this way :
Alter TRIGGER T1 FOR MYTABLE
ACTIVE BEFORE INSERT POSITION 10
as
begin
new.f1 = new.f2 * 1 ;
end
and inser new data:
insert into mytable ( id , f2 ) values ( 3 , 23.44)
now select :
select * from mytable
ID F1 F2
=========== =========== ======================
1 0.02 23.440
2 0.10 100.000
3 23.44 23.440
The result is GOOD !!!!! .
Is this a bug or i'm wrong in doing a implicit casting ?
Note that if you use: f1 = cast ( f2 as decimal (9,2)