Don??™t forget to set the
$$ delimiter before executing the code of each step.
2. Execute this code, which creates the customer_get_login_info stored procedure in your tshirtshop
database:
-- Create customer_get_login_info stored procedure
CREATE PROCEDURE customer_get_login_info(IN inEmail VARCHAR(100))
BEGIN
SELECT customer_id, password FROM customer WHERE email = inEmail;
END$$
CHAPTER 16 ?– MANAGING CUSTOMER DETAILS 502
When a user logs in to the site, you must check the user??™s password. The customer_get_login_info
stored procedure returns the customer ID and the hashed password for a user with a specific e-mail.
3. Execute the following code, which creates the customer_add stored procedure in your tshirtshop
database:
-- Create customer_add stored procedure
CREATE PROCEDURE customer_add(IN inName VARCHAR(50),
IN inEmail VARCHAR(100), IN inPassword VARCHAR(50))
BEGIN
INSERT INTO customer (name, email, password)
VALUES (inName, inEmail, inPassword);
SELECT LAST_INSERT_ID();
END$$
The customer_add stored procedure is called when a user registers on the site. This stored procedure
returns the customer ID for that user to be saved in the session.
4. Execute this code, which creates the customer_get_customer stored procedure in your tshirtshop
database:
-- Create customer_get_customer stored procedure
CREATE PROCEDURE customer_get_customer(IN inCustomerId INT)
BEGIN
SELECT customer_id, name, email, password, credit_card,
address_1, address_2, city, region, postal_code, country,
shipping_region_id, day_phone, eve_phone, mob_phone
FROM customer
WHERE customer_id = inCustomerId;
END$$
The customer_get_customer stored procedure returns full customer details for a given customer ID.
Pages:
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624