You can use the :. operator to separate different types.  You can string them together for as long as you want.  WIth ScopedTypeVariables extension enabled you can type them in an anon function like so.

forM_ res $ \((Only (x :: Int)) :. (Only (y :: Int)) ) -> do
    print (show x) ++ (show y)

You can also create your own 11+ item datatype and create a fromRow instance for it, which would serve the same purpose.



On Mon, Dec 23, 2013 at 7:37 PM, Miro Karpis <miroslav.karpis@gmail.com> wrote:
Hi, please ... I need help with following:

I have a table with 11 columns. I would like to create a query where in return I should get values of all columns. Problem is that when I try with 10 elements everything works OK. With 11 I will get compile error.

I found in the Database.SQLite.Simple documentation following:
A collection type that can be converted from a sequence of fields. Instances are provided for tuples up to 10 elements and lists of any length.

So is it possible to select more than 10 columns in one query? It must be right?


working code:
-------------------------
queryX :: Query
queryX = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10 FROM tableX" 

saveBtceTickerData :: IO ()
saveBtceTickerData = do
    conn <- open "../mydb.sqlite"
    r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double, Double, Double, Double, Double, Double)]
    mapM_ print r
    close conn
    putStrLn "done"


non-working code:
-------------------------
someQuery :: Query
someQuery = "SELECT el1, el2, el3, el4, el5, el6, el7, el8, el9, el10, el11 FROM tableX" 

saveBtceTickerData :: IO ()
saveBtceTickerData = do
    conn <- open "../mydb.sqlite"
    r <- query_ conn queryX :: IO [(Double, Int, Double, Double, Double, Double, Double, Double, Double, Double, Double)]
    mapM_ print r
    close conn
    putStrLn "done"

------
Error output:

No instance for (FromRow

                       (Double,

                        Int,

                        Double,

                        Double,

                        Double,

                        Double,

                        Double,

                        Double,

                        Double,

                        Double,

                        Double))

      arising from a use of `query_'

    Possible fix:

      add an instance declaration for

      (FromRow

         (Double,

          Int,

          Double,

          Double,

          Double,

          Double,

          Double,

          Double,

          Double,

          Double,

          Double))



thanks,
m.



_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners