Issue Details (XML | Word | Printable)

Key: CORE-2041
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Hans Englhauser
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

update or insert with gen_id() with wrong generator value

Created: 13/Aug/08 01:42 PM   Updated: 20/Apr/11 08:40 AM
Component/s: None
Affects Version/s: 2.1.0
Fix Version/s: 2.5 Beta 1

Time Tracking:
Not Specified

Environment: Windows XP, FlameRobin
Issue Links:
Relate

Planning Status: Unspecified


 Description  « Hide
I think this runs wrong:

CREATE GENERATOR LOGID;
set generator LOGID to 0;
CREATE TABLE LOGBOOK
( ID integer not null,
TS timestamp,
ENTRY varchar(64),
PRIMARY KEY (ID));

update or insert into logbook (id, ts, entry) values (gen_id(LOGID, 1), 'now','Testing 1');
update or insert into logbook (id, ts, entry) values (gen_id(LOGID, 1), 'now','Testing 2');
update or insert into logbook (id, ts, entry) values (gen_id(LOGID, 1), 'now','Testing 3');
update or insert into logbook (id, ts, entry) values (gen_id(LOGID, 1), 'now','Testing 4');
select * from logbook;

/* ID in table LOGBOOK is not incremented by 1, but by 3.
Workaround is possible with stored procedure: */

set term ^ ;
create procedure logrow(txt varchar(64)) as
declare variable lid integer;
begin
lid = gen_id(LOGID, 1);
update or insert into logbook (id, ts, entry)
    values (:lid, 'now',:txt);
end^
set term ; ^

execute procedure logrow('Test 1');
execute procedure logrow('Test 2');
execute procedure logrow('Test 3');
execute procedure logrow('Test 4');
select * from logbook;

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Pavel Cisar added a comment - 20/Apr/11 08:40 AM
QA test added.