Can anybody change this logic ?

Hi,
In a form I have a block :serial_entry and two text fields one is vfi_range_quantity(number),fm_serial_number(char) I will enter vfi_range_quantity is 3 and tab curosr goes to fm_serial_number and will enter 546-878-335
and press tab it will pop up message saying 546-878-335,546-878-336,546-878-337. Its working fine.
The code for this is attached at the end.
Now what I want is I will enter vfi_range_quantity is 3, fm_serial_number 546-878-000 its poping up the message saying 546-878-0,546-878-1,546-878-2. What I want is 546-878-000,546-878-001,546-878-002
AND If I Enter vfi_range_quantity is 3 fm_serial_number 546-878-999
its poping up the message saying 546-878-999,546-878-1000,546-878-1001.
What I want is 546-878-999 only..
Thanks,
Devender
When-Validate-item of fm_serial_number
DECLARE
l_fm_serial_number VARCHAR2 (100);
l_part_number VARCHAR2 (100);
len_fm_serial_number     NUMBER;
temp_part VARCHAR2 (50);
temp_part1 VARCHAR2 (50);
temp_part5 VARCHAR2 (500);
temp_part2 NUMBER;
temp_part3 NUMBER;
temp_part4 NUMBER;
v_count_parent           NUMBER:=1;
v_count_vmsn           NUMBER;
BEGIN
     len_fm_serial_number:=length(:serial_entry.fm_serial_number);
     IF len_fm_serial_number = 11 THEN
          temp_part3:= 9;temp_part4:=7;
     END IF;
IF v_count_parent != 0 THEN
     BEGIN --++++
     temp_part2 :=
TO_NUMBER (SUBSTR (:serial_entry.fm_serial_number, temp_part3, 3));
          FOR i IN 1 ..:serial_entry.vfi_range_quantity
     LOOP
     BEGIN
temp_part1 :=
SUBSTR (:serial_entry.fm_serial_number, 1, temp_part4)|| '-'|| TO_CHAR (temp_part2);
TEMP_PART := NULL;
     END;
     temp_part2 := temp_part2 + 1;
     temp_part5 := temp_part5||','||temp_part1;
END LOOP;
Message(temp_part5);
Message(temp_part5);
END; --++++
END IF;
END;
-------------------------------

DECLARE
     FUNCTION generate_serial_numbers(
          p_serial_no IN VARCHAR2,
          p_range IN PLS_INTEGER)
          RETURN VARCHAR2 IS
          part3_num PLS_INTEGER;
          retval VARCHAR2(100) := '';
     BEGIN
          BEGIN
               part3_num := To_Number(SubStr(p_serial_no,9));
          EXCEPTION
               WHEN Value_Error THEN
                    Raise_Application_Error(-20000,'Bad serial no - use ''nnn-nnn-nnn''');
          END;
          FOR i IN 0..(p_range - 1) LOOP
               IF part3_num + i <= 999 THEN
                    IF i != 0 THEN
                         retval := retval || ', ';
                    END IF;
                    retval := retval || SubStr(p_serial_no,1,8) || To_Char(part3_num + i,'fm009');
               END IF;
          END LOOP;
          RETURN retval;
     END;
BEGIN
     Dbms_Output.put_line(generate_serial_numbers('546-878-1',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-001',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-999',3));
     Dbms_Output.put_line(generate_serial_numbers('546-878-1',6));
     Dbms_Output.put_line(generate_serial_numbers('546-878-egg',6));
END;
/any use?

Similar Messages

Maybe you are looking for

  • Insert data into the xml schema-based xmltype table problem!

    Hello, there, I got problem in inserting data into the xmltype table after registered XML schema and created table. details see below: 1) xml schema: <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSpy v2007 sp2 (http://www.altova.com) by

  • Is there/Will there be a "device" to check for M.L. compatability?

    I have a late 2008 white MacBook. It's the 2.4Ghz model with 4GB Ram. I think it would be powerful enough to run Mountain Lion but maybe there's a proc compatability issue? If I buy ML from the app store and it doesn't install will I still be charged

  • Storage Problem on my MacBook Pro 2011

    I've deleted and/or backed up pictures and movies and have gone from only 8 GB up to 60 GB of storage left.  Under "About this Mac" 97 GB is Photos & 157 GB is "Other." In Finder my iPhoto Library is 218 GB.  What explains this discrepancy?  Somewher

  • Error when calling CLIPBOARD_IMPORT

    hi all, i have the following BDC call and process the return message. It is wokrng fine at foreground. When execute In background, the write statement return only "Error when calling CLIPBOARD_IMPORT". please advise what could be the mistake i have m

  • Question on switch-version and data loss

    Hi, In reading info around the web, I do find and understand that any changes made to configuration of an upgraded CUCM node will be lost if they were made after upgrade but before switch-version.  I was wondering if CDR files/database were also grou