Ordering result

Use the function order

ord =
  withDB$ \db ->
  do rows <-query db $
            do result <- table H.farms
               order [asc result est]
               return result
     farmsHeader
     mapM_ (putStrLn .showH) rows


Frame> ord
farm_id farm_name size cows chickens est
      1 "Emmerdale" 1002 Just 10 Just 106 1969
      0 "Doebrook" 375 Just 3 Just 15 1969
      4 "PreMillenium Bug" 459 Just 2 Just 50 1982
      3 "Millenium bug" 458 Nothing Just 50 2000


order [*what way* *table* *column*]

You can not end the query with the order function, then this will happen

ord =
  withDB$ \db ->
  do rows <-query db $
            do result <- table H.farms
               order [asc result est]
     farmsHeader
     mapM_ (putStrLn .showH) rows


Bad3> ord
ERROR "Bad3.hs":6 - Undefined variable "farmsHeader"
farm_id farm_name size cows chickens est
      1 "Emmerdale" 1002 Just 10 Just 106 1969
      0 "Doebrook" 375 Just 3 Just 15 1969
      4 "PreMillenium Bug" 459 Just 2 Just 50 1982
      3 "Millenium bug" 458 Nothing Just 50 2000

Here are all words and functions with references, in alphabetical order

Go to main page