Example of some Functions

CREATE OR REPLACE FUNCTION get
    RETURN NUMBER IS
    query_str VARCHAR2(1000);
    num_of_employees NUMBER;
BEGIN
    query_str := 'SELECT COUNT(*) FROM '
        || ' employees';
    EXECUTE IMMEDIATE query_str
        INTO num_of_employees;
    RETURN num_of_employees;
END;


CREATE OR REPLACE FUNCTION get
    RETURN varchar2 IS
    query_str VARCHAR2(1000);
    num_of_employees varchar2(50) ;
BEGIN
    query_str := 'SELECT LAST_NAME FROM
        employees where employee_id=101';
    EXECUTE IMMEDIATE query_str
        INTO num_of_employees;
    RETURN num_of_employees;
END;



CREATE OR REPLACE procedure get
 IS
    query_str VARCHAR2(1000);
    num_of_employees varchar2(50) ;
BEGIN
    query_str := 'SELECT LAST_NAME FROM
        employees where employee_id=101';
    EXECUTE IMMEDIATE query_str
        INTO num_of_employees;
dbms_output.put_line(num_of_employees);
END;



create or replace function my_sign(num number) return number is
v_1 number;
begin
if num<0 then
v_1:=-1;
elsif num=0 then
v_1:=0;
elsif num>0 then
v_1:=1;
end if;
return v_1;
end;

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন