KeithRichards
IS-IT--Management
I’m REALLY hoping someone can point me in the right direction with this procedure.
I am using a While Do control structure to run a select statement based on the ID number of the database row. Simply, while the row ID = 1 then I want to run the first select statement which contains the function called book_value. When the ID = 2 run the second select statement containing the book_value_2 function.
The aim is to return 4 columns of data ID, CODE, FORECAST_NUMBER, LIST_PRICE and RESULT for each of the rows in the DB.
Currently when I call the procedure I am getting the error below.
Error Code : 1109
Unknown table ' test.table ' in field list
(0 ms taken).
Thanks a million! Keifey
I am using a While Do control structure to run a select statement based on the ID number of the database row. Simply, while the row ID = 1 then I want to run the first select statement which contains the function called book_value. When the ID = 2 run the second select statement containing the book_value_2 function.
The aim is to return 4 columns of data ID, CODE, FORECAST_NUMBER, LIST_PRICE and RESULT for each of the rows in the DB.
Currently when I call the procedure I am getting the error below.
Error Code : 1109
Unknown table ' test.table ' in field list
(0 ms taken).
Thanks a million! Keifey
Code:
DELIMITER $$;
DROP PROCEDURE IF EXISTS `test`.`test_proc`$$
CREATE DEFINER=`root`@`%` PROCEDURE `test_proc`()
BEGIN
DECLARE TEST_VALUE decimal(6,4);
WHILE test.table.ID = '1' DO
SET TEST_VALUE = (SELECT ID, CODE, FORECAST_NUMBER, LIST_PRICE, (FORECAST_NUMBER + book_value(CODE) – LIST_PRICE) AS RESULT
FROM test.table WHERE ID = '1');
WHILE test.table.ID = '2' DO
SET TEST_VALUE = (SELECT ID, CODE, FORECAST_NUMBER, LIST_PRICE, (FORECAST_NUMBER + book_value_2(CODE) – LIST_PRICE) AS RESULT
FROM test.table WHERE ID = '2');
END WHILE;
END$$
DELIMITER ;$$