Page 1 of 1
MyClasses.pas - Error !
Posted: Thu 10 May 2012 12:50
by kamrava
Hello there
when i wanna execute MyStoredProce , this error is showing :
...
(D:\Project\Delphi\Dac\MySql\Source\MyClasses.pas, line 2810)
I'm using : Delphi XE2 and MyDac 7.0.2
please help me.I need it
Thank You
Regards
Hamed Kamrava
Re: MyClasses.pas - Error !
Posted: Thu 10 May 2012 14:05
by AndreyZ
Hello,
Please specify the exact error message that occurs (the message line before the '(D:\Project\Delphi\Dac\MySql\Source\MyClasses.pas, line 2810)' line). Also please specify the script to create your stored procedure.
Re: MyClasses.pas - Error !
Posted: Thu 10 May 2012 14:26
by kamrava
Tnx for you'r reply.
it's error shot :
and this is stored proc code in mysql :
Code: Select all
DELIMITER $$
USE `bimarestan`$$
DROP PROCEDURE IF EXISTS `save_user2`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `save_user2`(IN $_id VARCHAR(50),IN $_name VARCHAR(50),IN $_lname VARCHAR(50))
BEGIN
IF LTRIM(RTRIM($_id))<>'' THEN
BEGIN
IF NOT EXISTS(SELECT * FROM user1 WHERE id=$_id) THEN
INSERT INTO user1 VALUES($_id,$_name,$_lname);
END IF;
END;
END IF;
END$$
DELIMITER ;
and this is Delphi code :
Code: Select all
sp_save := TMyStoredProc.Create(nil);
sp_save.Connection := con;
sp_save.Active := False;
sp_save.StoredProcName := 'save_user2';
sp_save.ParamByName('$_id').Value := '100';
sp_save.ParamByName('$_name').Value := 'hamed';
sp_save.ParamByName('$_lname').Value := 'mofagh shodim';
sp_save.ExecProc;
Thank You
Re: MyClasses.pas - Error !
Posted: Thu 10 May 2012 17:28
by kamrava
Please help me faster guys:(
I have to do this project for 2 days later .
I'm waiting for you'r answers.
Regards
Hamed Kamrava
Re: MyClasses.pas - Error !
Posted: Fri 11 May 2012 06:53
by AndreyZ
This problem is caused by the '$' symbol in the names of your stored procedure parameters. MyDAC treats this symbol as a MySQL special character. To avoid the problem, you should remove the '$' symbol from the names of your stored procedure parameters. For example:
Code: Select all
DELIMITER $$
USE `bimarestan`$$
DROP PROCEDURE IF EXISTS `save_user2`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `save_user2`(IN _id VARCHAR(50),IN _name VARCHAR(50),IN _lname VARCHAR(50))
BEGIN
IF LTRIM(RTRIM(_id))<>'' THEN
BEGIN
IF NOT EXISTS(SELECT * FROM user1 WHERE id=_id) THEN
INSERT INTO user1 VALUES(_id,_name,_lname);
END IF;
END;
END IF;
END$$
DELIMITER ;
Code: Select all
sp_save := TMyStoredProc.Create(nil);
sp_save.Connection := con;
sp_save.Active := False;
sp_save.StoredProcName := 'save_user2';
sp_save.ParamByName('_id').Value := '100';
sp_save.ParamByName('_name').Value := 'hamed';
sp_save.ParamByName('_lname').Value := 'mofagh shodim';
sp_save.ExecProc;
Re: MyClasses.pas - Error !
Posted: Fri 11 May 2012 07:12
by kamrava
Ow!
Yes that's right.
Thank you so much.

Re: MyClasses.pas - Error !
Posted: Fri 11 May 2012 09:28
by AndreyZ
Feel free to contact us if you have any further questions about MyDAC.