Dear Friends,
How do I call a Stored Procedure with an OUT Parameter using RDC on a MySQL Database.
Here is a sample of MySQL Stored Procedure with OUT Parameter
The above stored procedure just returns the CustomerLevel (String) based on the Customer's Credit Limit
In MySQL, we can call the GetCustomerLevel() stored procedure as follows:
To call a stored procedure, I assume that the following statement is to be used in the RDC config.properties file
Not sure the above line in config.properties file is correct or not, I am just assuming
In the B4A
The second parameter ie @? is the OUT parameter. I don't know how to retrieve this OUT parameter's value from the Sub JobDone.
Any advice or a sample is appreciated.
Thanks & Regards
Anser
How do I call a Stored Procedure with an OUT Parameter using RDC on a MySQL Database.
Here is a sample of MySQL Stored Procedure with OUT Parameter
B4X:
DELIMITER $$
CREATE PROCEDURE GetCustomerLevel(
in p_customerNumber int(11),
out p_customerLevel varchar(10))
BEGIN
DECLARE creditlim double;
SELECT creditlimit INTO creditlim
FROM customers
WHERE customerNumber = p_customerNumber;
IF creditlim > 50000 THEN
SET p_customerLevel = 'PLATINUM';
ELSEIF (creditlim <= 50000 AND creditlim >= 10000) THEN
SET p_customerLevel = 'GOLD';
ELSEIF creditlim < 10000 THEN
SET p_customerLevel = 'SILVER';
END IF;
END$$
In MySQL, we can call the GetCustomerLevel() stored procedure as follows:
B4X:
CALL GetCustomerLevel(103,@level);
SELECT @level AS level;
To call a stored procedure, I assume that the following statement is to be used in the RDC config.properties file
B4X:
sql.callsp_myspname= CALL GetCustomerLevel(?,@?)
In the B4A
B4X:
Dim CustomerNumber as Int :CustomerNumber = 22
Dim CustomerLevel as String :CustomerLevel = ''
Dim cmd As DBCommand
cmd.Initialize
cmd.Name="callsp_myspname"
' I don't have any idea regarding the next line
' How to pass the Variable and retrieve its value
cmd.Parameters=Array As Object(CustomerNumber,CustomerLevel)
reqManager.ExecuteCommand(cmd, "AddUser" )
The second parameter ie @? is the OUT parameter. I don't know how to retrieve this OUT parameter's value from the Sub JobDone.
Any advice or a sample is appreciated.
Thanks & Regards
Anser
Last edited: