Created
May 16, 2019 23:48
-
-
Save bobby5892/76dcaef9bf3547953de2b9d442b5ebdd to your computer and use it in GitHub Desktop.
276 Week 7 Monday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE cars ( | |
carID NUMBER(10), | |
carType VARCHAR2(20) | |
); | |
SET SERVEROUTPUT ON; | |
CREATE OR REPLACE PROCEDURE createArray IS | |
TYPE list_of_cars IS TABLE OF cars.carType%TYPE INDEX BY PLS_INTEGER; | |
virtualTableCars list_of_cars; | |
l_row PLS_INTEGER; | |
BEGIN | |
virtualTableCars (424242) :='Mustang'; | |
virtualTableCars (24242424) :='Camero'; | |
virtualTableCars (86753309) :='Trans Am'; | |
virtualTableCars (185) :='Maserati'; | |
virtualTableCars (5565) :='Corvette'; | |
virtualTableCars (00001) :='Pinto'; | |
l_row:=virtualTableCars.FIRST; | |
WHILE (l_row IS NOT NULL) | |
LOOP | |
DBMS_OUTPUT.put_line (virtualTableCars (l_row)); | |
l_row := virtualTableCars.NEXT (l_row); | |
END LOOP; | |
END; | |
EXEC createArray(); | |
/*Create a stored procedure that will create an associative array: | |
(based on the example on page 346 of the textbook) | |
A type of product code table and it’s index | |
Define values (5 or 6) for the elements | |
Loop through the table and print out the array | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment