Bob Crest Posted August 20, 2011 Share Posted August 20, 2011 Hi everybody, I've been reading this forum from a long time but I signed up today coz I got a problem. This could be very simple problem. I am a newbe and did not find the exact problem discussed in the forum. I downloaded the books scripts from Larry's site and try to follow the second site on the book. I got the following error message while importing the sql.sql file via phpmyadmin. I amusing wamp server (all other sites are working just fine) Php version: 5.3.4 Mysql version: 5.1.53 Apache: 2.2.17 Error SQL query: Documentation DELIMITER ; -- ----------------------------- -- Later in Chapter 8: -- -- ----------------------------- DELIMITER $$ CREATE PROCEDURE select_products(type VARCHAR(6), cat TINYINT) BEGIN IF type = 'coffee' THEN SELECT gc.description, gc.image, CONCAT("C", sc.id) AS sku, CONCAT_WS(" - ", s.size, sc.caf_decaf, sc.ground_whole, sc.price) AS name, sc.stock, sc.price, sales.price AS sale_price FROM specific_coffees AS sc INNER JOIN sizes AS s ON s.id=sc.size_id INNER JOIN general_coffees AS gc ON gc.id=sc.general_coffee_id LEFT OUTER JOIN sales ON (sales.product_id=sc.id AND sales.product_type='coffee' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE general_coffee_id=cat AND stock>0 ORDER by name; ELSEIF type = 'other' THEN SELECT ncc.description AS g_description, ncc.image AS g_image, CONCAT("O", ncp.id) AS sku, ncp.name, ncp.description, ncp.image, ncp.price, ncp.stock, sales.price AS sale_price FROM[...] MySQL said: Documentation #1304 - PROCEDURE select_products already exists somebdy please helpexactly what to do. Regards, Bob Link to comment Share on other sites More sharing options...
Stuart Posted August 20, 2011 Share Posted August 20, 2011 Never used stored procedures but it looks fairly straight forward that the SP select_products already exists. If you want to re-create it again: DROP PROCEDURE IF EXISTS select_products; Then run your code again. Link to comment Share on other sites More sharing options...
Larry Posted August 22, 2011 Share Posted August 22, 2011 Hey Bob, As I believe it says on the Web site, and in the SQL file itself, you should not import the entire file as is. This is in part because one stored procedure gets redefined at a later point in the book. My recommendation is to copy and paste the SQL commands as needed as you go through the material. Link to comment Share on other sites More sharing options...
Recommended Posts