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 -> pl/sql VARCHAR2

pl/sql VARCHAR2

From: chet <zipper59er_at_yahoo.com>
Date: 14 Jun 2002 21:07:28 -0700
Message-ID: <3988d00.0206142007.250187eb@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:07:28 CDT

Original text of this message

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