Question

In: Computer Science

Write a PL/SQL procedure called FENCE that takes three arguments MIN, MAX, STEP and sends to...

Write a PL/SQL procedure called FENCE that takes three arguments MIN, MAX, STEP and
sends to the screen the numbers:
MIN, MIN+STEP, MIN+2*STEP, etc. up to MAX.
Note: the last number before MAX could be closer to MAX than STEP.
Every number should be shown in a separate row.
MAX should be shown. This should work for negative numbers too.
Example:
FENCE(2, 9, 3)
Should send to the screen:
2
5
8
9
Write a main program that calls FENCE(…) one time.
Show the complete PL/SQL code.
Both procedure and main program.
Show a SNIP of SQL Developer that shows
================================

Write a PL/SQL function FENCESUM that takes three arguments MIN, MAX, STEP and that
computes and returns the SUM of all the FENCE values.
Example:
FENCESUM(2, 9, 3)
Should return
24
FENCESUM should be called by a main program that sends the result of FENCESUM to the
screen.
Show the complete PL/SQL code. Both function and main program.

Solutions

Expert Solution

1. PL/SQL PROCEDURE:

DECLARE
MINN number;
MAXX number;
STEP number;

PROCEDURE FENCE(MINN IN number, MAXX IN number, STEP IN number) IS
BEGIN
dbms_output.put_line(MINN);
dbms_output.put_line(MINN+STEP);
dbms_output.put_line(MINN+2*STEP);
dbms_output.put_line(MAXX);
END;



BEGIN
MINN:= 2;
MAXX:= 9;
STEP:= 3;
FENCE(MINN, MAXX, STEP);
END;
/

SCREENSHOT:

OUTPUT:

2. PL/SQL FUNCTION:

DECLARE
MINN number;
MAXX number;
STEP number;
SUMM number;

FUNCTION FENCESUM(MINN IN number, MAXX IN number, STEP IN number)
RETURN NUMBER
IS
BEGIN
RETURN (MINN+MAXX+STEP);
END;



BEGIN
MINN:= 2;
MAXX:= 9;
STEP:= 3;
SUMM:=FENCESUM(MINN, MAXX, STEP);

dbms_output.put_line(SUMM);
END;
/

SCREENSHOT:


Related Solutions

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)
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)
SCHEME [4 marks] Define a procedure called valid_date? that takes three arguments representing the year, month,...
SCHEME [4 marks] Define a procedure called valid_date? that takes three arguments representing the year, month, and day respectively. The procedure should return true (#t) if the values are numbers representing a valid date and false (#f) otherwise. E.g. (valid_date? 2014 10 3) → #t E.g. (valid_date? 2016 2 29) → #t E.g. (valid_date? -3000 14 87) → #f E.g. (valid_date? "2019" "September" "7th") → #f
In.java In this program write a method called upDown that takes three integers as arguments and...
In.java In this program write a method called upDown that takes three integers as arguments and returns one of these 3 strings: "increasing" if they are in strictly increasing order (note that 3,3,4 - are not strictly increasing), "decreasing" if they are in strictly decreasing order. "none" otherwise. I recommend you use a complex condition to check for this (that is, have a single if statement with one big question). In the main method do the following: read three integers...
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:...
JavaScript Write a function called "first" that takes in two arguments - the first is an...
JavaScript Write a function called "first" that takes in two arguments - the first is an argument called arr that is an array of numbers, the second is an optional number argument called num(hint: you'll need a default value - look back at the slides). If "num" was not passed in (since it's optional), the "first" function will return an array containing the first item of the array. If a value for "num" was given, the "first" function will return...
Using the ListNode file. Write methods called min and max that return the smallest and largest...
Using the ListNode file. Write methods called min and max that return the smallest and largest values in the linked list. These methods will be added to your ListNode class. For example if a variable called list stores {11, -7, 3, 42, 0, 14], the call of list.min() should return -7 and the call of list.max() should return 42. If the list is empty, return -1. Print the returned value. Write a method called insertNode that inserts a new node...
Using the ListNode file. Write methods called min and max that return the smallest and largest...
Using the ListNode file. Write methods called min and max that return the smallest and largest values in the linked list. These methods will be added to your ListNode class. For example if a variable called list stores {11, -7, 3, 42, 0, 14], the call of list.min() should return -7 and the call of list.max() should return 42. If the list is empty, return -1. Print the returned value. Write a method called insertNode that inserts a new node...
Write a program that contains a function that takes in three arguments and then calculates the...
Write a program that contains a function that takes in three arguments and then calculates the cost of an order. The output can be either returned to the program or as a side effect. 1. Ask the user via prompt for the products name, price, and quantity that you want to order. 2. Send these values into the function. 3. Check the input to make sure the user entered all of the values. If they did not, or they used...
Write a function called draw_card. It takes no arguments and returns an integer representing the value...
Write a function called draw_card. It takes no arguments and returns an integer representing the value of a blackjack card drawn from a deck. Get a random integer in the range 1 to 13, inclusive. If the integer is a 1, print "Ace is drawn" and return 1. If the integer is between 2 and 10, call it x, print "<x> is drawn" and return x (print the number, not the string literal "<x>"). If the number is 11, 12,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT