now that is thinking outside the box. I like it

Michael Moore wrote:
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to