Home » Developer & Programmer » Forms » pick single value from range (merged 2) (Forms 6i)
pick single value from range (merged 2) [message #548010] Mon, 19 March 2012 09:06 Go to next message
arif_md2009
Messages: 732
Registered: May 2009
Location: United Arab Emirates
Senior Member

i have to pick single value from the given range based on value entered by user, for example if user enter the length 2499 it should be considered as 2000 if he enters 2000 its 2000 or he enters 2501 it will return 2500 , i have written a huge if condition for this purpose in my program which looks very cumbersome,is there a simple to do this other than this method.
the code is as below.

[CODE]
IF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =2000
THEN M_RCVD_LENGTH := 2000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 2001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 2499 THEN
M_RCVD_LENGTH := 2000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 2500
THEN M_RCVD_LENGTH := 2500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 2501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 2999 THEN
M_RCVD_LENGTH := 2500;

ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =3000
THEN M_RCVD_LENGTH := 3000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 3001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 3499 THEN
M_RCVD_LENGTH := 3000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 3500
THEN M_RCVD_LENGTH := 3500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 3501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 3999 THEN
M_RCVD_LENGTH := 3500;


ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =4000
THEN M_RCVD_LENGTH := 4000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 4001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 4499 THEN
M_RCVD_LENGTH := 4000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 4500
THEN M_RCVD_LENGTH := 4500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 4501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 4999 THEN
M_RCVD_LENGTH := 4500;


ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =5000
THEN M_RCVD_LENGTH := 5000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 5001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 5499 THEN
M_RCVD_LENGTH := 5000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 5500
THEN M_RCVD_LENGTH := 5500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 5501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 5999 THEN
M_RCVD_LENGTH := 5500;


ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =6000
THEN M_RCVD_LENGTH := 6000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 6001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6499 THEN
M_RCVD_LENGTH := 6000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6500
THEN M_RCVD_LENGTH := 6500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 6501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6999 THEN
M_RCVD_LENGTH := 6500;


ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =7000
THEN M_RCVD_LENGTH := 7000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 7001 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 7499 THEN
M_RCVD_LENGTH := 7000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 7500
THEN M_RCVD_LENGTH := 7500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) >= 7501 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 7999 THEN
M_RCVD_LENGTH := 7500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 7500 THEN
DISP_ALERT('Setup for Material Cuts is so far not done...');
END IF;


[\CODE]
Re: pick single value from range [message #548013 is a reply to message #548010] Mon, 19 March 2012 09:13 Go to previous messageGo to next message
Michel Cadot
Messages: 59414
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> with data as (select round(dbms_random.value(500,5000)) val from dual connect by level<=20)
  2  select val, 500*round(val/500) new_val 
  3  from data
  4  order by 1
  5  /
       VAL    NEW_VAL
---------- ----------
       702        500
       962       1000
      1051       1000
      1299       1500
      1497       1500
      1590       1500
      1989       2000
      2181       2000
      2271       2500
      2448       2500
      2705       2500
      2952       3000
      3019       3000
      3676       3500
      3926       4000
      3974       4000
      4098       4000
      4337       4500
      4805       5000
      4821       5000

"500*round(val/500)" is the key for what I understand of what you posted.

Regards
Michel
Re: pick single value from range [message #548014 is a reply to message #548013] Mon, 19 March 2012 09:15 Go to previous messageGo to next message
Michel Cadot
Messages: 59414
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Or is it TRUNC?
SQL> l
  1  with data as (select round(dbms_random.value(500,5000)) val from dual connect by level<=20)
  2  select val, 500*trunc(val/500) new_val
  3  from data
  4* order by 1
SQL> /
       VAL    NEW_VAL
---------- ----------
       509        500
       555        500
       785        500
      1006       1000
      1068       1000
      1522       1500
      1631       1500
      1698       1500
      2045       2000
      2182       2000
      2315       2000
      2579       2500
      2835       2500
      2885       2500
      3462       3000
      3633       3500
      3740       3500
      4050       4000
      4157       4000
      4222       4000

Regards
Michel
Re: pick single value from range [message #548016 is a reply to message #548014] Mon, 19 March 2012 09:26 Go to previous messageGo to next message
arif_md2009
Messages: 732
Registered: May 2009
Location: United Arab Emirates
Senior Member

thanks michel but user will be entering single value at one time for example there are two fields in form, one given length and actual length,if he enters the given lenght as any data, it will return one value as out parameter in another field.
he will enter 2499 in csdo_length (given_length) , new field csdo_new_length(actual_length) must be automatically populated as 2000.

Re: pick single value from range [message #548018 is a reply to message #548016] Mon, 19 March 2012 09:41 Go to previous messageGo to next message
cookiemonster
Messages: 11072
Registered: September 2008
Location: Rainy Manchester
Senior Member
And what's stopping you from using trunc or round from Michel's examples?
He's just outputing multiple values to show you what it does.
easy function [message #548804 is a reply to message #548010] Mon, 26 March 2012 06:32 Go to previous messageGo to next message
arif_md2009
Messages: 732
Registered: May 2009
Location: United Arab Emirates
Senior Member

i have a function which returns the value based on value given and there is a range based on which i am returning this value and i need to write this entire code for this purpose , is there a easy way to limit this coding.

[CODE]
FUNCTION L_GET_S_LEN (P_GIVEN_LEN NUMBER) RETURN NUMBER IS
M_RCVD_LENGTH OT_CUTTING_SHEET_DETAIL_OC.CSDO_STORE_RECD_LENGTH%TYPE;
BEGIN

IF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =2000
THEN M_RCVD_LENGTH := 2000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 2001 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 2499 THEN
M_RCVD_LENGTH := 2000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 2500
THEN M_RCVD_LENGTH := 2500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 2501 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 2999 THEN
M_RCVD_LENGTH := 2500;

ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =3000
THEN M_RCVD_LENGTH := 3000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 3001 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 3499 THEN
M_RCVD_LENGTH := 3000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 3500
THEN M_RCVD_LENGTH := 3500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 3501 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 3999 THEN
M_RCVD_LENGTH := 3500;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =4000
THEN M_RCVD_LENGTH := 4000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 4001 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 4499 THEN
M_RCVD_LENGTH := 4000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 4500
THEN M_RCVD_LENGTH := 4500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 4501 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 4999 THEN
M_RCVD_LENGTH := 4500;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =5000
THEN M_RCVD_LENGTH := 5000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 5001 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 5499 THEN
M_RCVD_LENGTH := 5000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 5500
THEN M_RCVD_LENGTH := 5500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) >= 5501 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 5999 THEN
M_RCVD_LENGTH := 5500;


ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6000
THEN M_RCVD_LENGTH := 6000;
ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6000 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6099 THEN
M_RCVD_LENGTH := 6000;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6100
THEN M_RCVD_LENGTH := 6100;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6100 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6199 THEN
M_RCVD_LENGTH := 6100;



ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =6200
THEN M_RCVD_LENGTH := 6200;

ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6200 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6299 THEN
M_RCVD_LENGTH := 6200;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6300
THEN M_RCVD_LENGTH := 6300;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6300 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6399 THEN
M_RCVD_LENGTH := 6300;


ELSIF ( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) =6400
THEN M_RCVD_LENGTH := 6400;

ELSIF
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6400 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6499 THEN
M_RCVD_LENGTH := 6400;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6500
THEN M_RCVD_LENGTH := 6500;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6500 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6599 THEN
M_RCVD_LENGTH := 6500;



ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6600
THEN M_RCVD_LENGTH := 6600;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6600 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6699 THEN
M_RCVD_LENGTH := 6600;


ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6700
THEN M_RCVD_LENGTH := 6700;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6700 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6799 THEN
M_RCVD_LENGTH := 6700;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) = 6800
THEN M_RCVD_LENGTH := 6800;

ELSIF (:CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) > 6800 AND
( :CSDO_STORE_RECD_LENGTH - SUBSTR(:CSDO_STORE_RECD_LENGTH,(LENGTH(:CSDO_STORE_RECD_LENGTH)-1),LENGTH(:CSDO_STORE_RECD_LENGTH))) <= 6899 THEN
M_RCVD_LENGTH := 6800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 6900
THEN M_RCVD_LENGTH := 6900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 6900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 6999 THEN
M_RCVD_LENGTH := 6900;




ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7000
THEN M_RCVD_LENGTH := 7000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7000 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7099 THEN
M_RCVD_LENGTH := 7000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7100
THEN M_RCVD_LENGTH := 7100;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7100 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7199 THEN
M_RCVD_LENGTH := 7100;



ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =7200
THEN M_RCVD_LENGTH := 7200;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7200 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7299 THEN
M_RCVD_LENGTH := 7200;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7300
THEN M_RCVD_LENGTH := 7300;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7300 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7399 THEN
M_RCVD_LENGTH := 7300;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =7400
THEN M_RCVD_LENGTH := 7400;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7400 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7499 THEN
M_RCVD_LENGTH := 7400;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7500
THEN M_RCVD_LENGTH := 7500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7500 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7599 THEN
M_RCVD_LENGTH := 7500;



ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7600
THEN M_RCVD_LENGTH := 7600;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7600 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7699 THEN
M_RCVD_LENGTH := 7600;


ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7700
THEN M_RCVD_LENGTH := 7700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7700 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7799 THEN
M_RCVD_LENGTH := 7700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7800
THEN M_RCVD_LENGTH := 7800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7800 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7899 THEN
M_RCVD_LENGTH := 7800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 7900
THEN M_RCVD_LENGTH := 7900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 7900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 7999 THEN
M_RCVD_LENGTH := 7900;






ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8000
THEN M_RCVD_LENGTH := 8000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8000 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8099 THEN
M_RCVD_LENGTH := 8000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8100
THEN M_RCVD_LENGTH := 8100;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8100 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8199 THEN
M_RCVD_LENGTH := 8100;



ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =8200
THEN M_RCVD_LENGTH := 8200;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8200 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8299 THEN
M_RCVD_LENGTH := 8200;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8300
THEN M_RCVD_LENGTH := 8300;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8300 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8399 THEN
M_RCVD_LENGTH := 8300;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =8400
THEN M_RCVD_LENGTH := 8400;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8400 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8499 THEN
M_RCVD_LENGTH := 8400;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8500
THEN M_RCVD_LENGTH := 8500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8500 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8599 THEN
M_RCVD_LENGTH := 8500;



ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8600
THEN M_RCVD_LENGTH := 8600;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8600 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8699 THEN
M_RCVD_LENGTH := 8600;


ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8700
THEN M_RCVD_LENGTH := 8700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8700 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8799 THEN
M_RCVD_LENGTH := 8700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8800
THEN M_RCVD_LENGTH := 8800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8800 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8899 THEN
M_RCVD_LENGTH := 8800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 8900
THEN M_RCVD_LENGTH := 8900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 8900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 8999 THEN
M_RCVD_LENGTH := 8900;





ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9000
THEN M_RCVD_LENGTH := 9000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9000 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9099 THEN
M_RCVD_LENGTH := 9000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9100
THEN M_RCVD_LENGTH := 9100;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9100 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9199 THEN
M_RCVD_LENGTH := 9100;



ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =9200
THEN M_RCVD_LENGTH := 9200;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9200 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9299 THEN
M_RCVD_LENGTH := 9200;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9300
THEN M_RCVD_LENGTH := 9300;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9300 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9399 THEN
M_RCVD_LENGTH := 9300;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =9400
THEN M_RCVD_LENGTH := 9400;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9400 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9499 THEN
M_RCVD_LENGTH := 9400;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9500
THEN M_RCVD_LENGTH := 9500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9500 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9599 THEN
M_RCVD_LENGTH := 9500;



ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9600
THEN M_RCVD_LENGTH := 9600;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9600 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9699 THEN
M_RCVD_LENGTH := 9600;


ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9700
THEN M_RCVD_LENGTH := 9700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9700 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9799 THEN
M_RCVD_LENGTH := 9700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9800
THEN M_RCVD_LENGTH := 9800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9800 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9899 THEN
M_RCVD_LENGTH := 9800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 9900
THEN M_RCVD_LENGTH := 9900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 9900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 9999 THEN
M_RCVD_LENGTH := 9900;






ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10000
THEN M_RCVD_LENGTH := 10000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10000 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10099 THEN
M_RCVD_LENGTH := 10000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10100
THEN M_RCVD_LENGTH := 10100;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10100 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10199 THEN
M_RCVD_LENGTH := 10100;



ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =10200
THEN M_RCVD_LENGTH := 10200;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10200 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10299 THEN
M_RCVD_LENGTH := 10200;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10300
THEN M_RCVD_LENGTH := 10300;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10300 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10399 THEN
M_RCVD_LENGTH := 10300;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =10400
THEN M_RCVD_LENGTH := 10400;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10400 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10499 THEN
M_RCVD_LENGTH := 10400;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10500
THEN M_RCVD_LENGTH := 10500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10500 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10599 THEN
M_RCVD_LENGTH := 10500;



ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10600
THEN M_RCVD_LENGTH := 10600;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10600 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10699 THEN
M_RCVD_LENGTH := 10600;


ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10700
THEN M_RCVD_LENGTH := 10700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10700 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10799 THEN
M_RCVD_LENGTH := 10700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10800
THEN M_RCVD_LENGTH := 10800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10800 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10899 THEN
M_RCVD_LENGTH := 10800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 10900
THEN M_RCVD_LENGTH := 10900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 10900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 10999 THEN
M_RCVD_LENGTH := 10900;







ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11000
THEN M_RCVD_LENGTH := 11000;
ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11000 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11099 THEN
M_RCVD_LENGTH := 11000;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11100
THEN M_RCVD_LENGTH := 11100;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11100 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11199 THEN
M_RCVD_LENGTH := 11100;



ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =11200
THEN M_RCVD_LENGTH := 11200;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11200 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11299 THEN
M_RCVD_LENGTH := 11200;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11300
THEN M_RCVD_LENGTH := 11300;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11300 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11399 THEN
M_RCVD_LENGTH := 11300;


ELSIF ( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) =11400
THEN M_RCVD_LENGTH := 11400;

ELSIF
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11400 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11499 THEN
M_RCVD_LENGTH := 11400;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11500
THEN M_RCVD_LENGTH := 11500;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11500 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11599 THEN
M_RCVD_LENGTH := 11500;



ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11600
THEN M_RCVD_LENGTH := 11600;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11600 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11699 THEN
M_RCVD_LENGTH := 11600;


ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11700
THEN M_RCVD_LENGTH := 11700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11700 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11799 THEN
M_RCVD_LENGTH := 11700;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11800
THEN M_RCVD_LENGTH := 11800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11800 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11899 THEN
M_RCVD_LENGTH := 11800;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 11900
THEN M_RCVD_LENGTH := 11900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) > 11900 AND
( P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) <= 11999 THEN
M_RCVD_LENGTH := 11900;

ELSIF (P_GIVEN_LEN - SUBSTR(P_GIVEN_LEN,(LENGTH(P_GIVEN_LEN)-1),LENGTH(P_GIVEN_LEN))) = 12000
THEN M_RCVD_LENGTH := 12000;

END IF;

RETURN(M_RCVD_LENGTH);

END;

[CODE\]
Re: easy function [message #548826 is a reply to message #548804] Mon, 26 March 2012 08:57 Go to previous messageGo to next message
John Watson
Messages: 4677
Registered: January 2010
Location: Global Village
Senior Member
Your code looks absurd, you are treating numbers and ranges of number individually. Surely all you need to do is round off the value to within 500? A function that implements this one SELECT should do for any value:
orcl> select round(&n/500)*500 from dual;
Enter value for n: 2000
old   1: select round(&n/500)*500 from dual
new   1: select round(2000/500)*500 from dual

ROUND(2000/500)*500
-------------------
               2000

orcl> /
Enter value for n: 2300
old   1: select round(&n/500)*500 from dual
new   1: select round(2300/500)*500 from dual

ROUND(2300/500)*500
-------------------
               2500

orcl> /
Enter value for n: 2999
old   1: select round(&n/500)*500 from dual
new   1: select round(2999/500)*500 from dual

ROUND(2999/500)*500
-------------------
               3000

orcl>
Re: easy function [message #548877 is a reply to message #548826] Mon, 26 March 2012 16:56 Go to previous messageGo to next message
cookiemonster
Messages: 11072
Registered: September 2008
Location: Rainy Manchester
Senior Member
Michel showed you how to do this a week ago.
Do not create a new topic for the same question (I've now merged the two).
If you don't understand how to apply what we show you, ask.
Do not ignore what we tell you, that's just rude.

And learn to use code tags properly, it's not difficult.
Re: easy function [message #548898 is a reply to message #548877] Tue, 27 March 2012 00:39 Go to previous messageGo to next message
arif_md2009
Messages: 732
Registered: May 2009
Location: United Arab Emirates
Senior Member

Thanks cookiemonster, i am really sorry for not replying back , yeah michel did reply but i need an example of implementing that sql inside my form .
Re: easy function [message #548922 is a reply to message #548898] Tue, 27 March 2012 03:34 Go to previous message
cookiemonster
Messages: 11072
Registered: September 2008
Location: Rainy Manchester
Senior Member
It didn't occur to you to try this?
M_RCVD_LENGTH := 500*round(P_GIVEN_LEN/500)

Seems pretty obvious.
Previous Topic: sending email from forms with report in pdf as an attachment
Next Topic: How to call a java function from Oracle forms?
Goto Forum:
  


Current Time: Wed Oct 22 07:43:35 CDT 2014

Total time taken to generate the page: 0.15585 seconds