标签:procedure 销售 客户 公司 入参 分享 add color char
DROP TABLE IF EXISTS `CUSTOMERS`; CREATE TABLE CUSTOMERS ( `id` INT ( 11 ) NOT NULL AUTO_INCREMENT,-- ID `cust_num` INT ( 11 ),-- 客户编号 `company` VARCHAR ( 20 ),-- 公司名称 `cust_rep` INT ( 11 ),-- 雇员 `credit_limit` DECIMAL ( 16, 2 ),-- 信用限额 PRIMARY KEY ( `id` ) ); DROP TABLE IF EXISTS `SALESREPS`; CREATE TABLE `SALESREPS` ( `id` INT ( 11 ) NOT NULL AUTO_INCREMENT,-- ID `quota` DECIMAL ( 16, 2 ),-- 销售目标 `empl_num` INT ( 11 ), PRIMARY KEY ( `id` ) ); INSERT INTO `SALESREPS` ( ID, QUOTA, EMPL_NUM ) VALUES ( 1, 20000.00, 103 ); DROP TABLE IF EXISTS `OFFICES`; CREATE TABLE `OFFICES` ( `id` INT ( 11 ) NOT NULL AUTO_INCREMENT, `target` DECIMAL ( 16, 2 ), `city` VARCHAR ( 20 ), PRIMARY KEY ( `id` ) ); INSERT INTO `OFFICES` ( id, target, city ) VALUES ( 1, 20000.00, ‘深圳‘ ); DROP PROCEDURE IF EXISTS `ADD_CUST`; DELIMITER // CREATE PROCEDURE `ADD_CUST` ( IN c_name VARCHAR ( 20 ), IN c_num INTEGER, IN cred_lim DECIMAL ( 16, 2 ), IN tgt_sls DECIMAL ( 16, 2 ), IN c_rep INTEGER, IN c_offc VARCHAR ( 20 ) ) BEGIN INSERT INTO customers ( cust_num, company, cust_rep, credit_limit ) VALUES ( c_num, c_name, c_rep, cred_lim ); UPDATE salesreps SET quota = quota + quota + tgt_sls WHERE empl_num = c_rep; UPDATE offices SET target = target + tgt_sls WHERE city = c_offc; COMMIT; END // CALL `ADD_CUST` ( ‘李四‘, 504, 200.00, 500.00, 309, ‘广州‘ );
标签:procedure 销售 客户 公司 入参 分享 add color char
原文地址:https://www.cnblogs.com/halo-halo/p/9026078.html