DECLARE mystr VARCHAR2 (1000) := '00AF 00F3 0019'; mychar CHAR (1); total NUMBER (10) := 0; BEGIN FOR i IN 1 .. LENGTH (mystr) LOOP mychar := SUBSTR (mystr, i, 1);
CASE mychar WHEN '1' THEN total := total + 1; WHEN '2' THEN total := total + 1; WHEN '3' THEN total := total + 2; WHEN '4' THEN total := total + 1; WHEN '5' THEN total := total + 2; WHEN '6' THEN total := total + 2; WHEN '7' THEN total := total + 3; WHEN '8' THEN total := total + 1; WHEN '9' THEN total := total + 2; WHEN 'A' THEN total := total + 2; WHEN 'B' THEN total := total + 3; WHEN 'C' THEN total := total + 2; WHEN 'D' THEN total := total + 3; WHEN 'E' THEN total := total + 3; WHEN 'F' THEN total := total + 4; ELSE NULL; END CASE; END LOOP; dbms_output.put_line(to_char(total)); END; --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Oracle PL/SQL" group. To post to this group, send email to Oracle-PLSQL@googlegroups.com To unsubscribe from this group, send email to oracle-plsql-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Oracle-PLSQL?hl=en -~----------~----~----~----~------~----~------~--~---