Update data

First we define an updatable fetch. A fetch is like a query but it can only contain single row. A fetch doesn’t generate a class as for the result set. You can also use the columns of a fetch as for query conditions (like the CustomerID column marked with @ in the example above).
fetch Customer [[
  FROM Customers
  WHERE CustomerID = @CustomerID
]] update "Customers" {
  readonly compare CustomerID: int;

Update “Customers” defines that this fetch will update the Customers table. Definition “readonly compare CustomerID: int” will tell that the CustomerID column is a special column that is never inserted or updated and it will be used as for comparison (in where clause) when row is updated or deleted. In NSQLObjects, you don’t define primary keys, only columns which to compare.

There are several ways to define default types for columns. You can use column types or column names to define defaults (See Define generated properties) or you can define common base classes (See Common business logic).

Queries can also contain updatable rows. Fetch is however recommended when a query can return only single rows.

Create a row

Last edited Oct 26, 2010 at 8:49 AM by nolics, version 3


No comments yet.