Difference between revisions of "Documentation/DevGuide/Database/Modifiable Result Sets"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Database Access) |
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
||
Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/Database/Update | |NextPage=Documentation/DevGuide/Database/Update | ||
}} | }} | ||
− | {{DISPLAYTITLE:Modifiable Result Sets}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Database/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Modifiable Result Sets}} | ||
Another feature of SDBC is the ability to update rows in a result set using methods in the programming language, rather than sending an SQL command. Before doing this, a modifiable result set must be created. To create a modifiable result set, supply the <code>ResultSetConcurrency</code> constant <code>UPDATABLE</code> to the <code>Statement</code> property <code>ResultSetConcurrency</code>, so that the <code>Statement</code> object creates an modifiable <code>ResultSet</code> object each time it executes a query. | Another feature of SDBC is the ability to update rows in a result set using methods in the programming language, rather than sending an SQL command. Before doing this, a modifiable result set must be created. To create a modifiable result set, supply the <code>ResultSetConcurrency</code> constant <code>UPDATABLE</code> to the <code>Statement</code> property <code>ResultSetConcurrency</code>, so that the <code>Statement</code> object creates an modifiable <code>ResultSet</code> object each time it executes a query. | ||
Revision as of 12:49, 15 May 2009
Another feature of SDBC is the ability to update rows in a result set using methods in the programming language, rather than sending an SQL command. Before doing this, a modifiable result set must be created. To create a modifiable result set, supply the ResultSetConcurrency
constant UPDATABLE
to the Statement
property ResultSetConcurrency
, so that the Statement
object creates an modifiable ResultSet
object each time it executes a query.
The following code fragment creates a modifiable XResultSet
object rs
. Note that the code also makes rs
scrollable. A modifiable ResultSet
object does not have to be scrollable, but when changes are made to a result set, the user may want to move around in it. With a scrollable result set, there is the ability to move to particular rows that you can work with. If the type is SCROLL_SENSITIVE
, the new value in a row can be obtained after it has changed without refreshing the whole result set.
XStatement stmt = con.createStatement(); XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, stmt); xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE)); xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.UPDATABLE)); XResultSet rs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES"); XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, rs);
The ResultSet
object rs may look similar to this:
NAME | PRICE |
---|---|
Linux | $30.00 |
Beef | $15.78 |
Orange juice | $1.50 |
The methods can now be used in the com.sun.star.sdbc.XRowUpdate interface of the result set to insert a new row into rs
, delete an existing row from rs
, or modify a column value in rs
.
Content on this page is licensed under the Public Documentation License (PDL). |