Skip to content

Instantly share code, notes, and snippets.

@softa
Created June 4, 2010 15:28
Show Gist options
  • Save softa/425546 to your computer and use it in GitHub Desktop.
Save softa/425546 to your computer and use it in GitHub Desktop.
-- relational.hs
import Database.HDBC
import Database.HDBC.PostgreSQL
import Data.List
printTuples conn rel = quickQuery' conn ("SELECT DISTINCT * FROM " ++ rel) []
(⋈) = intercalate " NATURAL JOIN "
(π) fields rel1 = "(SELECT " ++ (intercalate "," fields) ++ " FROM " ++ rel1 ++ ") a"
-- no gchi
:m Database.HDBC Database.HDBC.PostgreSQL
:l relational.hs
let teste = π ["empno", "ename", "dname"] $ (⋈) ["emp", "dept"]
conn <- connectPostgreSQL "host=localhost dbname=hdbtest user=hdbtest"
printTuples conn teste
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment