MySQL5 - Stored procedures
Moderators: gto, cipto_kh, EgonHugeist
MySQL5 - Stored procedures
Is it possible to use the new features in MySQL5 eg Stored Procedures, Triggers and so on?
If I use a common "SELECT-statement" I get a proper answer from MySQL, but if I call a Stored Procedure containing the same query I get the following:
"SQL Error: Procedure db5.p1 can't return a result set in the given context."
//Alf
If I use a common "SELECT-statement" I get a proper answer from MySQL, but if I call a Stored Procedure containing the same query I get the following:
"SQL Error: Procedure db5.p1 can't return a result set in the given context."
//Alf
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Uwin,
For the moment we are speaking about the alpha version you can get from svn (testing branch). See other posts for details about this. CVS isn't used anymore.
You can get a quite recent copy at http://users.telenet.be/mdaems
Mark
For the moment we are speaking about the alpha version you can get from svn (testing branch). See other posts for details about this. CVS isn't used anymore.
You can get a quite recent copy at http://users.telenet.be/mdaems
Mark
For the moment we are speaking about the alpha version you can get from svn (testing branch). See other posts for details about this. CVS isn't used anymore.
You can get a quite recent copy at http://users.telenet.be/mdaems
Mark
Thank 4 ur info... i'll try to download this version...
MySQL5 - Stored procedures
to awerner:
From now you can execute SP, that return resultset.
For instance:
Code: Select all
ZConnection.Properties.Add('CLIENT_MULTI_STATEMENTS=1');
ZConnection.Connect;
For instance:
Code: Select all
ZQuery1.SQL.Add('call myproc();');
ZQuery1.Open;
Last edited by Asis on 03.03.2007, 18:10, edited 1 time in total.
Hi,
I'm using mysql 5.0 and the newest beta components.
I tried to use a stored procedure using the tzquery.sql property.
But If I have an OUT Variable in the stored procedure I get an error.
The SQL.Property of the TZquery component is
Andreas
I'm using mysql 5.0 and the newest beta components.
I tried to use a stored procedure using the tzquery.sql property.
But If I have an OUT Variable in the stored procedure I get an error.
The Code of the storec Procedure is the following. And in MYSQL it is working fine.Out or INOUT argument 2 for NEUER_KUNDE is not a variable.
Code: Select all
CREATE PROCEDURE `NEUER_KUNDE`(in match_var varchar(15), out kdnr_var integer)
BEGIN
INSERT INTO KUNDEN
(MATCHCODE)
VALUES
(MATCH_var);
SET KDNR_var = LAST_insert_id();
END$$
What is wrong here.call NEUER_KUNDE(:MATCH, :KDNUMMER)
Andreas
I think you should try something likecall NEUER_KUNDE(:MATCH, :KDNUMMER)
Code: Select all
call NEUER_KUNDE(:MATCH, @VARIABLE);
SELECT @VARIABLE;
Code: Select all
while not zquery1.eof do
begin
---CODE---
zquery1.next
end;
To make the query work from your program code, you may do the following:andreass wrote:Hi,
I'm using mysql 5.0 and the newest beta components.
I tried to use a stored procedure using the tzquery.sql property.
But If I have an OUT Variable in the stored procedure I get an error.The Code of the storec Procedure is the following. And in MYSQL it is working fine.Out or INOUT argument 2 for NEUER_KUNDE is not a variable.
The SQL.Property of the TZquery component isCode: Select all
CREATE PROCEDURE `NEUER_KUNDE`(in match_var varchar(15), out kdnr_var integer) BEGIN INSERT INTO KUNDEN (MATCHCODE) VALUES (MATCH_var); SET KDNR_var = LAST_insert_id(); END$$
What is wrong here.call NEUER_KUNDE(:MATCH, :KDNUMMER)
Andreas
Correct the code of stored procedure this way:
Code: Select all
CREATE PROCEDURE `NEUER_KUNDE`(in match_var varchar(15))
BEGIN
INSERT INTO KUNDEN
(MATCHCODE)
VALUES
(MATCH_var);
SELECT LAST_insert_id();
END
Code: Select all
call NEUER_KUNDE(:MATCH);
Code: Select all
var kdnr_var: integer;
begin
...
ZQuery1.Close;
ZQuery1.ParamByName('MATCH').AsString := 'Any value';
ZQuery1.Open;
kdnr_var := ZQuery1.Fields[0].AsInteger;
...
end;
Last edited by Asis on 03.03.2007, 18:07, edited 1 time in total.
Currently Zeos Lib doesn't support multiple result sets for MySQL.iLLiCiT wrote:...but i still cannot find a solution regarding my problem. using CLIENT_MULTI_STATEMENTS=1 i'm able to accept multiple results. if i tryi only browse results included in the first resultset ... how can i browse to the second result set?Code: Select all
while not zquery1.eof do begin ---CODE--- zquery1.next end;
Property CLIENT_MULTI_STATEMENTS=1 only lets you avoid errors like 'Can't Return a result set in the given context'
on calling stored procedures.
Thus, to browse through different result sets you should get them separately, i.e. one query - one resultset.
-
- Junior Boarder
- Posts: 29
- Joined: 31.10.2005, 00:09
- Location: Antwerp
- Contact:
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hoi bravecobra,
Getting more resultsets (and so the last as well) from a query is only possible using the zdbc interfaces. There is a small example here : http://zeos.firmos.at/viewtopic.php?t=1141
More information can be found here :
http://zeos.firmos.at/viewtopic.php?t=295
http://zeos.firmos.at/viewtopic.php?t=912
I hope this helps you?
Mark
Getting more resultsets (and so the last as well) from a query is only possible using the zdbc interfaces. There is a small example here : http://zeos.firmos.at/viewtopic.php?t=1141
More information can be found here :
http://zeos.firmos.at/viewtopic.php?t=295
http://zeos.firmos.at/viewtopic.php?t=912
I hope this helps you?
Mark