src/Pure/General/sql.scala
changeset 65731 393d34045ffb
parent 65730 7ae61e72a678
child 65739 3f206cfca625
equal deleted inserted replaced
65730:7ae61e72a678 65731:393d34045ffb
    44 
    44 
    45   def select(columns: List[Column], distinct: Boolean = false): Source =
    45   def select(columns: List[Column], distinct: Boolean = false): Source =
    46     "SELECT " + (if (distinct) "DISTINCT " else "") + commas(columns.map(_.ident)) + " FROM "
    46     "SELECT " + (if (distinct) "DISTINCT " else "") + commas(columns.map(_.ident)) + " FROM "
    47 
    47 
    48   def join(table1: Table, table2: Table, sql: Source = "", outer: Boolean = false): Source =
    48   def join(table1: Table, table2: Table, sql: Source = "", outer: Boolean = false): Source =
    49     table1.ident + (if (outer) " LEFT OUTER JOIN " else " INNER JOIN ") + table2.ident +
    49     table1 + (if (outer) " LEFT OUTER JOIN " else " INNER JOIN ") + table2 +
    50       (if (sql == "") "" else " ON " + sql)
    50       (if (sql == "") "" else " ON " + sql)
    51 
    51 
    52   def join_outer(table1: Table, table2: Table, sql: Source = ""): Source =
    52   def join_outer(table1: Table, table2: Table, sql: Source = ""): Source =
    53     join(table1, table2, sql, outer = true)
    53     join(table1, table2, sql, outer = true)
    54 
    54 
   316       using_statement(table.create_index(name, columns, strict, unique))(_.execute())
   316       using_statement(table.create_index(name, columns, strict, unique))(_.execute())
   317 
   317 
   318     def create_view(table: Table, strict: Boolean = false): Unit =
   318     def create_view(table: Table, strict: Boolean = false): Unit =
   319     {
   319     {
   320       if (strict || !tables.contains(table.name)) {
   320       if (strict || !tables.contains(table.name)) {
   321         val sql = "CREATE VIEW " + table.ident + " AS " + { table.query; table.body }
   321         val sql = "CREATE VIEW " + table + " AS " + { table.query; table.body }
   322         using_statement(sql)(_.execute())
   322         using_statement(sql)(_.execute())
   323       }
   323       }
   324     }
   324     }
   325   }
   325   }
   326 }
   326 }