Tuesday, February 14, 2012

debug procedure.

Can anyone tell me what is wrong with the following? It is creating aprocedure with compilation errors.

CREATE OR REPLACE PROCEDURE get_parts (pizza IN VARCHAR2)
_
BEGIN
SELECT NAME
INTO_ temp_table
FROM pizza_items
WHERE pizza = USED_IN;
END;

iT READS FROM TABLE

CREATE TABLE PIZZA_ITEMS(id NUMBER PRIMARY KEY,
name VARCHAR2(20),
used_in VARCHAR2(20));
CREATE SEQUENCE pizza_sequence START WITH 1001;

And is meant to match the pizza name with the toppings used and place the results into temp_table
CREATE TABLE temp_table(ingredient varchar2(20));

Any ideas?Hi minniemouse,

Would you please post also the compilation error?|||1) You need the keyword IS or AS before BEGIN

2) "SELECT name INTO temp_table" expects to find a VARIABLE called "temp_table", not a table. To insert data into a table requires an INSERT statement.

Try this:

CREATE OR REPLACE PROCEDURE get_parts (pizza IN VARCHAR2)
IS
BEGIN
INSERT INTO temp_table(ingredient)
SELECT NAME
FROM pizza_items
WHERE pizza = USED_IN;
END;
/

No comments:

Post a Comment