SQL Server · CrudLabDB

Edit article

Feature 2 Update. The hidden rowVersion (now 1) protects you if someone else saves first.

UPDATE article … WHERE id = ? AND row_version = ?
Stored in an NVARCHAR(MAX) column: long text and Thai (ภาษาไทย) are fine.
Unique business key (unique index UX_article_code). Empty = next number from the SEQUENCE.
Separate with commas. Duplicates are removed.
Status: Unpublished
Cancel * required
SQL behind this page

Captured by a Hibernate StatementInspector and by the JdbcTemplate code. ? marks a parameter: values are sent separately, which keeps SQL injection out.

Loading this page
1
SELECT
  COUNT(*)                                                                AS total,
  SUM(CASE WHEN deleted = 0 AND archived = 0 THEN 1 ELSE 0 END)           AS active,
  SUM(CASE WHEN deleted = 0 AND archived = 0 AND status = 'DRAFT' THEN 1 ELSE 0 END)       AS drafts,
  SUM(CASE WHEN deleted = 0 AND archived = 0 AND status = 'PUBLISHED' THEN 1 ELSE 0 END)   AS published,
  SUM(CASE WHEN deleted = 0 AND archived = 0 AND status = 'UNPUBLISHED' THEN 1 ELSE 0 END) AS unpublished,
  SUM(CASE WHEN deleted = 0 AND archived = 0 AND pinned = 1 THEN 1 ELSE 0 END)    AS pinned,
  SUM(CASE WHEN deleted = 0 AND favourite = 1 THEN 1 ELSE 0 END)                  AS favourites,
  SUM(CASE WHEN deleted = 0 AND archived = 0 AND is_read = 0 THEN 1 ELSE 0 END)   AS unread,
  SUM(CASE WHEN deleted = 0 AND locked = 1 THEN 1 ELSE 0 END)                     AS locked,
  SUM(CASE WHEN deleted = 0 AND archived = 1 THEN 1 ELSE 0 END)                   AS archived,
  SUM(CASE WHEN deleted = 1 THEN 1 ELSE 0 END)                                    AS trash
FROM article
2
select a1_0.id,a1_0.archived,a1_0.archived_at,a1_0.category,a1_0.code,a1_0.content,a1_0.created_at,a1_0.deleted,a1_0.deleted_at,a1_0.favourite,a1_0.locked,a1_0.locked_at,a1_0.locked_reason,a1_0.merged_into_id,a1_0.pinned,a1_0.pinned_at,a1_0.priority,a1_0.published_at,a1_0.is_read,a1_0.read_at,a1_0.row_version,a1_0.source_id,a1_0.status,a1_0.summary,a1_0.tags,a1_0.title,a1_0.updated_at from article a1_0 where a1_0.id=?
3
select distinct a1_0.category from article a1_0 where a1_0.deleted=0 order by a1_0.category