Hi Monks,
I have a simple SQLite database. I read the content of the table and print it out (in a TK table). When printing it out, I need to sort the entries in an alphabetical order. Easy for English, but I have a small set of non-ASCII characters, such as german ä/ü/ö. I came up with:
order by column collate NOCASE
Result (orderd): a g x ä
Right order: a ä g x
My script:
$dbh = DBI->connect( "dbi:SQLite:files/database/data.db" ) || die "Can +not connect: $DBI::errstr"; $selected = $dbh->selectall_arrayref("SELECT ID,column1,column2 FROM +table order by column1 collate NOCASE"); foreach my $row_db (@$selected ) { my ($ID, $column1, $column2) = @$row_db; print "$column1\n"; }
One day of manuals and goole gave me no clue! (Mea culpa)!
I am not familiar with creating new collate in perl. Unfortunatelly I didn't find any example out there. I thought even about the posibility to substitute ä->a before performing SELECT. Or... maybe doing the sorting in perl at the stage of 'foreach' (@$selected), maybe not the best solution, but probably the easiest one.
Can any of you suggest a - possible easy - way to solve the problem?
THANXS Cla
In reply to SQLite (DBD) Sorting by fanticla
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |