0

I have been using ZeosLib Components with Delphi and Lazarus for the past 10 years or so. I'm mostly using it to access MySQL Databases. Now I have run into a strange Problem with TZReadOnlyQuery.

In my MariaDB database I have a pretty complex stored procedure that takes some input parameters, one inout param and one out param. Because of the error I get, when I try to call it with TZReadOnlyQuery, I have made a very simple procedure to test it.

This is my test procedure:

CREATE PROCEDURE MyProc(INOUT a VARCHAR(255), OUT r VARCHAR(255))
BEGIN
  set a = 'inparam changed';
  set r = 'outparam set';
END

I tried to call this procedure from different MySQL query/managment tools with this statement:

set @x = 'inputparam';
call MyProc(@x, @y);
select @x, @y;

I get the expected answer: a dataset with one record and two fields like this: QueryResultSet

But when I add the same query statement to a TZReadOnlyQuery and try to open it I get an error message:

Query Error Message

Any ideas why this happens and how to work around it?

Thanks!

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • The error says call p your published proc name is myproc?? – P.Salmon Jan 09 '23 at 10:08
  • Oops sorry, that was an old version of the error message - before I renamed the procedure for this post. I edited it now so that the error message corresponds to the procedure name. – Heinzi Tuberkel Jan 09 '23 at 10:15
  • Logically `SET` is mutually exclusive with "_readonly_", so the error message does make sense. – AmigoJack Jan 09 '23 at 10:54
  • The "ReadOnly" as I understand it (correct me if I'm wrong) referrs to the resulting data set being read only, not the query statement itself. But I never get a result data set as the query is never executed. – Heinzi Tuberkel Jan 09 '23 at 12:25
  • Logically `SET` and `CALL` are not a _query_ either. Are you sure the component accepts anything? Because code wise there's also a distinction between executing **multiple** commands at once and defining a query (and not more). Just like nobody would expect to successfully assign `DELETE FROM table;` to it. – AmigoJack Jan 09 '23 at 12:36
  • You are probably right, that the TZReadOnlyQuery does not allow a batch of queries to be executed like several other query components do. Looks like I never did that in ZEOS queries before. I tried a different approach that manages to use only ONE statement in the query and does NOT use INOUT parameters in the procedure. Now it works. Thanks for the nudge in the right directon – Heinzi Tuberkel Jan 10 '23 at 07:38

0 Answers0