Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle views and function problems
dbarker_at_tpgi.com.au wrote in message <6ilvm7$m5l$1_at_nnrp1.dejanews.com>...
>I have created an Oracle function that takes one input VARCHAR parameter
and
>returns a VARCHAR2(5) value. I have created a view that selects records
from
>a table and uses this function. When I perform a DESC on the view the
>function is of type VARCHAR2(2000). Does anybody have any ideas?
>
>FUNCTION lineitem(accnbri in VARCHAR2)
>
>RETURN VARCHAR IS tmp VARCHAR(5);
>BEGIN
> tmp := SUBSTR(accnbri, 12, 5);
> return tmp;
>END;
>
>CREATE OR REPLACE VIEW V_ACTUALS AS SELECT lineitem(accnbri) as line_item,
>glf_ldg_acct.* FROM glf_ldg_acct
>
1. You created a function returning VARCHAR, not VARCHAR2(5). 2. Inside the function, you have a local variable being VARCHAR2(5). 3. You cannot specify a length in a function argument datatype (See Oracle7Server SQL Reference Manual).