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: Oracle For Fun

Re: Oracle For Fun

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Thu, 29 Jan 2004 22:19:02 -0800
Message-ID: <1075443480.381421@yasure>


zhix wrote:

> create table t2(x varchar2(20));
>
> insert into t2 values('123-456-7893');
> insert into t2 values('12-3456-7893');
> insert into t2 values('-12345-67893');
>
> create or replace function valid_code ( p_code in varchar2 )
> return boolean
> is
> begin
> return translate(nvl(p_code,'?'),'0123456789#','##########?') = '###-###-####';
> end;
>
> select x,valid_code(x) from t2;
>
> ERROR at line 1:
> ORA-06552: PL/SQL: Statement ignored
> ORA-06553: PLS-382: expression is of wrong type
>
>
> ???????

To test a function that returns a Boolean you must wrap the function in an anonymous block.

set serveroutput on

BEGIN
   IF <your_function_name_here>('123-A5-67890') THEN      dbms_output.put_line('True');
   ELSE
     dbms_output.put_line('False');
   END IF;
END;
/

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Fri Jan 30 2004 - 00:19:02 CST

Original text of this message

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