Last active
August 29, 2015 14:11
-
-
Save yuga/7accb97bb232e6dc0f1f to your computer and use it in GitHub Desktop.
追加しようと思うexample
This file contains 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
account1'' :: Relation () Account1 | |
account1'' = relation $ do | |
a <- query account | |
wheres $ a ! Account.productCd' `in'` values ["CHK", "SAV", "CD", "MM"] | |
return $ Account1 |$| a ! Account.accountId' | |
|*| a ! Account.productCd' | |
|*| a ! Account.custId' | |
|*| a ! Account.availBalance' | |
data Account1 = Account1 | |
{ a1AccountId :: Int64 | |
, a1ProductCd :: String | |
, a1CustId :: Int64 | |
, a1AvailBalance :: Maybe Double | |
} deriving (Show) | |
$(makeRecordPersistableDefault ''Account1) | |
-- | sql/4.3.3b.sh | |
-- | |
-- @ | |
-- SELECT account_id, product_cd, cust_id, avail_balance | |
-- FROM account | |
-- WHERE product_cd IN (SELECT product_cd FROM product | |
-- WHERE product_type_cd = 'ACCOUNT') | |
-- @ | |
productSubQuery :: Relation String String | |
productSubQuery = relation' $ do | |
p <- query product | |
(phProductCd,()) <- placeholder (\ph -> wheres $ p ! Product.productTypeCd' .=. ph) | |
let productCd = p ! Product.productCd' | |
return (phProductCd, productCd) | |
account1b :: Relation String Account | |
account1b = relation' $ do | |
a <- query account | |
(phProductCd,p) <- queryList' productSubQuery | |
wheres $ a ! Account.productCd' `in'` p | |
return (phProductCd, a) | |
account1b' :: Relation String (((Int64, String), Int64), Maybe Double) | |
account1b' = undefined | |
account1b'' :: Relation String Account | |
account1b'' = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment