<div dir="ltr"><div><div><div><div><div><div>Are you limited to one query per transaction? This type of code causes compiler errors where a single query doesn't:<br><br></div><div>fun page () : transaction xbody =<br></div><div><br></div>data <- (SELECT * FROM table ...) (fn row => ...)<br>data2 <- (SELECT * FROM table2 ...) (fn row => ...)<br><br></div>(* Generate part of the page with data *)<br></div>{header data}<br><br></div>(* Generate another section with data2 *)<br></div>{footer data2}<br><br>--<br></div>Burton<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 6:56 AM, mutaamba maasha <span dir="ltr"><<a href="mailto:maasha@gmail.com" target="_blank">maasha@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(* Hi<br>
Yes, occur within transactions, let me know if you want me to go into<br>
more detail into why. I can't place the error as I can't determine<br>
the line numbers so I have included the code below which should help<br>
you track down your problem. Hope this helps.<br>
<br>
happy hacking<br>
<br>
*)<br>
style postsList<br>
style post<br>
style postTitle<br>
style postAuthor<br>
style postBody<br>
style postBottom<br>
style postComments<br>
style postDate<br>
<br>
(* there is a typo starting around "Body, :string" *)<br>
table posts : { Id : int, Title : string, Body : string, Author :<br>
<span class="">string, Created : time }<br>
PRIMARY KEY Id<br>
<br>
</span>(* Renamed the function more of a personal preference.<br>
The query has to be in a transaction which is what<br>
I think you were asking.<br>
*)<br>
fun list_posts () : transaction xbody =<br>
(* changed the variable name ... personal prefrence *)<br>
content <- queryX (SELECT * FROM posts)<br>
(* changed the function name ... personal<br>
preference *)<br>
(fn row => format_post row.Posts.Title (*<br>
removed the {[]} as it is used in queries or xml *)<br>
row.Posts.Body<br>
row.Posts.Author<br>
row.Posts.Created);<br>
return <xml><div class="postsList"><br>
{content}<br>
</div></xml><br>
<br>
<br>
(* changed the function name ... personal preference *)<br>
and format_post<br>
(title : string)<br>
(body : string)<br>
(authorUserId : string)<br>
(created : time) (* changed name but also the type is time *)<br>
<span class=""> : xbody =<br>
let<br>
val numComments = 0<br>
in<br>
<xml><br>
<div class="post"><br>
<div class="postTitle">{[title]}</div><br>
<div class="postAuthor">{[authorUserId]}</div><br>
<div class="postBody">{[body]}</div><br>
<div class="postBottom"><br>
<div class="postComments"><br>
<a link={comments ()}>{[numComments]} comments</a><br>
</div><br>
</span> <div class="postDate">{[created]}</div><br>
</div><br>
</div><br>
</xml><br>
end<br>
(* Using error instead of supplying the implementation of the comment<br>
function ... compiles but will throw an runtime error if you try to<br>
view the page. I use this often when I am trying to isolate an<br>
compilation error ... I comment out the function definition and<br>
replace it with error <xml>some insightful error message</xml> *)<br>
and comments () : transaction page = error <xml>error : comment<br>
function not implemented</xml><br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" target="_blank">http://www.impredicative.com/cgi-bin/mailman/listinfo/ur</a><br>
</div></div></blockquote></div><br></div>