mariadbfoxpro

How to exec MariaDB stored procedure from Visual Foxpro?


I have a function/stored procedure in Maria DB:

CREATE DEFINER=`root`@`localhost` PROCEDURE `test1`(var1 varchar(100))
BEGIN
  select * from ttype where kode=var1;
END

I need to get a cursor from that stored procedure, how to get a cursor in vfp application, database in MariaDb/MySQL stored procedure?

I try with this in my Visual Foxpro:

Sqlexec(kon,"call test1 ('ABC')","test")     --> not running

But when I use common select like this :

sqlexec(kon,"select * from ttype where kode='ABC'","test")

it's running well.


Solution

  • "Can you show me how to use aerror() in my case?"

    You would use the AError() function always when any ODBC Remote action would fail, i.e. any of Vfp's SQL*() functions, like SqlStringConnect() for example or your proposed

    sqlexec(kon,"select * from ttype where kode='ABC'","test") --it's running well
    

    && Actually you cannot know whether "it's running well" unless you are evaluating its return value like this:

    Local lnResult, laSqlErrors[1], lcErrorMessage
    lnResult = SqlExec(kon,"select * from ttype where kode='ABC'","test")
    If m.lnResult = –1 && as documented in the F1 Help
            AERROR(laSqlErrors)
            lcErrorMessage = ;
                TRANSFORM(laSqlErrors[1]) + ", " + ;
                TRANSFORM(laSqlErrors[2])
            && now write a log and/or inform the user
    ENDIF
    && to be continued