create
orreplace
function sf_score_pm(
p_in_stuid in varchar2,
--學號
p_in_courseid in varchar2 --課程id
)return number
is ls_pm number:=0;
ls_score number:=0;
begin
--獲取該學生的成績
select t.score into ls_score from score t
where t.stuid = p_in_stuid
and t.courseid = p_in_courseid;
--獲取成績比該學生高的人數
select
count(1
)into ls_pm from score t
where t.courseid = p_in_courseid
and t.score>ls_score;
--得到該學生的成績排名
ls_pm:=ls_pm+1;
return ls_pm;
exception
when no_data_found then
dbms_output.put_line(
'該學生的課程:'
||p_in_courseid||
'的成績在成績表中找不到');
end;
create
orreplace
function daystring_to_daynumber (
daystring nchar
)return number is
daynumber number(38,
0); n number(38,
0);begin
if instr(daystring,
'w')
>
0then
n := to_number(
replace
(daystring,
'w','')
);daynumber := n *5;
endif
;return daynumber;
end;
create
orreplace
function f_get_diff_time
( start_time in
date
, end_time in
date
)return varchar2 is
diff_time varchar2(50)
;begin
select tday ||
'天'|| thour ||
'時'|| tminute ||
'分'||
round
((tt - tminute)*60
)||'秒'into diff_time
from
(select tday,
thour,
trunc(
(tt - thour)*60
) tminute,
(tt - thour)
*60 tt
from
(select tday,
trunc(
(tt - tday)*24
) thour,
(tt - tday)
*24 tt
from
(select to_number(end_time - start_time)
as tt,
trunc(to_number(end_time - start_time)
)as tday
from
(select start_time, end_time from dual)))
);return diff_time;
end;
Oracle建立WM CONCAT函式
oracle建立wm concat函式 wm concat這個函式會出錯,所以從 11g開始。官方不認可 wm concat.然後就沒這個函式了,下面就是建立wm concat這個函式的步驟 用sqlplus登入 conn sys pass word as sysdba 一 忘記除sys syste...
Oracle建立WM CONCAT函式
oracle建立wm concat函式 wm concat這個函式會出錯,所以從 11g開始。官方不認可 wm concat.然後就沒這個函式了,下面就是建立wm concat這個函式的步驟 用sqlplus登入 conn sys pass word as sysdba 一 忘記除sys syste...
Oracle建立儲存過程 建立函式 建立包
一 oracle建立儲存過程 1 基本語法 create orreplace procedureupdate emp sal name inout type,name inout type,is begin endupdate emp sal 2 寫乙個簡單的例子修改emp表的ename欄位 cre...