Problem with mysql and result sets in stored procedures

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Problem with mysql and result sets in stored procedures

Post by cokotech »

Hello!

Now i installed the latest svn Version of zeos, but i can't open stored procedures with result sets. In many topics is written, that it works with the latest svn and there was a code example, too.... but i only get the message "can't return a result set in given context"

My Code:

Procedure test2: (sorry i created it in navicat... so i haven't the hole code)

BEGIN
SELECT * FROM Gilden;
END



Delphi:
ZConnection1.Properties.Add('CLIENT_MULTI_STATEMENTS=1');
conn := ZConnection1.DbcConnection;
stmt := conn.CreateStatement;
ZConnection1.Connect;
if Stmt.Execute('call test2()') then
begin
Rs := Stmt.GetResultSet;
while (Rs <> nil) and (Rs.Next)
do begin
S := S + Rs.GetStringByName('PRIMARY')+'; '+#13+#10;
end;
messageBox(Self.Handle, PChar(S), 'result 1', MB_OK);
end;


Any idea???

Bye Sven!
User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Post by cipto_kh »

What database you're working?
mmm.. I never do like that, usually I use TZStroredProcedure or TZQuery component
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Post by cokotech »

cipto_kh wrote:What database you're working?
mmm.. I never do like that, usually I use TZStroredProcedure or TZQuery component
I am using mysql, so i cannot use TSoredProcedures!


Bye Sven!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Maybe you could have a look here... http://zeos.firmos.at/viewtopic.php?t=1453

Mark
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Post by cokotech »

mdaems wrote:Maybe you could have a look here... http://zeos.firmos.at/viewtopic.php?t=1453

Mark
No, i need a resultset as result (nice sentence).....
And i think it should works after the changes in the latest beta (test, svn or however) version!


Bye SVen!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

What changes do you mean?

I suppose you read the other threads on this topic? Including the one where I explain why we can't add support for this in the ZQuery component.

Mark
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Post by cokotech »

20070314 : Added Multiple resultset support on Dbc level - Code by Asis - See http://zeos.firmos.at/viewtopic.php?t=459 and http://zeos.firmos.at/viewtopic.php?t=912



did i understand something wrong?!?!?!?


Bye Sven!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Well... That's the last patch indeed.
To make it easy :
Can you attach a small (command line?) project.
Also, include the statements to create the necessary data and procedure...
That way I can start debugging without the hassle of setting it all up myself.

Mark
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Post by cokotech »

Hello!


I don't know what you mean, i sent you the code a few topics upper....

CREATE DEFINER=`admin`@`%` PROCEDURE `test2`()
BEGIN
SELECT * FROM Gilden;
END

ZConnection1.Properties.Add('CLIENT_MULTI_STATEMENTS=1');
ZConnection1.Connect;
ZQuery1.SQL.Clear;
ZQuery1.SQL.add('set names ''utf8'';');
ZQuery1.ExecSQL;
ZQuery1.SQL.Clear;

conn := ZConnection1.DbcConnection;
stmt := conn.CreateStatement;
Connection1.Connect;
ZQuery1.SQL.add('CALL test2();');
Query1.open;


After this i used the code from the Threads above but i get the error message after the open command.
I can't use variables because i need more then one result.... this example is not the code i need but the right code will give me more then one result, too.


Bye Sven
cokotech
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: 24.03.2007, 12:27

Post by cokotech »

Hmmmmm now it works but i dont't know why......

Bye Sven!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I meant : attach a zip file of your project files (Delphi or Lazarus) and a script to install everything on the database side.
I know : code above should be enough to reproduce this kind of problems, but setting up everything for every problem is very tedious.
The more : sometimes it's just a setting in the object inspector that's wrong.
Don't forget : at this side of the web I can't see what's on your side (and in your head).

Fortunately : it works know...

Mark
Post Reply