Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Funciton & VARCHAR2 problem
> if i hard code the variable i get the right result but if the
> parameter is passed in as a VARCHAR2 it doesn't work. what is wrong?
>
> FUNCTION dCount (p_code IN VARCHAR2)
> RETURN NUMBER IS
> result NUMBER;
> BEGIN
> select count(*) INTO result from dd a
> where a.code=p_code -- works fine if i say a.code='HR';
> RETURN result;
> END;
Version? OS? Which errors?
With 8.0.5.1.0 on Solaris 2.6 it's no problem:
KNUT_at_TST.TALMAN.DE> create table dd (code varchar2(10));
Table created.
KNUT_at_TST.TALMAN.DE> insert into dd values ('AA');
1 row created.
KNUT_at_TST.TALMAN.DE> commit;
Commit complete.
KNUT_at_TST.TALMAN.DE> create or replace FUNCTION dCount (p_code IN VARCHAR2)
2 RETURN NUMBER IS
3 result NUMBER;
4 BEGIN
5 select count(*) INTO result from dd a 6 where a.code=p_code; 7 RETURN result;
Function created.
KNUT_at_TST.TALMAN.DE> select dCount('AA') from dual;
DCOUNT('AA')
1 Received on Wed Apr 10 2002 - 11:50:37 CDT
![]() |
![]() |