-----function
create or replace
function isNumber ( strNum in varchar2 )
return char
is
chkNum number;
begin
chkNum := to_number(strNum);
return 'Y';
exception
when others
then return 'N';
end isNumber;
declare
ww varchar2(10):='17';
begin
dbms_output.put_line(isNumber(ww));
end;
-----procedure
create or replace
procedure isNumber2 ( strNum in varchar2 )
is
chkNum number;
begin
chkNum := to_number(strNum);
dbms_output.put_line(chkNum);
exception
when others
then null;
end isNumber2;
call isNumber2('13');
create or replace
function isNumber ( strNum in varchar2 )
return char
is
chkNum number;
begin
chkNum := to_number(strNum);
return 'Y';
exception
when others
then return 'N';
end isNumber;
declare
ww varchar2(10):='17';
begin
dbms_output.put_line(isNumber(ww));
end;
-----procedure
create or replace
procedure isNumber2 ( strNum in varchar2 )
is
chkNum number;
begin
chkNum := to_number(strNum);
dbms_output.put_line(chkNum);
exception
when others
then null;
end isNumber2;
call isNumber2('13');
PL/SQL函数与过程示例
本文介绍了一个简单的PL/SQL示例,包括用于验证输入字符串是否为数字的函数和过程。通过这些示例,读者可以了解如何使用异常处理来确保程序的健壮性,并学习如何使用dbms_output进行结果输出。
103

被折叠的 条评论
为什么被折叠?



