Skip to main content

CRUD over an existing table

The problem​

A database table — products, tickets, contracts — and a team that needs to read and edit it, without writing a front end.

The pattern​

table → connector with 4 generated queries → screen → menu entry

The recipe​

1. Reach the database​

Liberty Next → Administer → Pools: the default pool works when the table is in the framework's database; otherwise add a pool with the database's URL. See Connectors.

2. Generate the queries​

Liberty Next → Build → Connectors: create (or pick) the SQL connector, choose the Tables view, then + Add queries → Generate from DB. Pick the products table, keep the columns to show, tick key on ID, keep the four statements and save. The wizard writes:

-- products_get
SELECT ID, NAME, PRICE, STOCK FROM products

-- products_post
INSERT INTO products (ID, NAME, PRICE, STOCK) VALUES (:ID, :NAME, :PRICE, :STOCK)

-- products_put
UPDATE products SET NAME = :NAME, PRICE = :PRICE, STOCK = :STOCK WHERE ID = :ID_ORIGINAL

-- products_delete
DELETE FROM products WHERE ID = :ID

To stamp who changed a row and when, add the audit columns to the write queries with server tokens — the browser cannot alter them:

UPDATE products
SET NAME = :NAME, PRICE = :PRICE, STOCK = :STOCK,
UPDATED_BY = {{LOGIN}}, UPDATED_AT = {{SYSTIMESTAMP}}
WHERE ID = :ID_ORIGINAL

Or give the UPDATED_BY / UPDATED_AT dictionary entries the LOGIN / SYSDATE rules. See Parameter binding → Tokens.

3. Build the screen​

Liberty Next → Build → Screens, the connector's chip (+ Add scope the first time), + Add screen products, then in the screen editor:

TabSetting
GeneralLabel Products; Editable for in-grid editing; uploadable for Excel / CSV import.
QueriesRead products_get, update products_put, insert products_post, delete products_delete.
ColumnsLabels, formats, widths, filters.
DialogDrag the columns onto the form.

The Screen Creation Assistant does steps 2 and 3 in one pass.

4. Add the menu entry​

Liberty Next → Build → Menus, the connector's chip (+ Add scope the first time), + Item: label Products, type screen, target products_get. Save.

Result​

Clicking Products opens the grid: sort and filter by column, group, save views; a row opens the edit dialog, + Add an empty one, Delete removes the row. Each query has its own permission — sql:<connector>:products_get, sql:<connector>:products_put… — to grant through roles.

Variations​

NeedHow
Labels and lists of valuesDictionary entries on the columns, with an ENUM or LOOKUP rule — see Dictionary.
Read-only for some usersGive their role only the read query's permission: writes are refused. To make the screen read-only for everyone, tick Read-only on the General tab.
Excel exportThe screen's Export tab — see Excel export.
Related rows inside the dialogA nested_table tab — see Nested tabs.
Bulk loading from a fileSee Bulk import.

What's next​