-
-
Notifications
You must be signed in to change notification settings - Fork 261
Open
Description
Here is an example table and procedure for this.
--DROP PROCEDURE ADDMYTABLE;
--DROP TABLE MYTABLE;
--commit;
CREATE TABLE MYTABLE (
FIELDOLD INTEGER
);
SET TERM ^ ;
create or alter procedure ADDMYTABLE (
FIELDOLD integer)
as
begin
insert into MYTABLE ( FIELDOLD)
values ( :FIELDOLD);
end^
SET TERM ; ^When I run the following script, it results in corrupt records in my table.
What am I doing?
- I am alter the procedure to create data records. (I noticed that it doesn't matter what I change, I just have to create an old procedure and couldn't change the content of the procedure anyway).
- In the same script, I create a new field “FIELDNEW” with a default and “not null”.
- Then, at the end of the same script, I execute the procedure.
The result is that the data record is created with “NULL” in “FIELDNEW,” even though that shouldn't be possible.
However, if I reconnect after the “alter procedure,”
I don't get this effect.
I noticed this in Firebird 3.0.4, but it also continues to occur in 5.0.3.
set term ^;
create or alter procedure ADDMYTABLE (
FIELDOLD integer)
as
begin
insert into MYTABLE ( FIELDOLD)
values ( :FIELDOLD);
end^
set term;^
-- The problem here is probably the procedure.
-- When I reconnect after the “alter procedure,” it works.
-- So FieldNew is then set to the default value.
alter table MYTABLE add FIELDNEW bigint default 0 not null;
commit;
execute procedure ADDMYTABLE( 1);
commit;Metadata
Metadata
Assignees
Labels
No labels