D
DelphiUser
Unregistered / Unconfirmed
GUEST, unregistred user!
我在Interbase中写了个存储过程,对数据库进行了写操作。
在Interbase的Windows ISQL中调用,结果正常。
而在Delphi中,每次重新启动Interbase Server后在第一次调用的时候正常,
但第二次调用的时候,数据库的数据没有被更改。这是为什么?
我的存储过程:
CREATE PROCEDURE SET_STU_RIGHTS (
ID VARCHAR(6),
RIGHT0 VARCHAR(1),
RIGHT1 VARCHAR(1),
RIGHT2 VARCHAR(1),
RIGHT3 VARCHAR(1),
RIGHT4 VARCHAR(1),
RIGHT5 VARCHAR(1),
RIGHT6 VARCHAR(1),
RIGHT7 VARCHAR(1)
) AS
BEGIN
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 0, :RIGHT0;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 1, :RIGHT1;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 2, :RIGHT2;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 3, :RIGHT3;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 4, :RIGHT4;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 5, :RIGHT5;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 6, :RIGHT6;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 7, :RIGHT7;
END
CREATE PROCEDURE SET_STU_ONE_RIGHT (
ID VARCHAR(6),
RIGHTID SMALLINT,
ENABLE VARCHAR(1)
) AS
DECLARE VARIABLE Temp INTEGER;
BEGIN
SELECT COUNT(*) FROM STURIGHTS WHERE (ID=:ID) AND (RIGHTID=:RIGHTID) INTO :Temp;
IF ((Temp>0) AND (Enable='F')) THEN
BEGIN
DELETE FROM STURIGHTS WHERE (ID=:ID) AND (CLASSID=:RIGHTID);
EXIT;
END
IF ((Temp=0) AND (Enable='T')) THEN
BEGIN
INSERT INTO STURIGHTS(ID, RIGHTID)
VALUES ID, :RIGHTID);
END
END
在Interbase的Windows ISQL中调用,结果正常。
而在Delphi中,每次重新启动Interbase Server后在第一次调用的时候正常,
但第二次调用的时候,数据库的数据没有被更改。这是为什么?
我的存储过程:
CREATE PROCEDURE SET_STU_RIGHTS (
ID VARCHAR(6),
RIGHT0 VARCHAR(1),
RIGHT1 VARCHAR(1),
RIGHT2 VARCHAR(1),
RIGHT3 VARCHAR(1),
RIGHT4 VARCHAR(1),
RIGHT5 VARCHAR(1),
RIGHT6 VARCHAR(1),
RIGHT7 VARCHAR(1)
) AS
BEGIN
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 0, :RIGHT0;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 1, :RIGHT1;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 2, :RIGHT2;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 3, :RIGHT3;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 4, :RIGHT4;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 5, :RIGHT5;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 6, :RIGHT6;
EXECUTE PROCEDURE SET_STU_ONE_RIGHT :ID, 7, :RIGHT7;
END
CREATE PROCEDURE SET_STU_ONE_RIGHT (
ID VARCHAR(6),
RIGHTID SMALLINT,
ENABLE VARCHAR(1)
) AS
DECLARE VARIABLE Temp INTEGER;
BEGIN
SELECT COUNT(*) FROM STURIGHTS WHERE (ID=:ID) AND (RIGHTID=:RIGHTID) INTO :Temp;
IF ((Temp>0) AND (Enable='F')) THEN
BEGIN
DELETE FROM STURIGHTS WHERE (ID=:ID) AND (CLASSID=:RIGHTID);
EXIT;
END
IF ((Temp=0) AND (Enable='T')) THEN
BEGIN
INSERT INTO STURIGHTS(ID, RIGHTID)
VALUES ID, :RIGHTID);
END
END