- $query = "select max(cast( substring_index(barcode, '-',-1) as signed)) from items where barcode like ?";
- my $sth=$dbh->prepare($query);
- $sth->execute("$year%");
- while (my ($count)= $sth->fetchrow_array) {
- warn "Examining Record: $count" if $DEBUG;
- $nextnum = $count if $count;
- }
- $nextnum++;
- $nextnum = sprintf("%0*d", "4",$nextnum);
- $nextnum = "$year-$nextnum";