Example with SQL placed in code

23 views
Skip to first unread message

Eduardo M. Cavalcanti

unread,
May 12, 2011, 4:25:02 PM5/12/11
to orbroker
Hi,
Is it possible to show or point out an example of issuing a query with
orbroker having the SQL placed inside the code?
Thank you

Nils Kilden-Pedersen

unread,
May 12, 2011, 4:29:18 PM5/12/11
to orbr...@googlegroups.com

Nils Kilden-Pedersen

unread,
May 12, 2011, 4:31:49 PM5/12/11
to orbr...@googlegroups.com
Or, if you need apply an extractor, use Token like this:

val token = Token("SELECT * FROM TABLE", 'id, Extractor, "foo"->bar)

Eduardo M. Cavalcanti

unread,
May 27, 2011, 7:19:10 PM5/27/11
to orbr...@googlegroups.com
Hi,
Is it possible to show or point out an example of issuing a transaction
with Orbroker?
Thank you

Nicholas Ustinov

unread,
May 28, 2011, 6:29:47 AM5/28/11
to orbr...@googlegroups.com
Hello.
Well, simple example you can find here:
http://code.google.com/p/orbroker/wiki/GeneratedKeys
i speak about last code block:
...
val savedItem = broker.transaction() { txn =>
val newId = txn.executeForKey(InsertItem, "item"->newItem)
item.copy(id = newId)
}

all calls in transaction(){ } block are executed in single
transaction, which is commited by default or rollbacked if any
exceptions arised.

also smth interesting you can find in tests, e.g. here:
http://code.google.com/p/orbroker/source/browse/src/test/scala/test/orbroker/example/TestBroker.scala?name=3.2
especially with "transactional" blocks, where you can commit/rollback explicitly


Nicholas

2011/5/28 Eduardo M. Cavalcanti <eduardo.c...@eversystems.com.br>:

Nils

unread,
Jun 28, 2011, 9:00:16 AM6/28/11
to orbr...@googlegroups.com
On Thursday, May 12, 2011 3:31:49 PM UTC-5, Nils wrote:
Or, if you need apply an extractor, use Token like this:

val token = Token("SELECT * FROM TABLE", 'id, Extractor, "foo"->bar)

This is of course wrong. The parameters are not supplied in the token definition. Should be:

val token = Token("SELECT * FROM TABLE", 'id, Extractor)


Eduardo M. Cavalcanti

unread,
Jun 28, 2011, 4:38:35 PM6/28/11
to orbr...@googlegroups.com
Thank you, Nils.
By the way, I have been using Orbroker with pleasure.
Reply all
Reply to author
Forward
0 new messages