Carlos Mojica
Member
Following https://www.b4x.com/android/forum/t...ith-stored-procedures-support.123294/#content, I can't get the return values.
The code never end the Wait for (never reach the "if j.Success then"), but the server does its job. The stored procedure is:
Thanks in advance
B4X:
Dim req As DBRequestManager = B4XPages.MainPage.jrdc.CreateRequest
Dim cmd As DBCommand = B4XPages.MainPage.jrdc.CreateCommand("insertarUsuario", _
Array(edtContrasena.Text, edtNombre.Text, edtCorreo1.Text, CreateMap("name":"varResponse", "type":"OUT", "sqlType":"VARCHAR")))
Wait For (req.ExecuteCall(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
Log("Call executed successfully")
req.HandleCallJobAsync(j, "req")
Wait For (req) req_CallResult(resultSets As List, parameters As Map)
'Let's print out the returned result sets. resultSets is a list containing 0 or more DBResult objects.
For Each res As DBResult In resultSets
req.PrintTable(res)
Next
'Let's print the returned OUT parameters
Log($"Parameters map content: ${parameters}"$)
Else
Log($"ERROR: ${j.ErrorMessage}"$)
End If
The code never end the Wait for (never reach the "if j.Success then"), but the server does its job. The stored procedure is:
B4X:
CREATE PROCEDURE insertarUsuario(
IN claveP BLOB, nombreP VARCHAR(250), usuarioP VARCHAR(150),
OUT varResponse LONGTEXT)
BEGIN
# Revisamos si existe el usuario
DECLARE idP Int;
DECLARE tokenP VARCHAR(1500);
SELECT idusuario, token
INTO idP, tokenP
FROM usuario
WHERE usuario = usuarioP;
IF (idP is null) THEN
insert into usuario values(null, nombreP, AES_ENCRYPT(claveP,"XXX"), usuarioP, UUID(), NOW());
SELECT idusuario, token
INTO idP, tokenP
FROM usuario
WHERE usuario = usuarioP;
SET varResponse = CONCAT('{"idP":',idP,', "tokenP":',tokenP,'}');
ELSE
SET varResponse = '{"idP": -1, "tokenP": -1}';
END IF;
SELECT @varResponse as response;
END
Thanks in advance