im having trouble creating a function..
I want the function to find what rent a certain account had at a certain date.
The function takes 2 parameters rentacc (number) and rentdate (varchar2)
create or replace function get_rent(rentacc in number,rentdate in varchar2)
return number
as
atype number :=rentacc
begin
if atype =1
then
select "RATE" from "RENTCHANGE" where TO_DATE(rentdate, 'YYYY-MM-DD') >= TIME or TO_DATE(rentdate, 'YYYY-MM-DD') <=TIME;
else return -1;
end if;
end get_rent;
This is my table rentchange
ID ACOUNT RATE TIME
---------- ---------- ---------- ----------
123 1 ,58 2013-07-09
124 1 ,69 2013-09-02
125 1 1,78 2013-10-07
126 1 2,7 2013-10-17
select function_name(1,20131010)
from dual;
would return
function_name
-------------------------
1,78
If someone has any advice i would appreciate it alot. Thanks.