[Ur] Subqueries.

Alexei Golovko m-lj at yandex.ru
Fri Feb 24 04:27:40 EST 2012


Can anyone show me sql subquery usage example? I don't understand which syntax I should use.
I am trying:

$ cat sql.ur
table t : { X : int, Y : int }
table s : { X : int, Y : int, Z : int }
val test = dml (INSERT INTO t (X, Y) VALUES
    ( (SELECT s.X FROM s WHERE s.Z = 1),
    (SELECT s.Y FROM s WHERE s.Z = 1) )
)


$ urweb -tc sql
/tmp/sql.ur:5:5-5:36: Error in final record unification
Can't unify record constructors
Have:  []
Need:  [<UNIF:U54::Name> = <UNIF:U55::Type>]
/tmp/sql.ur:5:5-5:36: Stuck unifying these records after canceling matching pieces:
Have:  []
Need:  [<UNIF:U54::Name> = <UNIF:U55::Type>]
/tmp/sql.ur:5:5-5:36: Error in final record unification
Can't unify record constructors
Have:  [#S = [#Y = Basis.int]]
Need:  []
/tmp/sql.ur:5:5-5:36: Stuck unifying these records after canceling matching pieces:
Have: 
[#S =
  (fn fields :: ({Type} * {Type}) => fields.1)
   ([#Y = Basis.int], ([#Z = Basis.int]) ++ [#X = Basis.int])]
Need:  []
/tmp/sql.ur:4:5-4:36: Error in final record unification
Can't unify record constructors
Have:  []
Need:  [<UNIF:Q::Name> = <UNIF:R::Type>]
/tmp/sql.ur:4:5-4:36: Stuck unifying these records after canceling matching pieces:
Have:  []
Need:  [<UNIF:Q::Name> = <UNIF:R::Type>]
/tmp/sql.ur:4:5-4:36: Error in final record unification
Can't unify record constructors
Have:  [#S = [#X = Basis.int]]
Need:  []
/tmp/sql.ur:4:5-4:36: Stuck unifying these records after canceling matching pieces:
Have: 
[#S =
  (fn fields :: ({Type} * {Type}) => fields.1)
   ([#X = Basis.int], ([#Z = Basis.int]) ++ [#Y = Basis.int])]
Need:  []



More information about the Ur mailing list