TZStoredProcedure and MySQL 5.1.7-beta
Posted: 12.04.2006, 14:36
I have problem with a calling stored procedure in MySQL base. I getting "Unsupported operation" exception on SP.ExecSQL. Do someone know why?
Delphi 7:
var
new: TZStoredProc;
begin
new:=TZStoredProc.Create(nil);
new.Connection:=DM.zMain;
new.StoredProcName:='KalRasFullMonth';
new.Params.CreateParam(ftDate,'d',ptInput);
new.Params[0].Value:=StrToDate('01.01.2006');
new.ExecProc;
end;
MySQL:
CREATE PROCEDURE KalRasFullMonth (d DATE)
BEGIN
DECLARE i INT;
DECLARE Cnt INT;
SET i=0;
WHILE MONTH(d)=MONTH(d+i) DO
IF (SELECT COUNT(*)
FROM kalendarrashodov
WHERE Today=d+i AND NalBeznal=0)<1
THEN
INSERT INTO KalendarRashodov(Today, NalBeznal)
VALUES(d+i, 0);
END IF;
IF (SELECT COUNT(*)
FROM kalendarrashodov
WHERE Today=d+i AND NalBeznal=1)<1
THEN
INSERT INTO KalendarRashodov(Today, NalBeznal)
VALUES(d+i, 1);
END IF;
SET i=i+1;
END WHILE;
END
PS. Sorry for my bad english...
Delphi 7:
var
new: TZStoredProc;
begin
new:=TZStoredProc.Create(nil);
new.Connection:=DM.zMain;
new.StoredProcName:='KalRasFullMonth';
new.Params.CreateParam(ftDate,'d',ptInput);
new.Params[0].Value:=StrToDate('01.01.2006');
new.ExecProc;
end;
MySQL:
CREATE PROCEDURE KalRasFullMonth (d DATE)
BEGIN
DECLARE i INT;
DECLARE Cnt INT;
SET i=0;
WHILE MONTH(d)=MONTH(d+i) DO
IF (SELECT COUNT(*)
FROM kalendarrashodov
WHERE Today=d+i AND NalBeznal=0)<1
THEN
INSERT INTO KalendarRashodov(Today, NalBeznal)
VALUES(d+i, 0);
END IF;
IF (SELECT COUNT(*)
FROM kalendarrashodov
WHERE Today=d+i AND NalBeznal=1)<1
THEN
INSERT INTO KalendarRashodov(Today, NalBeznal)
VALUES(d+i, 1);
END IF;
SET i=i+1;
END WHILE;
END
PS. Sorry for my bad english...