Thu, 21 Aug 2003 18:43:55 +1000
Tom Pledger wrote:
> How about introducing a Cursor abstract data type?
> doquery :: Process -> String -> b -> (Cursor -> b -> IO (b,
> -> IO b
> stringv :: Cursor -> CInt -> IO String
> doublev :: Cursor -> CInt -> IO Double
> intv :: Cursor -> CInt -> IO Int
> This achieves the restriction you're after, because doquery is the
> only exported producer of Cursor, and stringv etc. are the only
> exported consumers of Cursor.
I like this. Not sure about whether I'd call it Cursor or just Row. Code
results <- doquery dbconn sqltext  \row results -> do
name <- colv row 1
address <- colv row 2
seems quite tidy.
> It also has the benefit that the function you pass to doquery can
> other calls to doquery, without mucking up the 'current row' state.
> There would be one current row per Cursor, not one per Process.
Is it normal or common to support multiple simultaneous queries on
a single DB connection?