Section 14 in Foundation > module Language.SQL.SimpleSQL.SQL2011DataManipulation (sql2011DataManipulationTests) where > import Language.SQL.SimpleSQL.TestTypes > import Language.SQL.SimpleSQL.Syntax > sql2011DataManipulationTests :: TestItem > sql2011DataManipulationTests = Group "sql 2011 data manipulation tests" > [ 14 Data manipulation 14.1 ::= DECLARE FOR 14.2 ::= [ ] [ ] CURSOR [ ] [ ] ::= SENSITIVE | INSENSITIVE | ASENSITIVE ::= SCROLL | NO SCROLL ::= WITH HOLD | WITHOUT HOLD ::= WITH RETURN | WITHOUT RETURN 14.3 ::= [ ] ::= FOR { READ ONLY | UPDATE [ OF ] } 14.4 ::= OPEN 14.5 ::= FETCH [ [ ] FROM ] INTO ::= NEXT | PRIOR | FIRST | LAST | { ABSOLUTE | RELATIVE } ::= [ { }... ] 14.6 ::= CLOSE 14.7 ::= SELECT [ ]
| ONLY
14.9 ::= DELETE FROM [ FOR PORTION OF FROM TO ] [ [ AS ] ] [ WHERE ] > (TestStatement SQL2011 "delete from t" > $ Delete [Name "t"] Nothing Nothing) > ,(TestStatement SQL2011 "delete from t as u" > $ Delete [Name "t"] (Just (Name "u")) Nothing) > ,(TestStatement SQL2011 "delete from t where x = 5" > $ Delete [Name "t"] Nothing > (Just $ BinOp (Iden [Name "x"]) [Name "="] (NumLit "5"))) > ,(TestStatement SQL2011 "delete from t as u where u.x = 5" > $ Delete [Name "t"] (Just (Name "u")) > (Just $ BinOp (Iden [Name "u", Name "x"]) [Name "="] (NumLit "5"))) 14.10 ::= TRUNCATE TABLE [ ] ::= CONTINUE IDENTITY | RESTART IDENTITY > ,(TestStatement SQL2011 "truncate table t" > $ Truncate [Name "t"] DefaultIdentityRestart) > ,(TestStatement SQL2011 "truncate table t continue identity" > $ Truncate [Name "t"] ContinueIdentity) > ,(TestStatement SQL2011 "truncate table t restart identity" > $ Truncate [Name "t"] RestartIdentity) 14.11 ::= INSERT INTO ::=
::= | | ::= [ ] [ ] ::= [ ] [ ] ::= OVERRIDING USER VALUE | OVERRIDING SYSTEM VALUE ::= DEFAULT VALUES ::= > ,(TestStatement SQL2011 "insert into t select * from u" > $ Insert [Name "t"] Nothing > $ InsertQuery makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "u"]]}) > ,(TestStatement SQL2011 "insert into t(a,b,c) select * from u" > $ Insert [Name "t"] (Just [Name "a", Name "b", Name "c"]) > $ InsertQuery makeSelect > {qeSelectList = [(Star, Nothing)] > ,qeFrom = [TRSimple [Name "u"]]}) > ,(TestStatement SQL2011 "insert into t default values" > $ Insert [Name "t"] Nothing DefaultInsertValues) > ,(TestStatement SQL2011 "insert into t values(1,2)" > $ Insert [Name "t"] Nothing > $ InsertQuery $ Values [[NumLit "1", NumLit "2"]]) > ,(TestStatement SQL2011 "insert into t values (1,2),(3,4)" > $ Insert [Name "t"] Nothing > $ InsertQuery $ Values [[NumLit "1", NumLit "2"] > ,[NumLit "3", NumLit "4"]]) > ,(TestStatement SQL2011 > "insert into t values (default,null,array[],multiset[])" > $ Insert [Name "t"] Nothing > $ InsertQuery $ Values [[Iden [Name "default"] > ,Iden [Name "null"] > ,Array (Iden [Name "array"]) [] > ,MultisetCtor []]]) 14.12 ::= MERGE INTO [ [ AS ] ] USING
ON ::= ::= ... ::= | ::= WHEN MATCHED [ AND ] THEN ::= | ::= WHEN NOT MATCHED [ AND ] THEN ::= UPDATE SET ::= DELETE ::= INSERT [ ] [ ] VALUES ::= [ { }... ] ::= | 14.13 ::= UPDATE [ [ AS ] ] SET WHERE CURRENT OF 14.14 ::= UPDATE [ FOR PORTION OF FROM TO ] [ [ AS ] ] SET [ WHERE ] > ,(TestStatement SQL2011 "update t set a=b" > $ Update [Name "t"] Nothing > [Set [Name "a"] (Iden [Name "b"])] Nothing) > ,(TestStatement SQL2011 "update t set a=b, c=5" > $ Update [Name "t"] Nothing > [Set [Name "a"] (Iden [Name "b"]) > ,Set [Name "c"] (NumLit "5")] Nothing) > ,(TestStatement SQL2011 "update t set a=b where a>5" > $ Update [Name "t"] Nothing > [Set [Name "a"] (Iden [Name "b"])] > $ Just $ BinOp (Iden [Name "a"]) [Name ">"] (NumLit "5")) > ,(TestStatement SQL2011 "update t as u set a=b where u.a>5" > $ Update [Name "t"] (Just $ Name "u") > [Set [Name "a"] (Iden [Name "b"])] > $ Just $ BinOp (Iden [Name "u",Name "a"]) > [Name ">"] (NumLit "5")) > ,(TestStatement SQL2011 "update t set (a,b)=(3,5)" > $ Update [Name "t"] Nothing > [SetMultiple [[Name "a"],[Name "b"]] > [NumLit "3", NumLit "5"]] Nothing) 14.15 ::= [ { }... ] ::= | ::= | ::= ::= [ { }... ] ::= ::= | ::= ::= ::= | ::= | 14.16 ::= DECLARE LOCAL TEMPORARY TABLE
[ ON COMMIT
ROWS ] 14.17 ::= FREE LOCATOR [ { }... ] ::= | | 14.18 ::= HOLD LOCATOR [ { }... ] > ]