Every function I try to create in MySQL fails. When calling it, I get a “Function does not exist” error.
delimiter //
create function get_vendor(vendor_name_param varchar(50))
returns int
begin
declare vendor_id_var int;
select vendor_id into vendor_id_var from vendors where vendor_name = vendor_name_param;
return(vendor_id_var);
end //
delimiter ;
select invoice_number, invoice_total from invoices where vendor_id = get_vendor('ibm');
This is a pretty simple example, but I can’t figure out why it’s not working.