diff src/prepare.sml @ 338:e976b187d73a

SQL sequences
author Adam Chlipala <adamc@hcoop.net>
date Sun, 14 Sep 2008 11:02:18 -0400
parents aa89b73d83e4
children 7abb28e9d51f
line wrap: on
line diff
--- a/src/prepare.sml	Sat Sep 13 20:15:30 2008 -0400
+++ b/src/prepare.sml	Sun Sep 14 11:02:18 2008 -0400
@@ -163,6 +163,18 @@
              ((EDml {dml = dml, prepared = SOME (#2 sns)}, loc),
               ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1)))
 
+      | ENextval {seq, ...} =>
+        let
+            val s = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc)
+            val s = (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), s]), loc)
+        in
+            case prepString (s, [], 0) of
+                NONE => (e, sns)
+              | SOME (ss, n) =>
+                ((ENextval {seq = seq, prepared = SOME (#2 sns)}, loc),
+                 ((String.concat (rev ss), n) :: #1 sns, #2 sns + 1))
+        end
+
 fun prepDecl (d as (_, loc), sns) =
     case #1 d of
         DStruct _ => (d, sns)
@@ -193,6 +205,7 @@
         end
 
       | DTable _ => (d, sns)
+      | DSequence _ => (d, sns)
       | DDatabase _ => (d, sns)
       | DPreparedStatements _ => (d, sns)