Android Question [Solved] Sql Store Procedure

Alberto Salinas

Member
Licensed User
B4X:
Dim sf As Object = mysql.CreateCallStatement("{call spfolios(?)}", Array(71))
        Dim crsr As JdbcResultSet=mysql.ExecCall(sf)
I have this code

this work because update my database but i get this error

java.sql.SQLException: The executeQuery method must return a result set.

in this line

Dim crsr As JdbcResultSet=mysql.ExecCall(sf)

Any help Please

sorry my english
 

Alberto Salinas

Member
Licensed User
Use
SQL:
RETURN SELECT 1
1655382984283.png

Thanks but still have a error

here my store procedure
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Thanks for reply

Now

i Return 1

But Now i get this msg

(SQLException) java.sql.SQLException: The executeQuery method must return a result set.
Sorry for a late response

Modify your procedure to something like this

UPDATE tblMytable set Name=@Name where id=@ID - assume that this line does the update.

Then at the end add this line - or something like this

SELECT * from tblMyTable where id=@ID - this line returns a recordset
 
Upvote 0

Alberto Salinas

Member
Licensed User
hello @Alberto Salinas

See the example of how to handle the input and output parameters of a stored procedure in the following link: https://www.b4x.com/android/forum/threads/sql-simplyfying-calling-stored-procedures.73181/

I hope it helps
Sorry for a late response

Modify your procedure to something like this

UPDATE tblMytable set Name=@Name where id=@ID - assume that this line does the update.

Then at the end add this line - or something like this

SELECT * from tblMyTable where id=@ID - this line returns a recordset
Thanks Guys

This Help Resolve my problems


SELECT * from tblMyTable where id=@ID - this line returns a recordset:

I add this and

CursorToLog( MyResultSet ):

Final Code

B4X:
            Dim sf As Object = mysql.CreateCallStatement("{call AgregaPago(?,?,?,?,?,?,?,?,?)}", Array(Main.NtagPago,Main.IdUsuario,Main.Nombre,Main.MacId,PEDIDOS.total,Pagar.CadenaG,PEDIDOS.Referencia ,Main.GrupoProd,PEDIDOS.orden ))
            Dim crsr As JdbcResultSet=mysql.ExecCall(sf)
            CursorToLog( crsr )
 
Upvote 0
Top