How to retrieve values from a Stored Procedure

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Zsolt Csillag
Posts: 30
Joined: Sun 28 May 2006 16:09

How to retrieve values from a Stored Procedure

Post by Zsolt Csillag » Wed 21 Nov 2007 10:03

Hello,

I have a stored procedure as follows:

CREATE DEFINER = 'root'@'localhost' PROCEDURE `Get_MyValue`(IN cnr cHAR(10))
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN

Select cbk_category from cbk
Where cbk_cnr=cnr;

END;


If I call this procedure from an sql statement like this:

Call Get_MyValue("S10155")

Then I can see every row displayed (like the result of a normal Select).

How can I retrieve the rows (because there might be many rows) from Delphi, calling the stored procedure?



The following code doesn't work, it will never enter in the iteration:

while not eof do
Begin
ShowMessage(FieldByName('cbk_category ').AsString);

Next;
end;

I use Delphi 2006 and MyDac 4.40.0.24.

If my version is not capable to do that but the version 5 is, than I am willing to upgrade.

By the way how can I see the difference between the version 4 and 5?
When should I expect the version 6? If it is not so far it would be easier for me to upgrade directly to 6.

Thank you in advance

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 21 Nov 2007 12:42

This code should work both in MyDAC 4.40 and MyDAC 5.20.
Please make sure that your TMyQuery calling this procedure is active and that it returns rows.
If it does, try to add a call to the First method before the cycle.
Zsolt Csillag wrote:By the way how can I see the difference between the version 4 and 5?
You can refer to this page: http://crlab.com/mydac/history.html
Zsolt Csillag wrote:When should I expect the version 6? If it is not so far it would be easier for me to upgrade directly to 6.
We have no estimate of MyDAC 6. So you can upgrade to MyDAC 5.

Post Reply