--编写求绝对值的函数
CREATE OR REPLACE FUNCTION jueduizhi
(m number)
return number
is
n number(1);
begin
if m<=0 then
n:=m*(-1);
dbms_output.put_line('绝对值为:'|| n);
else
n:=m;
dbms_output.put_line('绝对值为:'|| n);
end if;
return n;
end jueduizhi;
--运用函数求绝对值(例:求 -4 的绝对值)
declare
m number(1);
b number(1);
begin
m:=-4;
b:=jueduizhi(m);
end;
编写自定义函数,实现功能和SQL内置函数ABS(n)一致,返回绝对值
最新推荐文章于 2023-12-21 13:54:38 发布