[solved] problem calling two different SP

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sean
Posts: 42
Joined: Sun 16 Jul 2006 00:17

[solved] problem calling two different SP

Post by sean » Fri 02 Oct 2009 16:30

I have two different SPs:

Code: Select all

CREATE PROCEDURE test1(IN var1 INT, OUT var2 DOUBLE)
  READS SQL DATA
BEGIN
  SET var2=2.02;
END;
CREATE PROCEDURE test2(IN v1 INT, OUT v2 DOUBLE)
  READS SQL DATA
BEGIN
  SET v2= v1 + 10.02;
END;
These are called as follows:

Code: Select all

  with MyStoredProc1 do begin
    try
      Close;
      StoredProcName:='test1';
      ParamByName('var1').AsInteger:=10;
      Execute;

      ShowMessage('test1 var2=' +FieldByName('@var2').AsString);
    finally
      Close;
    end;
  end;

  with MyStoredProc1 do begin
    try
      Close;
      StoredProcName:='test2';
      ParamByName('v1').AsInteger:=10;
      Execute;

      ShowMessage('test2 v2=' +FieldByName('@v2').AsString);
    finally
      Close;
    end;
  end;
In the design environment, the two results are popped up fine.

BUT, in the production (no delphi), The first SP works [var2=2.02], the second says "Parameter var1 not found".
After that SP test1 no longer works either, until I restart the client program. Normal mysql queries queries work fine, it only affects SPs (which I would really like to be able to use..)

I first noticed this is much more complex queries, and created the very simple examples above as a proof of concept. Seem like a bug to me?

D7 / MyDAC 5.9.0.51

Thanks in advance
Last edited by sean on Fri 09 Oct 2009 14:29, edited 1 time in total.

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

Post by Dimon » Mon 05 Oct 2009 07:52

I can not reproduce the problem.
Try to execute the following code:

Code: Select all

StoredProcName:='';
before the line:

Code: Select all

StoredProcName:='test1';

sean
Posts: 42
Joined: Sun 16 Jul 2006 00:17

Post by sean » Mon 05 Oct 2009 18:14

That did not make any difference ("Parameter 'var1' not found" still happens at run time)

I also deleted and re-added the MyStoredProc1 visual object to be sure it has no special settings. This had no effect.

Running the DBmonitor on the runtime system does not show the SP being called either.

Could be be something in the MyConnection properties?
Have you any other suggestions?

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

Post by Dimon » Tue 06 Oct 2009 06:51

I still can not reproduce the problem.
Please, try to compose a sample to demonstrate the problem and send it to dmitryg*devart*com.
Also supply me the exact version of MySQL server and client. You can see it in the Info sheet of TMyConnection Editor.

sean
Posts: 42
Joined: Sun 16 Jul 2006 00:17

Post by sean » Fri 09 Oct 2009 14:28

There were some out of band emails, but a solution has been found.

The users calling the queries did not have the (mysql) rights to list the SP details.

Its a problem with the way APIs such as mydac check SPs before calling them, see:
http://bugs.mysql.com/bug.php?id=10640

The workaround:
mysql> GRANT SELECT on mysql.proc to MYUSER@'%';

'MYSUSER' is the user who calls the SP, configured in the MyConnection.

Thanks to Dmitry Gerasimenko for the help.

This shoould go in a FAQ, it will surely bit anyone who tries to use SPs from Mydac?

Regards,

Sean

Post Reply