# Answered! With SQL: Design, code, and test a stored Oracle function that inputs a name as a string. With a loop, the function sums the…

With SQL:

Design, code, and test a stored Oracle function that inputs a name as a string. With a loop, the function sums the numbers from 0 to 10000 (ten thousand) in increments of the ASCII value of the first letter of the name that was input. The function you code returns that sum in the name of the function. Since the ASCII value of the letter R in my last name is 82, the sum of the numbers for me would be 0 + 82 + 164 + 246 + … + 9840 + 9922 = 605242. The next number in the series after 9922 is 9922 + 82 = 10004, which is greater than 10000 and must be omitted.

Don't use plagiarized sources. Get Your Custom Essay on
Answered! With SQL: Design, code, and test a stored Oracle function that inputs a name as a string. With a loop, the function sums the…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

A built-in function useful here is ASCII(string), which returns the ASCII value of the first letter of the string. For example, ASCII(‘ABC’) returns 65, which is the ASCII value of the letter A. Another useful function is TRUNC (the Oracle version of truncate) that can truncate a number to a whole number. For example, TRUNC(1234.5) is 1234 and TRUNC(12.9999) is 12. You might alternately use the MOD function, which returns the modulus or remainder after an integer division, or the function FLOOR may be useful, which returns the next whole number smaller than or equal to another number. For example, FLOOR(2.5) is 2, and the FLOOR(2) is also 2.

Hi,

Here is the function that I have created for the problem given

Oracle code-

create or replace function ascii_Calc1(strin in varchar2,strout number) return number as
var1 number;
ivar number:=0;
sum1 number:=0;
begin
var1:=ASCII(strin);
for ivar in 0..10000 LOOP
sum1:=sum1+var1;
end loop;
return sum1;
end ascii_Calc1;

Screenshot-