Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Funciton & VARCHAR2 problem
1st: Please use a valid email address when posting here!
2nd:
> How do I define variable p_code? The "FUNCTION dCount (p_code IN
> VARCHAR2)" declaration gives no results at all, i.e. count is 0. If I
> try to declare it as "CHAR(4)" I get compilation error.
SQL> create or replace FUNCTION dCount (p_code IN CHAR)
RETURN NUMBER IS
result NUMBER;
BEGIN
select count(*) INTO result from dd a
where a.code=p_code;
RETURN result;
END;
/
2 3 4 5 6 7 8 9
Function created.
SQL>
SQL> drop table dd;
Table dropped.
SQL> create table dd (code char(4));
Table created.
SQL> insert into dd values ('AA');
1 row created.
SQL> commit;
Commit complete.
SQL> select dCount('AA') from dual;
DCOUNT('AA')
1 Received on Wed Apr 10 2002 - 12:56:28 CDT
![]() |
![]() |