[Gambas-user] MySQL stored procedures execution problem

Leandro Anthonioz Blanc leandro_anthonioz at ...43...
Wed May 30 17:06:09 CEST 2007


Hi Benoit, thanks for the reply. I'm using last Gambas version, 1.9.49, with MySQL 5.0.26. I write an abbreviated example that reproduces the problem. If "ExecuteStoredProcedure" sub is executed two times, last execution throw  "Query failed: Commands out of sync; you can’t run this command now”. I hope this information could be useful. Thank you very much.

' Gambas class file

PRIVATE $hConnection AS Connection

PUBLIC SUB _New()
 
  $hConnection = NEW Connection
  WITH $hConnection
    .Type = "mysql"
    .Host = "localhost"
    .port = "3306"
    .Login = "root"
    .Password = ""
    .Name = "SIMSA"
    .Open
  END WITH
 
END

PUBLIC SUB btnOK_Click()

  ExecuteStoredProcedure(ME.txtPassword.Text)

END

PUBLIC SUB ExecuteStoredProcedure(sValue AS String)
 
  DIM hResult AS Result
 
  hResult = $hConnection.exec(Subst("CALL MyStoredProcedure('&1')", sValue))
 
  IF hResult[0] = 1 THEN
    Message.Info("Correct")
  ELSE
    Message.Error("Wrong")
  ENDIF
 
END

... and the MySQL stored procedure code:

CREATE DEFINER=`root`@`localhost` PROCEDURE `MyStoredProcedure`(vPassword VARCHAR(20))
BEGIN

    SELECT COUNT(*) AS Coincidencia FROM ObConfiguracionGeneral WHERE PasswordAdministradorMD5 = MD5(vPassword);

END


>Which version of Gambas do you use? (I should have a keyboard shortcut for 
inserting this question...)

>Please send me exactly what code you are trying to run.

>At first glance, gb.db.mysql does not use mysql_use_result(), and use 
mysql_store_result() each time it has run a query without error. I think I 
have a clue about what could happen, but I need your full code.

>Regards,

>-- 
>Benoit Minisini


 
---------------------------------
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.



More information about the User mailing list