| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle For Fun
I feel a new weekly metric coming on
Nbr of posts
Nbr of _correct_ posts
Don't worry Daniel, they only come in three's ;-)
VC wrote:
> Hello Daniel,
>
> "Daniel Morgan" <damorgan_at_x.washington.edu> wrote in message
> news:1075776599.3474_at_yasure...
>
>>VC wrote: >> >>>SQL> create or replace function f1( p_number in varchar2 ) return
>>> 2 begin
>>> 3 return translate(p_number,'0123456789','9999999999') =
>>>'999-999-9999';
>>> 4 end;
>>> 5 /
>>>
>>>Function created.
>>>
>>>SQL> create table t1(x varchar2(20))
>>> 2 /
>>>
>>>Table created.
>>>
>>>SQL> insert into t1 values('123-456-7890')
>>> 2 /
>>>
>>>1 row created.
>>>
>>>SQL> insert into t1 values('123-456-78j0')
>>> 2 /
>>>
>>>1 row created.
>>>
>>>SQL> insert into t1 values(null)
>>> 2 /
>>>
>>>1 row created.
>>>
>>>SQL> set serverout on
>>>SQL> declare
>>> 2 l_str varchar2(20);
>>> 3 begin
>>> 4 for l in (select x from t1) loop
>>> 5 if f1(l.x) then l_str := 'valid'; else l_str := 'not valid';
>>>if;
>>> 6 dbms_output.put_line('<'||l.x||'>'||l_str);
>>> 7 end loop;
>>> 8 end;
>>> 9
>>> 10 /
>>><123-456-7890>valid
>>><123-456-78j0>not valid
>>><>not valid <-- null is not valid
>>>
>>>PL/SQL procedure successfully completed.
>>>
>>>SQL>
>>>
>>>
>>>????????????
>>>
>>>
>>>VC
>>
>>What, exactly, do you expect "insert into t1 values(null)" to do?
>>Try select count(*) from t1;
>>You need to create another column ...
![]() |
![]() |