<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.webhuis.nl:443/index.php?action=history&amp;feed=atom&amp;title=PrimesSQL_Design</id>
	<title>PrimesSQL Design - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.webhuis.nl:443/index.php?action=history&amp;feed=atom&amp;title=PrimesSQL_Design"/>
	<link rel="alternate" type="text/html" href="https://wiki.webhuis.nl:443/index.php?title=PrimesSQL_Design&amp;action=history"/>
	<updated>2026-09-03T05:20:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.webhuis.nl:443/index.php?title=PrimesSQL_Design&amp;diff=4690&amp;oldid=prev</id>
		<title>Martin: Created page with &quot;# pgcobol Wiki  &gt; **pgcobol** — Three-tier GnuCOBOL / PostgreSQL prime-numbers application · v1.0 · reverse-engineered 2026-03-17  ---  ## What is pgcobol?  pgcobol is a batch COBOL application that demonstrates a clean three-tier architecture on Linux. It generates prime numbers by trial division, persists each prime in a PostgreSQL database, and produces a paginated printed report of all stored primes. There is no interactive interface; everything is driven from a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.webhuis.nl:443/index.php?title=PrimesSQL_Design&amp;diff=4690&amp;oldid=prev"/>
		<updated>2026-03-24T14:56:39Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;# pgcobol Wiki  &amp;gt; **pgcobol** — Three-tier GnuCOBOL / PostgreSQL prime-numbers application · v1.0 · reverse-engineered 2026-03-17  ---  ## What is pgcobol?  pgcobol is a batch COBOL application that demonstrates a clean three-tier architecture on Linux. It generates prime numbers by trial division, persists each prime in a PostgreSQL database, and produces a paginated printed report of all stored primes. There is no interactive interface; everything is driven from a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;# pgcobol Wiki&lt;br /&gt;
&lt;br /&gt;
&amp;gt; **pgcobol** — Three-tier GnuCOBOL / PostgreSQL prime-numbers application · v1.0 · reverse-engineered 2026-03-17&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## What is pgcobol?&lt;br /&gt;
&lt;br /&gt;
pgcobol is a batch COBOL application that demonstrates a clean three-tier architecture on Linux. It generates prime numbers by trial division, persists each prime in a PostgreSQL database, and produces a paginated printed report of all stored primes. There is no interactive interface; everything is driven from a single command-line argument.&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
primesmain  generate   →  primesgen  →  primes (DAL)  →  PostgreSQL&lt;br /&gt;
primesmain  report     →  primesgen  →  primes (DAL)  →  primesui  →  primes.prt&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Quick Start&lt;br /&gt;
&lt;br /&gt;
| Goal | Command |&lt;br /&gt;
|---|---|&lt;br /&gt;
| Generate primes | `./primesmain generate` |&lt;br /&gt;
| Produce report | `./primesmain report` |&lt;br /&gt;
| Reset database | `psql -f reset-primes.sql` |&lt;br /&gt;
&lt;br /&gt;
**Prerequisites:** GnuCOBOL 4.0, GixSQL pre-processor, PostgreSQL 11+, schema initialised with `primes_schema.sql`, prime 2 manually inserted.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; ⚠ **Known issue:** The generate loop is commented out in `primesmain.cbl` line 51. Generation mode does not execute the sieve in the current source. See [Technical Specification › Known Issues](design/technical-spec.md#7-known-technical-issues).&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Source Files&lt;br /&gt;
&lt;br /&gt;
| File | Type | Role |&lt;br /&gt;
|---|---|---|&lt;br /&gt;
| `primesmain.cbl` | COBOL | Entry point and session orchestrator |&lt;br /&gt;
| `primesgen.cbl` | COBOL | Business logic — sieve algorithm and report loop |&lt;br /&gt;
| `primes.cbl` | COBOL + GixSQL | Data access layer — all SQL |&lt;br /&gt;
| `primesui.cbl` | COBOL | Presentation — print file and console |&lt;br /&gt;
| `primes-session.cpy` | Copybook | Session-tier interface contract |&lt;br /&gt;
| `primes-dal.cpy` | Copybook | DAL-tier interface contract |&lt;br /&gt;
| `primes-ui.cpy` | Copybook | UI-tier interface contract (all programs) |&lt;br /&gt;
| `primes-table.cpy` | Copybook | SQL host variable — character format |&lt;br /&gt;
| `primes_table.cpy` | Copybook | SQL host variable — COMP-3 packed (alternate) |&lt;br /&gt;
| `SQLCA.cpy` | Copybook | GixSQL SQL Communications Area |&lt;br /&gt;
| `primes_schema.sql` | DDL | Schema, sequence, table definition |&lt;br /&gt;
| `reset-primes.sql` | DDL | Drop and recreate for a clean test run |&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Design-Level Documentation&lt;br /&gt;
&lt;br /&gt;
These pages describe **what** the system does and how it is structured.&lt;br /&gt;
&lt;br /&gt;
| Page | Contents |&lt;br /&gt;
|---|---|&lt;br /&gt;
| [Business Requirements](design/business-requirements.md) | Functional requirements (FR-01–FR-06), non-functional requirements, stakeholders, constraints |&lt;br /&gt;
| [Technical Specification](design/technical-spec.md) | Architecture diagram, component inventory, full pseudocode for all four programs, database connection parameters, SQL statement inventory, file I/O specification, known defects |&lt;br /&gt;
| [Data Dictionary](design/data-dictionary.md) | Every field in every copybook and working-storage section — name, level, picture, usage, semantic description, all 88-level conditions; database schema objects |&lt;br /&gt;
| [Flow Diagrams](design/flow-diagrams.md) | Eight Mermaid diagrams: top-level flow, primesgen dispatch, generate sieve loop, report loop, DAL dispatch, UI dispatch, generate sequence diagram, report sequence diagram |&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Program-Level Documentation&lt;br /&gt;
&lt;br /&gt;
These pages describe **how** each program works internally.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; 🔧 *Program-level pages are listed here for completeness. Contents are defined in the program-level specification set.*&lt;br /&gt;
&lt;br /&gt;
| Page | Contents |&lt;br /&gt;
|---|---|&lt;br /&gt;
| Program Logic | Step-by-step paragraph logic for all four programs |&lt;br /&gt;
| Business Rules | Primality algorithm rules, validation, formatting rules, error-handling conventions |&lt;br /&gt;
| I/O Behaviour | File handling, console output, database call patterns |&lt;br /&gt;
| Control Flow | PERFORM/CALL/EVALUATE trees, loop structure, paragraph maps |&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Architecture at a Glance&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
┌───────────────────────────────────────────┐&lt;br /&gt;
│              primesmain                   │  Orchestrator&lt;br /&gt;
│  Reads arg → dispatches → shuts down      │&lt;br /&gt;
└──────────────────┬────────────────────────┘&lt;br /&gt;
                   │  CALL using primes-session&lt;br /&gt;
        ┌──────────▼──────────┐&lt;br /&gt;
        │      primesgen      │  Business Logic&lt;br /&gt;
        │  sieve / report     │&lt;br /&gt;
        └───┬─────────────────┘&lt;br /&gt;
            │ primes-dal          │ primes-ui&lt;br /&gt;
   ┌────────▼──────┐    ┌────────▼──────────┐&lt;br /&gt;
   │    primes     │    │    primesui        │  Presentation&lt;br /&gt;
   │  (DAL / SQL)  │    │  primes.prt        │&lt;br /&gt;
   └───────┬───────┘    └────────────────────┘&lt;br /&gt;
           │&lt;br /&gt;
   ┌───────▼───────┐&lt;br /&gt;
   │  PostgreSQL   │&lt;br /&gt;
   │  primes.primes│&lt;br /&gt;
   └───────────────┘&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
All inter-program communication uses **method-dispatch**: the caller moves a verb string into a control-block field, calls the subprogram, and reads a numeric result code on return. The control blocks are defined in copybooks (`primes-session.cpy`, `primes-dal.cpy`, `primes-ui.cpy`) which serve as the published interface contracts between tiers.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Result Code Convention&lt;br /&gt;
&lt;br /&gt;
Used consistently across all three control blocks:&lt;br /&gt;
&lt;br /&gt;
| Code | Meaning |&lt;br /&gt;
|---|---|&lt;br /&gt;
| `0` | Success |&lt;br /&gt;
| `1` | Error / failure |&lt;br /&gt;
| `9` | End of data (session tier) |&lt;br /&gt;
| `99` | End of data (DAL tier) |&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
## Open Issues&lt;br /&gt;
&lt;br /&gt;
| ID | Severity | Description | See |&lt;br /&gt;
|---|---|---|---|&lt;br /&gt;
| T1 | High | Generate loop commented out — generation does not run | [Tech Spec §7](design/technical-spec.md#7-known-technical-issues) |&lt;br /&gt;
| T2 | High | Connection alias mismatch (`primes` vs `primesdb`) | [Tech Spec §7](design/technical-spec.md#7-known-technical-issues) |&lt;br /&gt;
| T3 | Medium | COMMIT on INSERT is commented out | [Tech Spec §7](design/technical-spec.md#7-known-technical-issues) |&lt;br /&gt;
| T4 | Medium | Prime 2 not seeded before sieve starts | [Business Requirements §5](design/business-requirements.md#5-assumptions-and-constraints) |&lt;br /&gt;
| T5 | Low | Database credentials hard-coded in source | [Data Dictionary §2.3](design/data-dictionary.md#23-primes-dal) |&lt;br /&gt;
| T6 | Low | Two near-duplicate host-variable copybooks | [Data Dictionary §1.4](design/data-dictionary.md#14-primes-table--sql-host-variable-character) |&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
*Last updated: 2026-03-17 · Source: reverse-engineered from pgcobol v1.0 artifacts*&lt;/div&gt;</summary>
		<author><name>Martin</name></author>
	</entry>
</feed>