Use Below Function for Checksum
Consider Account_number = 12345
O/p : 1+12+123+1234+12345 = 13715
CREATE OR REPLACE FUNCTION APPS.ACC_CHECK_SUM (ACCOUNT_NUMBER NUMBER)
RETURN NUMBER
IS
l_chk_sum NUMBER DEFAULT 0;
l_acc_num NUMBER DEFAULT 0;
l_var NUMBER :=0;
BEGIN
--SELECT LENGTH(ACCOUNT_NUMBER) INTO l_acc_num FROM DUAL;
l_var := ACCOUNT_NUMBER;
l_chk_sum := ACCOUNT_NUMBER;
FOR i IN 1.. LENGTH(ACCOUNT_NUMBER)
LOOP
BEGIN
l_var := FLOOR(l_var / 10);
l_chk_sum := (l_chk_sum + l_var);
END;
END LOOP;
RETURN (l_chk_sum);
END;
SELECT ACC_CHECK_SUM(12345) FROM DUAL
O/p : = 13715
Consider Account_number = 12345
O/p : 1+12+123+1234+12345 = 13715
CREATE OR REPLACE FUNCTION APPS.ACC_CHECK_SUM (ACCOUNT_NUMBER NUMBER)
RETURN NUMBER
IS
l_chk_sum NUMBER DEFAULT 0;
l_acc_num NUMBER DEFAULT 0;
l_var NUMBER :=0;
BEGIN
--SELECT LENGTH(ACCOUNT_NUMBER) INTO l_acc_num FROM DUAL;
l_var := ACCOUNT_NUMBER;
l_chk_sum := ACCOUNT_NUMBER;
FOR i IN 1.. LENGTH(ACCOUNT_NUMBER)
LOOP
BEGIN
l_var := FLOOR(l_var / 10);
l_chk_sum := (l_chk_sum + l_var);
END;
END LOOP;
RETURN (l_chk_sum);
END;
SELECT ACC_CHECK_SUM(12345) FROM DUAL
O/p : = 13715
No comments:
Post a Comment