-
-
Save joaomilho/fcc3901eee540d609f78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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