Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function problem 1

Status
Not open for further replies.

Crystalboy1

Programmer
Sep 4, 2007
89
GB
hi there,

I have written a function to check if a given date is a working day or not. the body of the function is given below.

function IsWorkingDate(datein varchar2) return boolean is
knt integer;
begin
insert into dmo_pwlb_reports_tt_isworking
select f_date
from tblholid_dat hol
where schedule = 'LONDON'
and (substr(datein, 5, 4) = '0101' or substr(datein, 5, 4) = '1225' or
substr(datein, 5, 4) = '1226' or
trim(to_char(to_date(datein, 'YYYYMMDD'), 'DAY')) = 'SUNDAY' or
trim(to_char(to_date(datein, 'YYYYMMDD'), 'DAY')) = 'SATURDAY');

select count(*) into knt from dmo_pwlb_reports_tt_isworking;
if knt = 0 then
return true;
else
return false;
end if;
end IsWorkingDate;



When i try to use the function

select isworkingdate(20081225) from dual



It gives me the following message.

ORA-06552: PL/SQL : Statment ignored
ORA-06553: PLS-382: Expresssion is of wrong type.

The strange thing is, if i test the function, its gives me the right results.

Please help!!!!


 
Is it just that you need to call the function as follows?

Code:
select isworkingdate('20081225') from dual




Steve Phillips, Crystal Trainer/Consultant
 
HI thanks for your reply. Well i did try dat which give me the same results.
ORA-06552: PL/SQL : Statment ignored
ORA-06553: PLS-382: Expresssion is of wrong type.

i got other functions written in same way, and all of them work. Is this the right way for declaration and returning of a boolean datatype ?
 
CrystalBoy,

When I need an otherwise-boolean function to work in SQL, I simply return a character 'Y' or 'N', or 'T' or 'F', or '1' or '0' from the function, then use:
Code:
...WHERE <function>(<args>) = 'Y' (or whatever return codes I want)
Let us know if this works as you want in your SQL invocation.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top