First page Back Continue Last page Image

A SELECT statement using the last FUNCTION

SELECT invoice_number, invoice_total

FROM invoices

WHERE vendor_id = get_vendor_id('IBM');

DELIMITER //

CREATE FUNCTION get_vendor_id

(

vendor_name_param VARCHAR(50)

)

RETURNS INT

DETERMINISTIC READS SQL DATA

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//

Here is the output, but realize the vendor_id is not part of the output it was just used to get the output