how mysql_affected_rows() should be called in stored procedures.

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
charbel
Posts: 15
Joined: Fri 02 May 2008 06:42

how mysql_affected_rows() should be called in stored procedures.

Post by charbel » Mon 26 May 2008 08:43

Dear Dimon,
im trying to create a stored procedure that when posting a table , it update or create records in another table . here is my code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `jmg_acc2007`.`LdgB4Post_CreateClt` $$
CREATE PROCEDURE `jmg_acc2007`.`LdgB4Post_CreateClt` (LNumb varchar(10), LName varchar(50),LCur varchar (6), LBlngGrp int(11) )
BEGIN


update clients
set Ledger_name = LName
where Ledger_number = LNumb;

if mysql_affected_rows() = 0 then
insert into clients(Ledger_number, Ledger_name, Currency_Code, Client_BelongsToGroup)
values (LNumb, LName, LCur, LBlngGrp);
end if;
END $$

DELIMITER ;

executing this procedure in the MySqlBrowser is working properly , but once i call this procedure from Borland developper studion 2006, it kept giving me that function mysql_affected_rows() does not exist in my database. i know that. its a mysql function. what should i do?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 27 May 2008 09:31

mysql_affected_rows() is a C API function that can not be called from stored pocedure.
You can use the ROW_COUNT() MySQL function that returns the same value as mysql_affected_rows().

charbel
Posts: 15
Joined: Fri 02 May 2008 06:42

Post by charbel » Tue 27 May 2008 10:05

thanks for ur help.

Post Reply