خرید بک لینک

Vote count: 0

I've been working on this code that's supposed to do this according to the book: Write a script that creates and calls a stored procedure named test. This stored procedure should create a cursor for a result set that consists of the product_name and list_price columns for each product with a list price that’s greater than $700. The rows in this result set should be sorted in descending sequence by list price. Then, the procedure should display a string variable that includes the product_name and list price for each product so it looks something like this: "Gibson SG", "2517.00" | "Gibson Les Paul", "1199.00""

Unfortunately what my code does is retu a null value instead of anything. what am i doing wrong?

USE my_guitar_shop;

DROP PROCEDURE IF EXISTS test;

DELIMITER //

Create Procedure test() Begin DECLARE names_var VARCHAR(50); DECLARE prices_var DECIMAL (8,2); DECLARE results VARCHAR(150); DECLARE done TINYINT;

DECLARE products_cursor CURSOR FOR
    SELECT product_name, list_price FROM products;

DECLARE continue handler for not found set done = 1;
SET done = 0;

OPEN products_cursor;

testloop : loop
FETCH products_cursor INTO names_var, prices_var;
IF done = 1 then leave testloop;
END IF;

IF prices_var > 700 THEN
    SET results = concat(results, "names_var", ', ', "prices_var", '|');
END if;
END loop testloop; 

CLOSE products_cursor;

SELECT results;

END //

DELIMITER ;

Call test;

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 16 فروردين 1395 ساعت: 11:08

صفحه بندی