We want to call a stored procedure of Maria DB and want to execute it through the frappe framework code. I have tried frappe.db.sql(“CALL SPNAME;”) but it’s not working, has anyone tried it practically, pls share some sample code. it will be a great help.
import frappe
@frappe.whitelist()
def call_update_gross_pay_stored_proc():
try:
frappe.db.sql("CALL `update_gross_pay`", ())
except Exception as e:
frappe.throw("An error occurred while calling the stored procedure.")
frappe.ui.form.on('Employee Test', {
refresh: function(frm){
frm.add_custom_button(__('UPDATE GROSS PAY'), function(){
frappe.call({
method: "frappe.employee.doctype.employee_test.store_procedure.call_update_gross_pay_stored_proc",
callback: function(response) {
console.log(result)
}
});
});
}
});
DELIMITER //
CREATE PROCEDURE _dc1eeb63b0ad9a8a.update_gross_pay()
BEGIN
UPDATE tabEmployee Test
SET gross_pay = 5000;
END //
DELIMITER ;