Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Funciton & VARCHAR2 problem

Re: Funciton & VARCHAR2 problem

From: Knut Talman <knut.talman_at_mytoys.de>
Date: Wed, 10 Apr 2002 19:56:28 +0200
Message-ID: <3CB47CCC.6B27E666@mytoys.de>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US