unwrapped plsql

Solutions on MaxInterview for unwrapped plsql by the best coders in the world

showing results for - "unwrapped plsql"
Erika
07 Mar 2020
1FUNCTION FNC_AMOUNT_INWORDS (P_AMT       IN NUMBER )                                        
2                                                   RETURN VARCHAR2 IS
3    M_MAIN_AMT_TEXT      VARCHAR2(2000) ;
4    M_TOP_AMT_TEXT       VARCHAR2(2000) ;
5    M_BOTTOM_AMT_TEXT    VARCHAR2(2000) ;
6    M_DECIMAL_TEXT       VARCHAR2(2000) ;
7    M_TOP                NUMBER(20,5) ;
8    M_MAIN_AMT           NUMBER(20,5) ;
9    M_TOP_AMT            NUMBER(20,5) ;
10    M_BOTTOM_AMT         NUMBER(20,5) ;
11    M_DECIMAL            NUMBER(20,5) ;
12    M_AMT                NUMBER(20,5);
13    M_TEXT               VARCHAR2(2000) ;
14    BEGIN
15       M_MAIN_AMT        := NULL ;
16       M_TOP_AMT_TEXT    := NULL ;
17       M_BOTTOM_AMT_TEXT := NULL ;
18       M_DECIMAL_TEXT    := NULL ;
19       
20       
21       M_DECIMAL    := P_AMT - TRUNC(P_AMT) ;
22       
23       IF M_DECIMAL >0 THEN
24       M_DECIMAL := M_DECIMAL *100;
25       END IF;
26       
27       M_AMT        := TRUNC(P_AMT) ;          
28     
29     
30       M_TOP        := TRUNC(M_AMT / 100000) ;
31       M_MAIN_AMT   := TRUNC(M_TOP / 100);
32       M_TOP_AMT    := M_TOP - M_MAIN_AMT * 100 ;
33       M_BOTTOM_AMT :=  M_AMT - (M_TOP * 100000) ;
34     
35      IF M_MAIN_AMT > 0 THEN
36          M_MAIN_AMT_TEXT := TO_CHAR(TO_DATE(M_MAIN_AMT,'J'),'JSP') ;
37          IF M_MAIN_AMT = 1 THEN
38            M_MAIN_AMT_TEXT := M_MAIN_AMT_TEXT || ' CRORE ' ;
39          ELSE
40            M_MAIN_AMT_TEXT := M_MAIN_AMT_TEXT || ' CRORES ' ;
41          END IF ;
42       END IF ;
43     
44       IF M_TOP_AMT > 0 THEN
45          M_TOP_AMT_TEXT := TO_CHAR(TO_DATE(M_TOP_AMT,'J'),'JSP') ;
46          IF M_TOP_AMT = 1 THEN
47            M_TOP_AMT_TEXT := M_TOP_AMT_TEXT || ' LAKH ' ;
48          ELSE
49            M_TOP_AMT_TEXT := M_TOP_AMT_TEXT || ' LAKHS ' ;
50          END IF;
51       END IF ;
52       IF M_BOTTOM_AMT > 0 THEN
53          M_BOTTOM_AMT_TEXT := TO_CHAR(TO_DATE(M_BOTTOM_AMT,'J'),'JSP') ;
54       END IF ;
55       IF M_DECIMAL > 0 THEN
56          IF NVL(M_BOTTOM_AMT,0) + NVL(M_TOP_AMT,0) > 0 THEN
57             M_DECIMAL_TEXT := ' AND ' || TO_CHAR(TO_DATE(M_DECIMAL,'J'),'JSP') || ' Paisa ' ;
58          ELSE
59             M_DECIMAL_TEXT :=  TO_CHAR(TO_DATE(M_DECIMAL,'J'),'JSP') ||' Paisa ';
60          END IF ;
61            END IF ;
62       M_TEXT := INITCAP(M_MAIN_AMT_TEXT || M_TOP_AMT_TEXT || M_BOTTOM_AMT_TEXT || ' Taka' || M_DECIMAL_TEXT || ' Only') ;
63       M_TEXT := UPPER(SUBSTR(M_TEXT,1,1))|| SUBSTR(M_TEXT,2);
64       M_TEXT := 'Received with thanks: '|| M_TEXT;
65       RETURN(M_TEXT);
66     
67    END FNC_AMOUNT_INWORDS;
similar questions
queries leading to this page
unwrapped plsql