Editing
Primes system Design
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= pgcobol β design documentation = <blockquote>'''System:''' pgcobol β Three-Tier COBOL / PostgreSQL Prime Numbers Application<br /> '''Version:''' 1.0 Β· Reverse-engineered baseline Β· 2026-03-17<br /> '''Runtime:''' GnuCOBOL 4.0 Β· GixSQL Β· PostgreSQL 11 Β· Linux </blockquote> ----- <span id="quick-navigation"></span> == Quick Navigation == {| !width="33%"| !width="33%"| Page !width="33%"| What you will find |- | π | '''[[Primes system Design]]''' | [[Cobol and PostgreSQL]] | This page β overview, architecture snapshot, quick-start |- | π| '''[[Business-Requirements|Business Requirements]]''' | What the system must do; stakeholders; constraints |- | β | '''[[Technical-Specification|Technical Specification]]''' | Stack; architecture; pseudocode for all four programs; SQL inventory; file spec; defect register |- | π| '''[[Data-Dictionary|Data Dictionary]]''' | Every field in every copybook and working-storage section |- | π| '''[[Flow-Diagrams|Flow Diagrams]]''' | Eight Mermaid diagrams β call graphs, sieve loop, report loop, sequence diagrams |} ----- <span id="system-overview"></span> == System Overview == pgcobol is a '''batch COBOL application''' that generates prime numbers by trial division, stores them in a PostgreSQL database, and produces a formatted line-printer report. It demonstrates a clean '''three-tier architecture''' entirely within COBOL. <pre> ββββββββββββββββββββββββββββββββββββββββββββββββ β primesmain β Orchestrator β Reads command-line arg β routes to tier β primesmain.cbl βββββββββββββββββββββ¬βββββββββββββββββββββββββββ β CALL using primes-session βββββββββββββΌβββββββββββββββ β primesgen β Business Logic / Sieve Engine β Sieve algorithm or β primesgen.cbl β cursor read-loop β ββββββββββ¬ββββββββββββββββββ CALL primes-dalβ βCALL primes-ui βββββββββββββΌβββ ββββΌβββββββββββββββ β primes β β primesui β Presentation β DAL + SQL β β Print file + β primesui.cbl β primes.cbl β β console log β ββββββββ¬ββββββββ ββββββββββββββββββββ β EXEC SQL via GixSQL ββββββββΌββββββββββββββββ β PostgreSQL 11 β β schema: primes β β table: primes β ββββββββββββββββββββββββ</pre> ----- <span id="two-operational-modes"></span> == Two Operational Modes == {| !width="50%"| Argument !width="50%"| What happens |- | <code>generate</code> | primesgen runs the sieve from 3 β 999,999,999; each confirmed prime is inserted into the database |- | <code>report</code> | primesgen opens a cursor over the primes table; each row is written into the formatted print file <code>primes.prt</code> |} <blockquote>β '''Known defect:''' The <code>generate</code> path exists in the code but the PERFORM that invokes the sieve loop is commented out in <code>primesmain.cbl</code> (line 51). See [[Technical-Specification#7-known-technical-issues|Technical Specification β Defect Register]]. </blockquote> ----- <span id="source-file-inventory"></span> == Source File Inventory == {| !width="33%"| File !width="33%"| Type !width="33%"| Role |- | <code>primesmain.cbl</code> | COBOL program | Entry point β session controller |- | <code>primesgen.cbl</code> | COBOL program | Business logic β sieve and report loops |- | <code>primes.cbl</code> | COBOL + GixSQL | Data access layer β all SQL |- | <code>primesui.cbl</code> | COBOL program | Presentation β print file and console |- | <code>primes-session.cpy</code> | Copybook | Session-tier control block |- | <code>primes-dal.cpy</code> | Copybook | DAL-tier control block |- | <code>primes-ui.cpy</code> | Copybook | UI-tier control block (all programs) |- | <code>primes-table.cpy</code> | Copybook | SQL host variable β character format |- | <code>primes_table.cpy</code> | Copybook | SQL host variable β COMP-3 format (duplicate β see [[Data-Dictionary#15-primes_table--sql-host-variable-packed|Data Dictionary]]) |- | <code>SQLCA.cpy</code> | Copybook | GixSQL SQL Communications Area |- | <code>primes_schema.sql</code> | DDL | Creates schema, sequence, and table |- | <code>reset-primes.sql</code> | DDL | Drops and recreates schema for a fresh run |- | <code>primes_cbsql.out</code> | Listing | GixSQL pre-compiler expanded output |} ----- <span id="inter-tier-communication-pattern"></span> == Inter-Tier Communication Pattern == All programs communicate through '''method-dispatch control blocks''' defined in copybooks. The pattern is the same at every tier: <pre>1. Caller MOVEs a verb string into the control block's methods field 2. Caller CALLs the subprogram, passing the control block BY REFERENCE 3. Subprogram EVALUATEs the verb, executes the matching paragraph 4. Subprogram sets a numeric result code before EXIT PROGRAM 5. Caller inspects the result field and branches accordingly</pre> {| !width="33%"| Tier boundary !width="33%"| Control block !width="33%"| Result codes |- | primesmain β primesgen | <code>primes-session</code> | 0 = ok Β· 1 = nok Β· 9 = eof |- | primesgen β primes | <code>primes-dal</code> | 0 = ok Β· 1 = nok Β· 99 = eof |- | any β primesui | <code>primes-ui</code> | 0 = ok Β· 1 = nok |} ----- <span id="document-revision"></span> == Document Revision == {| !width="33%"| Page !width="33%"| Document ID !width="33%"| Last updated |- | [[Business-Requirements|Business Requirements]] | PGCBL-BRD-001 | 2026-03-17 |- | [[Technical-Specification|Technical Specification]] | PGCBL-TSD-001 | 2026-03-17 |- | [[Data-Dictionary|Data Dictionary]] | PGCBL-DDD-001 | 2026-03-17 |- | [[Flow-Diagrams|Flow Diagrams]] | PGCBL-FLD-001 | 2026-03-17 |} ----- ''All pages derived by reverse engineering of source artifacts. Items marked β indicate known defects or unconfirmed assumptions.'' <hr/> Terug naar: [[Cobol and PostgreSQL]]
Summary:
Please note that all contributions to Webhuis wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Voorpagina
Cobol and PostgreSQL
PostgreSQL
CFEngine
Proxmox
Webhuis Kennisbank
Basale infra
Webhuis bouwstenen
Webhuis configuratie
Webhuis Infra
Webhuis Support
Webhuis Raspberry
Opzet Applicaties
Business Applicaties
Community portal
Current events
Recent changes
Random page
Help
sitesupport
Tools
What links here
Related changes
Special pages
Page information