الانتقال إلى المحتوى

Need Help To Make This Functions


free2000000

Recommended Posts

Create a package, which contains the following functions and procedures, in the HR account.


1. A function that has one input parameter of type NUMBER, and returns the square of its input.
2. A function that has three input parameters of type NUMBER, and returns the minimum of its three
inputs.
3. A function that has one input parameter of type INTEGER. The function returns TRUE if its input is a
prime number and FALSE if its input is not a prime number. A prime number (or a prime) is a natural
number that has exactly two distinct natural number divisors: 1 and itself. Here is a list of the first
twenty prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71.
4. A procedure that shows the names of employees (lastName, firstName) sorted by last name.
5. A procedure that shows the names of employees (firstName lastName) salaries less than 10000.
6. A procedure that shows the names of countries sorted by region id.
In implementing the 3rd function, you can search the web for algorithms on prime numbers. These algorithms
may be written in other programming languages. However, you will get the idea on how to
implement the function. Here is a prime testing algorithm written in Python. You may also need to get
familar with some PL/SQL data types (Figure 1). To get more information, see this PL/SQL datatypes. You
may need the MOD function in your implementation.

post-105730-1269619211_thumb.jpg

رابط هذا التعليق
شارك

  • بعد 3 أسابيع...

CREATE OR REPLACE FUNCTION TEST.max_number (
p_number_a IN NUMBER,
p_number_b IN NUMBER,
p_number_c IN NUMBER
)
RETURN NUMBER
AS
v_number_a NUMBER;
v_number_b NUMBER;
v_number_c NUMBER;
v_max NUMBER;
BEGIN
v_number_a := p_number_a;
v_number_b := p_number_b;
v_number_c := p_number_c;

IF v_number_a > v_number_b AND v_number_a > v_number_c
THEN
v_max := v_number_a;
ELSIF v_number_b > v_number_a AND v_number_b > v_number_c
THEN
v_max := v_number_b;
ELSIF v_number_c > v_number_a AND v_number_c > v_number_b
THEN
v_max := v_number_c;
END IF;

RETURN v_max;
END;

رابط هذا التعليق
شارك

2. A function that has three input parameters of type NUMBER, and returns the minimum of its three
inputs.

create or replace function minnum(v_a number,v_b number,v_c number)
return number
is 
begin if(v_a<v_ then
if(v_a<v_c) then 
return v_a;
elsif(v_a>v_c) then 
return v_c;
end if;
elsif(v_a>v_ then 
if(v_b<v_c) then 
return v_b;
elsif(v_b>v_c) then 
return v_c;
end if; 
end if;
end

;

رابط هذا التعليق
شارك

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية