Name |
Ceylon Database Platform Module |
---|---|
Description |
This module offers some components for JDBC-based
database connectivity. The main component is the class
value sql = Sql(newConnectionFromDataSource(dataSource)); You can easily get a query result as a value rows = sql.Select("select * from mytable").execute(); for (row in rows) { assert (is String name = rows["name"]); assert (is Integer count = rows["count"]); ... } You can define parameters to the query, using the value rows = sql.Select("select * from mytable where col1=? and col2=?") .execute(arg1, arg2); The try (results = sql.Select("select * from mytable where date>?") .Results(date)) { results.limit = 50; for (row in results) { ... } } Alternatively, sql.Select("select * from mytable where date>?") .forEachRow(date)((row) { ... }); A value query = sql.Select("select * from mytable where col=?"); value result1 = query.execute(value1); value result2 = query.execute(value2); And of course you can execute sql.Update("update table SET col=? where key=?") .execute(newValue, key); sql.Insert("insert into table (key,col) values (?, ?)") .execute(key, initialValue); If you need to perform several operations within a single
transaction, you can pass a function to the method
sql.transaction { function do() { sql.Insert("insert ... ").execute(); sql.Update("update ... ").execute(); sql.Update("delete ... ").execute(); //return true to commit the transaction //return false or throw to roll it back return true; } }; To pass a null value as an argument, use a sql.Update("update table set col=? where key=?") .execute(SqlNull(Types.integer)); If a column is null on a result row, it will be
represented as a |
Category |
SDK
The Ceylon SDK |
Last Published | Aug 21, 2017 |
Stats |
Downloads (JVM): 7058 Downloads (JS): 0 Source downloads: 7275 |
Module links |
Home Code repository Issue tracker Imported By Browse |
1.3.3 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Aug 21, 2017 |
Browse |
View docs |
|
1.3.2 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Mar 1, 2017 |
Browse |
View docs |
|
1.3.1 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Nov 21, 2016 |
Browse |
View docs |
|
1.3.0 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Sep 15, 2016 |
Browse |
View docs |
|
1.2.2 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Mar 11, 2016 |
Browse |
View docs |
|
1.2.1 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Feb 11, 2016 |
Browse |
View docs |
|
1.2.0 | JVM JVM: 1.2.x, 1.3.x (latest) | Published Oct 28, 2015 |
Browse |
View docs |
|
1.1.0 | JVM JVM: 1.1.0 (outdated) | Published Oct 8, 2014 |
Browse |
View docs |
|
1.0.0 | JVM JVM: 1.0.0 (outdated) | Published Nov 11, 2013 |
Browse |
View docs |
|
0.6.1 | JVM JVM: M6 (outdated) | Published Sep 24, 2013 |
Browse |
View docs |
|
0.6 | JVM JVM: M6 (outdated) | Published Sep 20, 2013 |
Browse |
View docs |
|
0.5 | JVM JVM: M5 (outdated) | Published Mar 14, 2013 |
Browse |
View docs |