Hi,

I wrote a CGI program to access a Postgres database using HDBC. The database stores books and I want to display those from a certain author. Everything works fine, unless I search for someone with an umlaut in his name. Böll, for example. I have a function like this

> bookByAuthor :: Connection -> AutorName -> IO [[String]]
> bookByAuthor c aName = do
>    writeFile "./err.log" ((show aName)++" "++(show $ toSql aName))
> rows <- quickQuery c "SELECT * FROM buecher WHERE lower (autor_name) LIKE ? ORDER BY autor_name, buch_name" [toSql $ map toLower $ '%':aName++"%"]
>    return $ map (map fromSql) rows

It returns me a SqlError. However, doing the same in ghci works perfectly. I can't understand why. err.log contains

> "b\195\182ll" SqlString "b\195\182ll"

which is ok I think. Since

> quickQuery c "SELECT * FROM buecher WHERE lower(autor_name) LIKE ? ORDER BY autor_name, buch_name" [toSql "%b\195\182%"]

works in ghci. I have tried "b\246ll", but that doesn't even work in ghci, although the database-encoding is utf-8. This all is really annoying...

Adrian

Attachment: PGP.sig
Description: Signierter Teil der Nachricht

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to