Question

In: Computer Science

Create a PL/SQL anonymous block that uses a nested loop (inner loop 1 to 15; outer...

Create a PL/SQL anonymous block that uses a nested loop (inner loop 1 to 15; outer loop 1 to 5) to perform computations using the SQL functions, ABS, EXP, SQRT, ROUND, MIN, MAX, LOG, MOD, REMAINDER and POWER

The outer loop will use the functions, ABS, EXP, SQRT, ROUND to display the following messages (must be

  • “ The absolute value of <outer loop index> is <value>”
  • “ The value of e to the <outer loop index> power is <value>”
  • “ The square root of <outer loop index> is <value>”
  • “ The rounded value of <outer loop index> is <value>”

The inner loop will use the functions, MIN, MAX, LOG, MOD, REMAINDER and POWER, to display the following messages,

  • “ The minimum of value of <outer loop index> and <inner loop index> is <value> "
  • “ The maximum value of <outer loop index> and <inner loop index> is <value> "
  • "Log <outer loop index> base <inner loop index> is <value> "
  • "Log <outer loop index> base <inner loop index> is <value> "
  • "<outer loop index> Mod <inner loop index> is <value> "
  • "<outer loop index> Remainder <inner loop index> is <value> "
  • "<outer loop index> to the <inner loop index>power is <value> "

Refer to the "Numeric Functions" section of the SQL Reference section (link in Announcements) for descriptions and use of all the functions

Solutions

Expert Solution

Coding:

DECLARE
i number(3);
j number(3);
log_val number(7,2);
BEGIN
i := 1;
LOOP
/* here is outloop */
dbms_output.put_line('****************************************');   
dbms_output.put_line('The absolute value of ::'||i||' is '||abs(i));
   dbms_output.put_line('The value of e to the ::'||i||' is '||exp(i));
   dbms_output.put_line('The square root of ::'||i||' is '||sqrt(i));
   dbms_output.put_line('The rounded value of ::'||i||' is '||round(sqrt(i)));
   dbms_output.put_line('****************************************');   

j:= 1;
LOOP
   /* here is inner loop */
   dbms_output.put_line('****************************************');   
dbms_output.put_line('The minimum of value of ='||i||' and '||j||' is ='||least(i,j));
       dbms_output.put_line('The Maximum of value of ='||i||' and '||j||' is ='||GREATEST(i,j));
       dbms_output.put_line('The Log of base of ='||i||' and '||j||' is ='||log(2,3));
   dbms_output.put_line('val :'||i||' mod '||j||' is ='||mod(i,j));
   dbms_output.put_line('val :'||i||' mod '||j||' is ='||mod(i,j));
       dbms_output.put_line('val :'||i||' power is '||j||' is ='||power(i,j));
j := j +1;
       exit WHEN j=5;
END LOOP;
     
           i := i + 1;
exit WHEN i = 15;
END LOOP;
END;
/

output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

Assignment 2- 9   USING A FOR LOOP Create a PL/SQL block using a FOR loop to...
Assignment 2- 9   USING A FOR LOOP Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. The values variable for the block is starting payment due date, monthly payment amount, and a number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining...
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to...
ORACLE TASK 2-2 USING A FOR LOOP Create a PL/SQL block using a FOR loop to generate a payment schedule for a donor’s pledge, which is to be paid monthly in equal increments. Values variable for the block are starting payment due date, monthly payment amount and number of total monthly payments for the pledge. The list that’s generated should display a line for each monthly payment showing payment number, date due, payment amount, and donation balance (remaining amount of...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of...
PL/SQL Write a PL/SQL block, using a While Loop, to calculate and print the sum of the odd integers from 10 to 120 inclusive. (Hint: 11 + 13 + 15 + . . . + 97 + 99)
Please write an anonymous PL/SQL program which uses an implicit cursor to print out the score...
Please write an anonymous PL/SQL program which uses an implicit cursor to print out the score and rank of team 'Mad Scientists' in the competition 'Science Olympiad Regional Baltimore'. Please handle exceptions. Problem 4: [15 points] Please write an anonymous PL/SQL program to print out the names of students and their school names for the team that won the first place (rank=1) in Science Olympiad Maryland State (name of a competition). drop table school cascade constraints; drop table student cascade...
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade...
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade based on the value stored in a variable called grade. Use the ACC      grading system described in the course syllabus to create the block and set     the initial value of grade as 95. Use only one print statement and no      logical operators in your code. Assume a grade can exceed 100, but it      can’t be negative. Grade Scale: Grade Scale:...
Write a code block to perform nested-for-loop sorting on a vector of State objects, arranging by...
Write a code block to perform nested-for-loop sorting on a vector of State objects, arranging by their string name attribute in alphabetical order A-Z. Assume all names are fully uppercase and that there's an assignment operator for the class. The name of the vector is "states".
The inner and outer surface temperatures of a glass window 5 mm thick are 15 and...
The inner and outer surface temperatures of a glass window 5 mm thick are 15 and 5°C. The thermal resist- ance of the glass window due to conduction is Rt,cond = 1.19 × 10−3 K/W. What is the rate of heat loss through a 1 m × 3 m window? What is the thermal conductivity of the glass?
Create Procedure in (PL/SQL) called Make_Account (v_first, v_last, v_email, v_errormsg) Add a new user to the...
Create Procedure in (PL/SQL) called Make_Account (v_first, v_last, v_email, v_errormsg) Add a new user to the Account table. If the new user cannot be added, return a error message. Table Account (this is the table I need to add data using PROCEDURE) Account_no (PK) Email (VARCHAR2) first (VARCHAR2) last (VARCHAR2)
C++ Language Implement a two-dimensional image using a nested loop. 1) Create an integer constant DIM...
C++ Language Implement a two-dimensional image using a nested loop. 1) Create an integer constant DIM and set it equal to 5. 2) Use a nested loop to print the output in terms of DIM. Example output: ***** *---* *---* *---* *****
‏1. The impeller in a centrifugal pump has inner diameter as 125 mm and outer diameter...
‏1. The impeller in a centrifugal pump has inner diameter as 125 mm and outer diameter as 270 mm. The pump runs at 1400 rpm. The vane angles of impeller at inlet and outlet are 17° and 30° respectively. The water enters the impeller radially and velocity of flow is constant. Determine the work done by impeller per unit weight of water.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT