1
2
3
4
5 DELIMITER $$
6
7CREATE PROCEDURE GetCustomerLevel(
8 IN customerNo INT,
9 OUT customerLevel VARCHAR(20)
10)
11BEGIN
12
13 DECLARE credit DEC(10,2) DEFAULT 0;
14
15 -- get credit limit of a customer
16 SELECT
17 creditLimit
18 INTO credit
19 FROM customers
20 WHERE
21 customerNumber = customerNo;
22
23 -- call the function
24 SET customerLevel = CustomerLevel(credit);
25END$$
26
27DELIMITER ;Code language: SQL (Structured Query Language) (sql)