Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help on creating a procedure in sql, this file will be used to compile. Then afterwards I have to make another sql file to run

Help on creating a procedure in sql, this file will be used to compile. Then afterwards I have to make another sql file to run and output the results. But for this part I'm stuck on the procedure tables.

image text in transcribed

image text in transcribed

Those are the instructions. image text in transcribed

Here's a sample.

image text in transcribed

These are the tables/columns were using.

image text in transcribed

What the final result is supposed to look like kind of.

Compile File, should have two procedures Extract Columns, Get Tables (in this order) Get Tables (receives no parameters) o In the AS section Define a cursor to get all tables for your userid Use... SELECT Table Name FROM User Tables to load up the cursor Define a composite variable to hold an individual row In the BEGIN section o Use DBMS_OUTPUT.PUT_LINE statements for PAGE heading items Oracle Catalog Extract Utility v1.0 ---- Run on Jan 6, 2020 at 12:34 Start extracting table COURSES Create a loop that will loop through the tables (remember you created a cursor and you need to loop through this cursor to get the table names) Use DBMS_OUTPUT.PUT_LINE statements for table header items First time through the loop you need to output the first table name hint: you will need to use the composite variable declared at the start At this point, you should call the extract columns procedure to take care of showing the rows for this particular table. You will need to send over the table name to the extract columns procedure. Use DBMS_OUTPUT.PUT_LINE statements for table footer items Loop ends when tables the end of the cursor is reached Use DBMS_OUTPUT.PUT_LINE statements for PAGE footer items Extract Columns, needs to accept the table name parameter being sent from the Extract Tables procedure In the AS section Define a cursor to get all columns for your userid | Use... SELECT Column Name FROM User. Tab.Columns to load up the cursor but we need to only find only the columns for the table name that was passed in. hint: Use a WHERE clause Define a composite variable to hold an individual row o In the BEGIN section Create a loop that will loop will print out the column names (remember you created a cursor and you need to loop through this cursor to get the column names) hint: you will need to use the composite variable declared at the start HINT: To align the data types Store the column name in a CHAR type variable using a size that you deem necessary. The CHAR datatype will automatically pad additional spaces at the end of the column name. Then print the datatypes and sizes at the end of the column variable. To print a line and include a line feed use DBMS_OUTPUT.PUT_LINE To continue printing on the same line that it is presently on use DBMS_OUTPUT.PUT 2. Create a file named YourLastName_A_Compile.SQL. This file will contain your stored procedures. You will be creating two procedures: Procedure Get_Tables: Purpose: To process each table in your schema (use the 'USER_'System Catalog tables) and output table-related lines (see sample on last page, lines 1-6, 11-15 and 24-28). Notes: Tables must appear in alphabetical order. Procedure Get_Tables will call the procedure Extract_Columns for each table. Procedure Extract_Columns: Purpose: Output column-related lines for the currently selected table in Get_Tables procedure (see sample on last page, lines 7-10 & 16-23). Note: Columns must be listed in the same order as in the original CREATE Table statement. 3. Create a file named YourLastName_A_Run.SQL. This file will contain the SQL code necessary to: Run the Get_Tables stored procedure(described above) Spool output to a file called Create_Tables_YourLastName.SQL (hint: SERVEROUTPUT size should be minimum 10,000). Figure 1: Sample result from PL/SQL code run Note: Sample only, your tables will differ. The line numbers and the text to the left of the lines numbers is only for reference within this document. Do not produce line numbers or text to the left of the line numbers Oracle Catalog Extract Utility v1.0 ---- 1 2 3 4 Run on Jan 6, 2021 at 12:34 Get_Tables Procedure 5 6 7 Extract_Columns Procedure 8 9 Start extracting table COURSES CREATE TABLE COURSES COURSEID COURSENAME , DESCRIPTION COURSECODE ); -- END of Table COURSES creation 1 Get_Tables Procedure 1 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Extract_Columns Procedure Start extracting table CUSTOMERS CREATE TABLE CUSTOMERS ( CUSTOMER LASTNAME FIRSTNAME ADDRESS . CITY STATE ZIP REFERRED ); -- END of Table CUSTOMERS creation Get_Tables Procedure Oracle Catalog Extract Utility v1.0 Run Completed on Jan 6, 2021 at 12:35 -- 0 Tables (Filtered) 0 ORDERS 1 ORDERNUM 1 ORDERCHAR CUST 1 REP 1 MANUF 1 PROD QTY 1 AMOUNT PRODUCTS 1 MFR 0 | PRODUCT O DESCRIPTION PRICE QTYONHAND File Edit Format View Help Oracle Catalog Extract Utility v1.0 Run on AUG 26, 2020 at 14:27 Start extracting table ORDERS CREATE TABLE ORDERS ( ORDERNUM ORDERCHAR CUST REP MANUF PROD QTY AMOUNT I), -- END of table ORDERS creation Start extracting table PRODUCTS CREATE TABLE PRODUCTS ( MFR , PRODUCT DESCRIPTION PRICE , QTYONHAND END of table PRODUCTS creation Compile File, should have two procedures Extract Columns, Get Tables (in this order) Get Tables (receives no parameters) o In the AS section Define a cursor to get all tables for your userid Use... SELECT Table Name FROM User Tables to load up the cursor Define a composite variable to hold an individual row In the BEGIN section o Use DBMS_OUTPUT.PUT_LINE statements for PAGE heading items Oracle Catalog Extract Utility v1.0 ---- Run on Jan 6, 2020 at 12:34 Start extracting table COURSES Create a loop that will loop through the tables (remember you created a cursor and you need to loop through this cursor to get the table names) Use DBMS_OUTPUT.PUT_LINE statements for table header items First time through the loop you need to output the first table name hint: you will need to use the composite variable declared at the start At this point, you should call the extract columns procedure to take care of showing the rows for this particular table. You will need to send over the table name to the extract columns procedure. Use DBMS_OUTPUT.PUT_LINE statements for table footer items Loop ends when tables the end of the cursor is reached Use DBMS_OUTPUT.PUT_LINE statements for PAGE footer items Extract Columns, needs to accept the table name parameter being sent from the Extract Tables procedure In the AS section Define a cursor to get all columns for your userid | Use... SELECT Column Name FROM User. Tab.Columns to load up the cursor but we need to only find only the columns for the table name that was passed in. hint: Use a WHERE clause Define a composite variable to hold an individual row o In the BEGIN section Create a loop that will loop will print out the column names (remember you created a cursor and you need to loop through this cursor to get the column names) hint: you will need to use the composite variable declared at the start HINT: To align the data types Store the column name in a CHAR type variable using a size that you deem necessary. The CHAR datatype will automatically pad additional spaces at the end of the column name. Then print the datatypes and sizes at the end of the column variable. To print a line and include a line feed use DBMS_OUTPUT.PUT_LINE To continue printing on the same line that it is presently on use DBMS_OUTPUT.PUT 2. Create a file named YourLastName_A_Compile.SQL. This file will contain your stored procedures. You will be creating two procedures: Procedure Get_Tables: Purpose: To process each table in your schema (use the 'USER_'System Catalog tables) and output table-related lines (see sample on last page, lines 1-6, 11-15 and 24-28). Notes: Tables must appear in alphabetical order. Procedure Get_Tables will call the procedure Extract_Columns for each table. Procedure Extract_Columns: Purpose: Output column-related lines for the currently selected table in Get_Tables procedure (see sample on last page, lines 7-10 & 16-23). Note: Columns must be listed in the same order as in the original CREATE Table statement. 3. Create a file named YourLastName_A_Run.SQL. This file will contain the SQL code necessary to: Run the Get_Tables stored procedure(described above) Spool output to a file called Create_Tables_YourLastName.SQL (hint: SERVEROUTPUT size should be minimum 10,000). Figure 1: Sample result from PL/SQL code run Note: Sample only, your tables will differ. The line numbers and the text to the left of the lines numbers is only for reference within this document. Do not produce line numbers or text to the left of the line numbers Oracle Catalog Extract Utility v1.0 ---- 1 2 3 4 Run on Jan 6, 2021 at 12:34 Get_Tables Procedure 5 6 7 Extract_Columns Procedure 8 9 Start extracting table COURSES CREATE TABLE COURSES COURSEID COURSENAME , DESCRIPTION COURSECODE ); -- END of Table COURSES creation 1 Get_Tables Procedure 1 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Extract_Columns Procedure Start extracting table CUSTOMERS CREATE TABLE CUSTOMERS ( CUSTOMER LASTNAME FIRSTNAME ADDRESS . CITY STATE ZIP REFERRED ); -- END of Table CUSTOMERS creation Get_Tables Procedure Oracle Catalog Extract Utility v1.0 Run Completed on Jan 6, 2021 at 12:35 -- 0 Tables (Filtered) 0 ORDERS 1 ORDERNUM 1 ORDERCHAR CUST 1 REP 1 MANUF 1 PROD QTY 1 AMOUNT PRODUCTS 1 MFR 0 | PRODUCT O DESCRIPTION PRICE QTYONHAND File Edit Format View Help Oracle Catalog Extract Utility v1.0 Run on AUG 26, 2020 at 14:27 Start extracting table ORDERS CREATE TABLE ORDERS ( ORDERNUM ORDERCHAR CUST REP MANUF PROD QTY AMOUNT I), -- END of table ORDERS creation Start extracting table PRODUCTS CREATE TABLE PRODUCTS ( MFR , PRODUCT DESCRIPTION PRICE , QTYONHAND END of table PRODUCTS creation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

3030871002, 978-3030871000

More Books

Students also viewed these Databases questions

Question

The Nature of Nonverbal Communication

Answered: 1 week ago

Question

Functions of Nonverbal Communication

Answered: 1 week ago

Question

Nonverbal Communication Codes

Answered: 1 week ago