I am trying to define a function to work out the checksum digit of an EAN13 barcode.
While trying to compile I get PLS-00215 String length constraints must be in range (1 .. 32767) for the following line:
[code]
| function ean13_with_checkdigit( |
| |
| p_ean13_without_checkdigit in varchar2 |
)
return varchar2
as
| checksum_digit varchar2; |
| ean13 | | varchar2; |
| l_sum | | number; |
| l_multiple | number; |
begin
| for i in 1..12 loop |
| | if mod(i,2) = 0 then |
| | | l_multiple := 3; |
| | else |
| | | l_multiple := 1; |
| | end if; |
| | l_sum := nvl(l_sum, 0) + substr(p_ean13_without_checkdigit, i, 1) * l_multiple; |
| end loop; |
| checksum_digit := TO_CHAR(10 - mod(l_sum, 10), 'FM0'); |
| ean13 := p_ean13_without_checkdigit || checksum_digit; |
| |
| return ean13; |
end;
[/code]
Any help is welcomed