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

Home -> Community -> Usenet -> c.d.o.misc -> Re: pl/sql VARCHAR2

Re: pl/sql VARCHAR2

From: Jim Kennedy <kennedy-family_at_attbi.com>
Date: Sat, 15 Jun 2002 04:46:58 GMT
Message-ID: <6FzO8.199292$cQ3.6855@sccrnsc01>


If you want it to display that way then convert to a varchar2 Jim
"chet" <zipper59er_at_yahoo.com> wrote in message news:3988d00.0206142007.250187eb_at_posting.google.com...
> In the code below I simply want to subtract 101 from aidy to get
> '0203'. The present code obviously converts aidy to a number then
> subtracts 101 yielding the resulting number 203 however I want the
> result to be '0203'. I realize that I simply could convert the
> resulting number back to a VARCHAR2 and pad that with a '0' zero
> getting '0203'. I would prefer not to have to convert the aidy to a
> VARCHAR2 at all and simply subtract '0101' from '0304' and get '0203'
> never converting any data types. Is this possible in PL/SQL? Any
> suggestions on how to do this?
>
> set serveroutput on;
> DECLARE
> temp_aidy VARCHAR2(4) :='0';
> aidy VARCHAR2(4) := '0304';
> i NUMBER := 0;
> j NUMBER := 0;
> BEGIN
> i := to_number(aidy);
> IF i >= 304 THEN
> temp_aidy := 304-101;
> DBMS_OUTPUT.PUT_LINE(temp_aidy);
> END IF;
> END;
> /
Received on Fri Jun 14 2002 - 23:46:58 CDT

Original text of this message

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