[Ur] SQL Question

Burton Samograd burton.samograd at gmail.com
Thu Oct 2 23:54:17 EDT 2014


Hi,

Another probably basic question where I'm not getting the type system.

I have the following table:

table posts : { Id : int, Title : string, Body, :string : Author, string,
Created : time }
          PRIMARY KEY Id

and I'm trying to compile the following code:

...
 and posts' () : xbody =
     posts' <- queryX (SELECT * FROM posts)
              (fn row => post' {[row.Posts.Title]} {[row.Posts.Body]}
{[row.Posts.Author]} {[row.Posts.Created]});
     <xml><div class="postsList">
       {posts'}
     </div></xml>

and post' (title:string) (body:string) (authorUserId:int) (date:string) :
xbody =
    let
        val numComments = 0
    in
        <xml><div class="post">
        <div class="postTitle">{[title]}</div>
        <div class="postAuthor">{[authorUserId]}</div>
        <div class="postBody">{[body]}</div>
    <div class="postBottom">
            <div class="postComments">
            <a link={comments ()}>{[numComments]} comments</a>
        </div>
            <div class="postDate">{[date]}</div>
    </div>
        </div></xml>
    end

this is giving me the following compile errors:

/root/typedweb/blog.ur:39:20: (to 39:25) syntax error: replacing  SYMBOL
with  SQL
/root/typedweb/blog.ur:39:28: (to 39:37) This is an expression but not a
pattern.
/root/typedweb/blog.ur:39:46: (to 39:46) syntax error: inserting  EQ
/root/typedweb/blog.ur:39:48: (to 39:57) This is an expression but not a
pattern.
/root/typedweb/blog.ur:39:28: (to 39:37) This is an expression but not a
pattern.
/root/typedweb/blog.ur:39:65: (to 39:65) syntax error: inserting  PLUS
/root/typedweb/blog.ur:39:67: (to 39:76) This is an expression but not a
pattern.
/root/typedweb/blog.ur:39:48: (to 39:57) This is an expression but not a
pattern.
/root/typedweb/blog.ur:39:86: (to 39:86) syntax error: inserting  PLUS

I'm trying to use the same syntax as the urblog tutorial but it's calling a
post generation function but I'm still not getting it to compile properly.
Can SQL only be used in a transaction?

--
Burton Samograd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20141002/e4c8d868/attachment.html>


More information about the Ur mailing list