Hello !
I have very simple SQL script.
create table T1(
ID integer DEFAULT 1,
Name varchar(20),
primary key(ID)
)#
create table T2(
ID integer DEFAULT 1,
Name varchar(20)
)#
CREATE TRIGGER InsT1 AFTER INSERT ON T1 ORDER 1 FOR EACH ROW
INSERT INTO T2 VALUES(NEW.ID,NEW.Name);#
CREATE TRIGGER PrimT1 BEFORE INSERT ON T1 ORDER 1 FOR EACH ROW
DECLARE :ID INTEGER;
SELECT IFNULL(MAX(ID),0)+1 INTO :ID FROM T1;
SET NEW.ID=:ID;#
CREATE PROCEDURE InsT (IN :C INTEGER);
DECLARE :I UINTEGER = 0;
BEGIN
WHILE I < :C) DO
SET :I = :I + 1;
INSERT INTO T1 VALUES(1,'1');
END WHILE;
END#
When I execute "CALL InsT(1)", I have no errors:
"SQL statement(script) has executed successfully." message
But after execution of "CALL InsT(2)" I've got next error
"ODBC Error: SQLSTATE = S1000, Native error code = -5099
The record has a key field containing a duplicate value(Btrieve Error 5)"
Can anybody explain me that it is wrong?
I have very simple SQL script.
create table T1(
ID integer DEFAULT 1,
Name varchar(20),
primary key(ID)
)#
create table T2(
ID integer DEFAULT 1,
Name varchar(20)
)#
CREATE TRIGGER InsT1 AFTER INSERT ON T1 ORDER 1 FOR EACH ROW
INSERT INTO T2 VALUES(NEW.ID,NEW.Name);#
CREATE TRIGGER PrimT1 BEFORE INSERT ON T1 ORDER 1 FOR EACH ROW
DECLARE :ID INTEGER;
SELECT IFNULL(MAX(ID),0)+1 INTO :ID FROM T1;
SET NEW.ID=:ID;#
CREATE PROCEDURE InsT (IN :C INTEGER);
DECLARE :I UINTEGER = 0;
BEGIN
WHILE I < :C) DO
SET :I = :I + 1;
INSERT INTO T1 VALUES(1,'1');
END WHILE;
END#
When I execute "CALL InsT(1)", I have no errors:
"SQL statement(script) has executed successfully." message
But after execution of "CALL InsT(2)" I've got next error
"ODBC Error: SQLSTATE = S1000, Native error code = -5099
The record has a key field containing a duplicate value(Btrieve Error 5)"
Can anybody explain me that it is wrong?