Data-Dictionary: Difference between revisions
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
= Data Dictionary = |
= Data Dictionary = |
||
<blockquote>'''Document ID:''' PGCBL-DDD-001 · '''Version:''' 1.0 · '''Status:''' Approved · '''Last updated:''' 2026-03-17 |
|||
'''Project:''' pgcobol — Prime Numbers Application<br /> |
|||
</blockquote> |
|||
'''Version:''' 1.0 (reverse-engineered)<br /> |
|||
'''← [[Technical-Specification|Technical Specification]]''' | [[Flow-Diagrams|Flow Diagrams →]] |
|||
'''Date:''' 2026-03-17 |
|||
----- |
|||
<span id="contents"></span> |
|||
== Contents == |
|||
# [[#conventions|Conventions]] |
|||
# [[#1-control-blocks-copybooks|Control Blocks — Copybooks]] |
|||
#* [[#11-primes-session|1.1 primes-session]] |
|||
#* [[#12-primes-dal|1.2 primes-dal]] |
|||
#* [[#13-primes-ui|1.3 primes-ui]] |
|||
#* [[#14-primes-table--sql-host-variable-character|1.4 primes-table (character)]] |
|||
#* [[#15-primes_table--sql-host-variable-packed|1.5 primes_table (packed)]] |
|||
#* [[#16-sqlca--sql-communications-area|1.6 SQLCA]] |
|||
# [[#2-working-storage-variables|Working-Storage Variables]] |
|||
#* [[#21-primesmain|2.1 primesmain]] |
|||
#* [[#22-primesgen|2.2 primesgen]] |
|||
#* [[#23-primes-dal|2.3 primes (DAL)]] |
|||
#* [[#24-primesui|2.4 primesui]] |
|||
# [[#3-database-objects|Database Objects]] |
|||
#* [[#31-schema-primes|3.1 Schema primes]] |
|||
#* [[#32-table-primesprimes|3.2 Table primes.primes]] |
|||
#* [[#33-sequence-asc_ident|3.3 Sequence asc_ident]] |
|||
#* [[#34-cursor-primescursor-runtime|3.4 Cursor primescursor]] |
|||
| Line 10: | Line 35: | ||
<span id="conventions"></span> |
<span id="conventions"></span> |
||
== |
== Conventions == |
||
{| |
{| |
||
!width="50%"| Symbol |
|||
! Column |
|||
! Meaning |
!width="50%"| Meaning |
||
|- |
|- |
||
| <code>PIC X(n)</code> |
|||
| Name |
|||
| Alphanumeric, n characters |
|||
| COBOL data-name as written in source |
|||
|- |
|- |
||
| <code>PIC 9(n)</code> |
|||
| Level |
|||
| Unsigned packed decimal display, n digits |
|||
| 01 / 03 / 05 / 07 hierarchy level |
|||
|- |
|- |
||
| <code>PIC S9(n)</code> |
|||
| Picture |
|||
| Signed packed decimal display, n digits |
|||
| COBOL PICTURE clause |
|||
|- |
|- |
||
| <code>PIC 9(n)V9(m)</code> |
|||
| Usage |
|||
| Unsigned numeric with m implied decimal places (no decimal point stored) |
|||
| DISPLAY (default) / COMP-3 / COMP-5 |
|||
|- |
|- |
||
| <code>PIC Z(n)</code> |
|||
| Source |
|||
| Zero-suppressed display numeric, n digits |
|||
| Copybook or program where defined |
|||
|- |
|- |
||
| <code>COMP-3</code> |
|||
| Description |
|||
| Packed-decimal binary storage (2 digits per byte + sign nibble) |
|||
| Semantic meaning and valid values |
|||
|- |
|||
| <code>COMP-5</code> |
|||
| Native binary integer (platform word size) |
|||
|- |
|||
| <code>88</code> |
|||
| Condition-name — a boolean alias tested via <code>IF <name></code> or <code>WHEN <name></code> |
|||
|- |
|||
| <code>—</code> |
|||
| Not applicable (group item or 88-level) |
|||
|- |
|||
| ⚠️ |
|||
| Known issue or deviation from standard |
|||
|} |
|} |
||
'''Level hierarchy used in this codebase:''' |
|||
Condition-names (88-level) are listed under the field they qualify. |
|||
<pre>01 Group root |
|||
03 Sub-group or elementary item |
|||
05 Nested elementary item |
|||
07 Doubly-nested elementary item |
|||
49 Special level for variable-length groups (SQLERRM in SQLCA) |
|||
88 Condition-name (under any level)</pre> |
|||
----- |
----- |
||
<span id=" |
<span id="control-blocks-copybooks"></span> |
||
== |
== 1. Control Blocks — Copybooks == |
||
<span id="primes-session"></span> |
|||
'''Control block for the session (main → business-logic) tier.''' |
|||
=== 1.1 primes-session === |
|||
<blockquote>'''Source file:''' <code>primes-session.cpy</code><br /> |
|||
'''Included by:''' <code>primesmain.cbl</code> (WORKING-STORAGE) · <code>primesgen.cbl</code> (LINKAGE SECTION)<br /> |
|||
'''Purpose:''' Session-tier control block. primesmain sets <code>methods</code>; primesgen reads it and sets <code>session-result</code>. |
|||
</blockquote> |
|||
{| |
{| |
||
!width=" |
!width="16%"| Level |
||
!width=" |
!width="16%"| Name |
||
!width=" |
!width="16%"| PIC |
||
!width=" |
!width="16%"| Usage |
||
!width=" |
!width="16%"| Initial |
||
!width="16%"| Description |
|||
|- |
|- |
||
| <code>primes-session</code> |
|||
| 01 |
| 01 |
||
| <code>primes-session</code> |
|||
| — |
|||
| — |
| — |
||
| — |
| — |
||
| Root of session control block |
| Root of session control block |
||
|- |
|- |
||
| <code>methods</code> |
|||
| 03 |
| 03 |
||
| <code>methods</code> |
|||
| X(32) |
|||
| <code>X(32)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Operation verb set by primesmain before calling primesgen |
|||
| Method dispatch verb — set by primesmain before calling primesgen |
|||
|- |
|- |
||
| — <code>report-primes</code> |
|||
| 88 |
| 88 |
||
| <code>report-primes</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"report"</code> |
|||
| VALUE “report” — run the report path |
|||
| Run the cursor report path |
|||
|- |
|- |
||
| — <code>generate-primes</code> |
|||
| 88 |
| 88 |
||
| <code>generate-primes</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"generate"</code> |
|||
| VALUE “generate” — run the sieve path |
|||
| Run the sieve generation path |
|||
|- |
|- |
||
| — <code>start-primes</code> |
|||
| 88 |
| 88 |
||
| <code>start-primes</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"start"</code> |
|||
| VALUE “start” — (reserved, not used in current flow) |
|||
| Reserved — not used in current flow |
|||
|- |
|- |
||
| — <code>stop-primes</code> |
|||
| 88 |
| 88 |
||
| <code>stop-primes</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"stop"</code> |
|||
| VALUE “stop” — (reserved, not used in current flow) |
|||
| Reserved — not used in current flow |
|||
|- |
|- |
||
| — <code>invalid-method</code> |
|||
| 88 |
| 88 |
||
| <code>invalid-method</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"bad"</code> |
|||
| VALUE “bad” — sentinel for bad dispatch |
|||
| Sentinel for unrecognised verb |
|||
|- |
|- |
||
| <code>session-result</code> |
|||
| 03 |
| 03 |
||
| <code>session-result</code> |
|||
| 9(2) |
|||
| <code>9(2)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| 0 |
|||
| Result code written back by primesgen; initial value ZERO |
|||
| Outcome code written by primesgen |
|||
|- |
|- |
||
| — <code>session-method-ok</code> |
|||
| 88 |
| 88 |
||
| <code>session-method-ok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 0 |
|||
| VALUE 0 — operation succeeded |
|||
| Operation succeeded |
|||
|- |
|- |
||
| — <code>session-method-nok</code> |
|||
| 88 |
| 88 |
||
| <code>session-method-nok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 1 |
|||
| VALUE 1 — operation failed |
|||
| Operation failed |
|||
|- |
|- |
||
| — <code>session-method-eof</code> |
|||
| 88 |
| 88 |
||
| <code>session-method-eof</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 9 |
|||
| VALUE 9 — cursor exhausted (end of data) |
|||
| End of data (cursor exhausted) |
|||
|} |
|} |
||
<blockquote>⚠️ <code>session-method-eof</code> (value 9) is never explicitly set in the current code. Fetch failure sets <code>session-result = 1</code> (nok), not 9. See [[Technical-Specification#7-known-technical-issues|Technical Specification — Defect T7]]. |
|||
</blockquote> |
|||
----- |
----- |
||
<span id=" |
<span id="primes-dal"></span> |
||
== |
=== 1.2 primes-dal === |
||
'''Control block for the DAL (business-logic → data-access) tier.''' |
|||
<blockquote>'''Source file:''' <code>primes-dal.cpy</code><br /> |
|||
'''Included by:''' <code>primesgen.cbl</code> (WORKING-STORAGE, caller) · <code>primes.cbl</code> (LINKAGE SECTION, callee)<br /> |
|||
'''Purpose:''' DAL-tier control block. primesgen sets <code>dal-methods</code> and reads back <code>dal-result</code> and <code>primes-data</code>. |
|||
</blockquote> |
|||
{| |
{| |
||
!width=" |
!width="16%"| Level |
||
!width=" |
!width="16%"| Name |
||
!width=" |
!width="16%"| PIC |
||
!width=" |
!width="16%"| Usage |
||
!width=" |
!width="16%"| Initial |
||
!width="16%"| Description |
|||
|- |
|- |
||
| 01 |
|||
| <code>primes-dal</code> |
| <code>primes-dal</code> |
||
| 01 |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| Root of DAL control block; passed as linkage to primes |
|||
| Root of DAL control block |
|||
|- |
|- |
||
| <code>dal-methods</code> |
|||
| 03 |
| 03 |
||
| <code>dal-methods</code> |
|||
| X(32) |
|||
| <code>X(32)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Operation verb set by caller |
|||
| Method dispatch verb |
|||
|- |
|- |
||
| — <code>next-prime</code> |
|||
| 88 |
| 88 |
||
| <code>next-prime</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"next-prime"</code> |
|||
| VALUE “next-prime” — fetch next row from cursor |
|||
| Fetch next row from open cursor |
|||
|- |
|- |
||
| — <code>next-divider</code> |
|||
| 88 |
| 88 |
||
| <code>next-divider</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"next-divider"</code> |
|||
| VALUE “next-divider” — select divider by ident |
|||
| SELECT a prime by ident for use as trial divisor |
|||
|- |
|- |
||
| — <code>write-prime</code> |
|||
| 88 |
| 88 |
||
| <code>write-prime</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"write"</code> |
|||
| VALUE “write” — insert prime into table |
|||
| INSERT a confirmed prime into the table |
|||
|- |
|- |
||
| — <code>db-cursor</code> |
|||
| 88 |
| 88 |
||
| <code>db-cursor</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"cursor"</code> |
|||
| VALUE “cursor” — start transaction and open cursor |
|||
| START TRANSACTION and OPEN primescursor |
|||
|- |
|- |
||
| — <code>db-connect</code> |
|||
| 88 |
| 88 |
||
| <code>db-connect</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"connect"</code> |
|||
| VALUE “connect” — connect to PostgreSQL |
|||
| Establish the PostgreSQL connection |
|||
|- |
|- |
||
| — <code>db-disconnect</code> |
|||
| 88 |
| 88 |
||
| <code>db-disconnect</code> |
|||
| — |
| — |
||
| — |
| — |
||
| |
| <code>"disconnect"</code> |
||
| Release the connection |
|||
|- |
|- |
||
| — <code>invalid-method</code> |
|||
| 88 |
| 88 |
||
| <code>invalid-method</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"bad"</code> |
|||
| VALUE “bad” — sentinel for bad dispatch |
|||
| Sentinel for unrecognised verb |
|||
|- |
|- |
||
| <code>primes-data</code> |
|||
| 03 |
| 03 |
||
| <code>primes-data</code> |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| One-row data payload |
|||
| Single-row data payload (one prime) |
|||
|- |
|- |
||
| <code>primes-sequence</code> |
|||
| 05 |
| 05 |
||
| <code>primes-sequence</code> |
|||
| 9(9) |
|||
| <code>9(9)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Sequence / ident of the current prime row |
|||
| Row identity (<code>ident</code>) of the fetched prime |
|||
|- |
|- |
||
| <code>prime-number</code> |
|||
| 05 |
| 05 |
||
| <code>prime-number</code> |
|||
| 9(9) |
|||
| <code>9(9)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Value of the current prime |
|||
| The prime value itself |
|||
|- |
|- |
||
| <code>dal-result</code> |
|||
| 03 |
| 03 |
||
| <code>dal-result</code> |
|||
| 9(2) |
|||
| <code>9(2)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| 0 |
|||
| Result code written back by primes; initial value ZERO |
|||
| Outcome code written by primes |
|||
|- |
|- |
||
| — <code>dal-method-ok</code> |
|||
| 88 |
| 88 |
||
| <code>dal-method-ok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 0 |
|||
| VALUE 0 — operation succeeded |
|||
| Operation succeeded |
|||
|- |
|- |
||
| — <code>dal-method-nok</code> |
|||
| 88 |
| 88 |
||
| <code>dal-method-nok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 1 |
|||
| VALUE 1 — operation failed |
|||
| Operation failed |
|||
|- |
|- |
||
| — <code>dal-method-eof</code> |
|||
| 88 |
| 88 |
||
| <code>dal-method-eof</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 99 |
|||
| VALUE 99 — cursor exhausted |
|||
| Cursor exhausted (no more rows) |
|||
|} |
|} |
||
| Line 234: | Line 315: | ||
----- |
----- |
||
<span id=" |
<span id="primes-ui"></span> |
||
== |
=== 1.3 primes-ui === |
||
'''Control block for the UI tier; included by all four programs.''' |
|||
<blockquote>'''Source file:''' <code>primes-ui.cpy</code><br /> |
|||
'''Included by:''' all four programs<br /> |
|||
'''Purpose:''' UI-tier control block. Any program sets <code>ui-methods</code> and <code>process-message</code> / <code>u-primes</code>, then calls primesui; primesui sets <code>ui-method-result</code>. |
|||
</blockquote> |
|||
{| |
{| |
||
!width=" |
!width="16%"| Level |
||
!width=" |
!width="16%"| Name |
||
!width=" |
!width="16%"| PIC |
||
!width=" |
!width="16%"| Usage |
||
!width=" |
!width="16%"| Initial |
||
!width="16%"| Description |
|||
|- |
|- |
||
| <code>primes-ui</code> |
|||
| 01 |
| 01 |
||
| <code>primes-ui</code> |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| Root of UI control block; passed as linkage to primesui |
|||
| Root of UI control block |
|||
|- |
|- |
||
| <code>ui-methods</code> |
|||
| 03 |
| 03 |
||
| <code>ui-methods</code> |
|||
| X(32) |
|||
| <code>X(32)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Operation verb set by caller |
|||
| Method dispatch verb |
|||
|- |
|- |
||
| — <code>write-ui</code> |
|||
| 88 |
| 88 |
||
| <code>write-ui</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"write"</code> |
|||
| VALUE “write” — add one prime row to print buffer |
|||
| Add one prime row to the print buffer |
|||
|- |
|- |
||
| — <code>message-ui</code> |
|||
| 88 |
| 88 |
||
| <code>message-ui</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"log-message"</code> |
|||
| VALUE “log-message” — display console message |
|||
| Write <code>process-message</code> to the console |
|||
|- |
|- |
||
| — <code>start-ui</code> |
|||
| 88 |
| 88 |
||
| <code>start-ui</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"start"</code> |
|||
| VALUE “start” — open print file |
|||
| Open <code>primes.prt</code> |
|||
|- |
|- |
||
| — <code>stop-ui</code> |
|||
| 88 |
| 88 |
||
| <code>stop-ui</code> |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"stop"</code> |
|||
| VALUE “stop” — flush and close print file |
|||
| Flush print buffer and close file |
|||
|- |
|- |
||
| <code>process-message</code> |
|||
| 03 |
| 03 |
||
| <code>process-message</code> |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| Structured console log record |
|||
| Structured 132-char console log record |
|||
|- |
|- |
||
| <code>program-name</code> |
|||
| 05 |
| 05 |
||
| <code>program-name</code> |
|||
| X(20) |
|||
| <code>X(20)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Name of the calling program (for log messages) |
|||
| Name of the calling program |
|||
|- |
|- |
||
| <code>program-line</code> |
|||
| 05 |
| 05 |
||
| <code>program-line</code> |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| Group: paragraph name + message text |
|||
| Location within the calling program |
|||
|- |
|- |
||
| <code>program-paragraph</code> |
|||
| 07 |
| 07 |
||
| <code>program-paragraph</code> |
|||
| X(20) |
|||
| <code>X(20)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Name of the calling paragraph |
| Name of the calling paragraph |
||
|- |
|- |
||
| <code>program-message</code> |
|||
| 07 |
| 07 |
||
| <code>program-message</code> |
|||
| X(92) |
|||
| <code>X(92)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Human-readable status or error message |
|||
| Human-readable status or error text |
|||
|- |
|- |
||
| <code>u-primes</code> |
|||
| 03 |
| 03 |
||
| <code>u-primes</code> |
|||
| — |
|||
| — |
| — |
||
| — |
| — |
||
| One prime row for the print writer |
| One prime row for the print writer |
||
|- |
|- |
||
| <code>u-sequence</code> |
|||
| 05 |
| 05 |
||
| <code>u-sequence</code> |
|||
| 9(9) |
|||
| <code>9(9)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Prime sequence number (ident) to print |
|||
| Sequence number (ident) to write to print buffer |
|||
|- |
|- |
||
| <code>u-number</code> |
|||
| 05 |
| 05 |
||
| <code>u-number</code> |
|||
| 9(9) |
|||
| <code>9(9)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Prime value to print |
|||
| Prime value to write to print buffer |
|||
|- |
|- |
||
| <code>ui-method-result</code> |
|||
| 03 |
| 03 |
||
| <code>ui-method-result</code> |
|||
| 9(2) |
|||
| <code>9(2)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| 0 |
|||
| Result code from primesui; initial value ZERO |
|||
| Outcome code written by primesui |
|||
|- |
|- |
||
| — <code>ui-method-ok</code> |
|||
| 88 |
| 88 |
||
| <code>ui-method-ok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 0 |
|||
| VALUE 0 — operation succeeded |
|||
| Operation succeeded |
|||
|- |
|- |
||
| — <code>ui-method-nok</code> |
|||
| 88 |
| 88 |
||
| <code>ui-method-nok</code> |
|||
| — |
| — |
||
| — |
| — |
||
| 1 |
|||
| VALUE 1 — operation failed |
|||
| Operation failed |
|||
|} |
|} |
||
'''Console message layout''' (132 characters, left-to-right): |
|||
<pre>┌──────────────────────┬──────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────┐ |
|||
│ program-name (20) │ program-paragraph(20)│ program-message (92) │ |
|||
└──────────────────────┴──────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────┘</pre> |
|||
----- |
----- |
||
<span id=" |
<span id="primes-table-sql-host-variable-character"></span> |
||
== |
=== 1.4 primes-table — SQL Host Variable (character) === |
||
'''SQL host variable — character (DISPLAY) format.''' |
|||
<blockquote>'''Source file:''' <code>primes-table.cpy</code><br /> |
|||
'''Included by:''' <code>primes.cbl</code> via <code>EXEC SQL INCLUDE primes-table END-EXEC</code><br /> |
|||
'''Purpose:''' Host variable layout for GixSQL to bind the <code>primes.primes</code> table columns. |
|||
</blockquote> |
|||
{| |
{| |
||
!width="20%"| Name |
|||
!width="20%"| Level |
!width="20%"| Level |
||
!width="20%"| |
!width="20%"| Name |
||
!width="20%"| PIC |
|||
!width="20%"| Usage |
!width="20%"| Usage |
||
!width="20%"| Description |
!width="20%"| Description |
||
|- |
|- |
||
| 01 |
|||
| <code>primes-table</code> |
| <code>primes-table</code> |
||
| 01 |
|||
| — |
| — |
||
| — |
| — |
||
| Host variable group |
| Host variable group (character format) |
||
|- |
|- |
||
| <code>ident</code> |
|||
| 03 |
| 03 |
||
| <code>ident</code> |
|||
| S9(9) |
|||
| <code>S9(9)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| Maps to <code>primes.ident</code>; signed for SQL compatibility |
|||
| Row identity (sequence number), signed |
|||
|- |
|- |
||
| 03 |
|||
| <code>prime</code> |
| <code>prime</code> |
||
| <code>S9(9)</code> |
|||
| 03 |
|||
| S9(9) |
|||
| DISPLAY |
| DISPLAY |
||
| Maps to <code>primes.prime</code>; signed for SQL compatibility |
|||
| Prime value, signed |
|||
|} |
|} |
||
| Line 386: | Line 494: | ||
----- |
----- |
||
<span id=" |
<span id="primes_table-sql-host-variable-packed"></span> |
||
== |
=== 1.5 primes_table — SQL Host Variable (packed) === |
||
'''SQL host variable — packed-decimal (COMP-3) format. Alternate version of primes-table.cpy.''' |
|||
<blockquote>'''Source file:''' <code>primes_table.cpy</code><br /> |
|||
'''Included by:''' <code>primes.cbl</code> (alternative layout)<br /> |
|||
'''Purpose:''' COMP-3 variant of <code>primes-table</code>. The underscore in both the filename and root name is a deviation from the project’s hyphen convention. |
|||
</blockquote> |
|||
{| |
{| |
||
! Level |
|||
! Name |
! Name |
||
! |
! PIC |
||
! Picture |
|||
! Usage |
! Usage |
||
! Description |
! Description |
||
|- |
|- |
||
| <code>primes_table</code> |
|||
| 01 |
| 01 |
||
| <code>primes_table</code> |
|||
| — |
| — |
||
| — |
| — |
||
| Host variable group |
| Host variable group (COMP-3 format) |
||
|- |
|- |
||
| <code>ident</code> |
|||
| 03 |
| 03 |
||
| <code>ident</code> |
|||
| S9(9) |
|||
| <code>S9(9)</code> |
|||
| COMP-3 |
| COMP-3 |
||
| Row identity |
| Row identity — packed decimal |
||
|- |
|- |
||
| 03 |
|||
| <code>prime</code> |
| <code>prime</code> |
||
| <code>S9(9)</code> |
|||
| 03 |
|||
| S9(9) |
|||
| COMP-3 |
| COMP-3 |
||
| Prime value |
| Prime value — packed decimal |
||
|} |
|} |
||
<blockquote>⚠️ Two nearly identical copybooks exist. <code>primes-table.cpy</code> (hyphens, DISPLAY) is used by the cursor FETCH target (<code>primes-row</code>). The canonical version should be designated and the other retired. See [[Technical-Specification#7-known-technical-issues|Technical Specification — Defect T6]]. |
|||
</blockquote> |
|||
----- |
----- |
||
<span id=" |
<span id="sqlca-sql-communications-area"></span> |
||
== |
=== 1.6 SQLCA — SQL Communications Area === |
||
'''GixSQL SQL Communications Area — standard across all embedded-SQL programs.''' |
|||
<blockquote>'''Source file:''' <code>SQLCA.cpy</code><br /> |
|||
'''Included by:''' <code>primes.cbl</code> via <code>EXEC SQL INCLUDE SQLCA END-EXEC</code><br /> |
|||
'''Purpose:''' Standard GixSQL communications area. Updated after every SQL statement. |
|||
</blockquote> |
|||
{| |
{| |
||
!width="20%"| Name |
|||
!width="20%"| Level |
!width="20%"| Level |
||
!width="20%"| |
!width="20%"| Name |
||
!width="20%"| PIC |
|||
!width="20%"| Usage |
!width="20%"| Usage |
||
!width="20%"| Description |
!width="20%"| Description |
||
|- |
|- |
||
| <code>SQLCA</code> |
|||
| 01 |
| 01 |
||
| <code>SQLCA</code> |
|||
| — |
| — |
||
| — |
| — |
||
| SQL communications area |
| SQL communications area |
||
|- |
|- |
||
| <code>SQLCAID</code> |
|||
| 05 |
| 05 |
||
| <code>SQLCAID</code> |
|||
| X(8) |
|||
| <code>X(8)</code> |
|||
| DISPLAY |
| DISPLAY |
||
| SQLCA identifier string |
| SQLCA identifier string |
||
|- |
|- |
||
| <code>SQLCABC</code> |
|||
| 05 |
| 05 |
||
| <code>SQLCABC</code> |
|||
| S9(9) |
|||
| <code>S9(9)</code> |
|||
| COMP-5 |
| COMP-5 |
||
| Byte length of SQLCA |
| Byte length of SQLCA structure |
||
|- |
|- |
||
| 05 |
|||
| <code>SQLCODE</code> |
| <code>SQLCODE</code> |
||
| <code>S9(9)</code> |
|||
| 05 |
|||
| S9(9) |
|||
| COMP-5 |
| COMP-5 |
||
| SQL return code: 0 |
| '''SQL return code:''' 0=success · negative=error · +100=not found |
||
|- |
|- |
||
| <code>SQLERRM</code> |
|||
| 05 |
| 05 |
||
| <code>SQLERRM</code> |
|||
| — |
| — |
||
| — |
| — |
||
| Error message group |
| Error message group |
||
|- |
|- |
||
| 49 |
|||
| <code>SQLERRML</code> |
| <code>SQLERRML</code> |
||
| <code>S9(4)</code> |
|||
| 49 |
|||
| S9(4) |
|||
| COMP-5 |
| COMP-5 |
||
| Length of error message text |
| Length of error message text |
||
|- |
|- |
||
| 49 |
|||
| <code>SQLERRMC</code> |
| <code>SQLERRMC</code> |
||
| <code>X(70)</code> |
|||
| 49 |
|||
| X(70) |
|||
| DISPLAY |
| DISPLAY |
||
| Error message text |
| Error message text from the database engine |
||
|- |
|- |
||
| 05 |
|||
| <code>SQLERRP</code> |
| <code>SQLERRP</code> |
||
| <code>X(8)</code> |
|||
| 05 |
|||
| X(8) |
|||
| DISPLAY |
| DISPLAY |
||
| Error |
| Error procedure name (not used in this application) |
||
|- |
|- |
||
| 05 |
|||
| <code>SQLERRD</code> |
| <code>SQLERRD</code> |
||
| <code>S9(9)</code> OCCURS 6 |
|||
| 05 |
|||
| S9(9) OCCURS 6 |
|||
| COMP-5 |
| COMP-5 |
||
| Diagnostic |
| Diagnostic array; <code>SQLERRD(3)</code> = number of rows processed |
||
|- |
|- |
||
| 05 |
|||
| <code>SQLWARN</code> |
| <code>SQLWARN</code> |
||
| 05 |
|||
| — |
| — |
||
| — |
| — |
||
| Warning flags group (not used) |
| Warning flags group (not used in this application) |
||
|- |
|||
| <code>SQLWARN0</code>–<code>SQLWARN7</code> |
|||
| 10 |
|||
| X(1) |
|||
| DISPLAY |
|||
| Individual warning flags |
|||
|- |
|- |
||
| 05 |
|||
| <code>SQLSTATE</code> |
| <code>SQLSTATE</code> |
||
| <code>X(5)</code> |
|||
| 05 |
|||
| X(5) |
|||
| DISPLAY |
| DISPLAY |
||
| ANSI SQL state code |
| ISO/ANSI SQL state code (5-char string) |
||
|} |
|||
'''SQLCODE reference (PostgreSQL / GixSQL):''' |
|||
{| |
|||
! Value |
|||
! Meaning |
|||
|- |
|||
| 0 |
|||
| Statement succeeded |
|||
|- |
|||
| +100 |
|||
| No rows found (SELECT returned empty, cursor exhausted) |
|||
|- |
|||
| negative |
|||
| Database error — see <code>SQLERRMC</code> for description |
|||
|} |
|} |
||
| Line 508: | Line 632: | ||
----- |
----- |
||
<span id=" |
<span id="working-storage-variables"></span> |
||
== |
== 2. Working-Storage Variables == |
||
<span id="primesmain"></span> |
|||
=== 2.1 primesmain === |
|||
<blockquote>'''Source:''' <code>primesmain.cbl</code> WORKING-STORAGE SECTION<br /> |
|||
'''Copybooks included:''' <code>primes-session</code> · <code>primes-ui</code> |
|||
</blockquote> |
|||
{| |
{| |
||
!width=" |
!width="20%"| Name |
||
!width=" |
!width="20%"| PIC |
||
!width=" |
!width="20%"| Usage |
||
!width=" |
!width="20%"| Initial |
||
!width=" |
!width="20%"| Description |
||
!width="16%"| Description |
|||
|- |
|- |
||
| <code>filler</code> |
| <code>filler</code> |
||
| <code>X(32)</code> |
|||
| 01 |
|||
| X(32) VALUE “Start WS primesmain” |
|||
| DISPLAY |
| DISPLAY |
||
| primesmain |
| <code>"Start WS primesmain"</code> |
||
| Debug marker |
| Debug marker — locates WS start in memory dumps |
||
|- |
|- |
||
| <code>commandline-args</code> |
| <code>commandline-args</code> |
||
| <code>X(32)</code> |
|||
| 01 |
|||
| X(32) |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| primesmain.cbl |
|||
| Command-line argument |
| Command-line argument from <code>ACCEPT … FROM COMMAND-LINE</code> |
||
|- |
|- |
||
| |
| <code>execute-generate</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"generate"</code> |
|||
| primesmain.cbl |
|||
| |
| True when commandline-args = “generate” |
||
|- |
|- |
||
| |
| <code>execute-report</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| — |
| — |
||
| <code>"report"</code> |
|||
| primesmain.cbl |
|||
| |
| True when commandline-args = “report” |
||
|- |
|- |
||
| <code>primes-session</code> |
| <code>primes-session</code> |
||
| 01 |
|||
| (group) |
| (group) |
||
| — |
| — |
||
| |
| — |
||
| COPY primes-session — see [[#11-primes-session|§1.1]] |
|||
| See §2 |
|||
|- |
|- |
||
| <code>primes-ui</code> |
| <code>primes-ui</code> |
||
| 01 |
|||
| (group) |
| (group) |
||
| — |
| — |
||
| |
| — |
||
| COPY primes-ui — see [[#13-primes-ui|§1.3]] |
|||
| See §4 |
|||
|} |
|} |
||
| Line 565: | Line 688: | ||
----- |
----- |
||
<span id=" |
<span id="primesgen"></span> |
||
== |
=== 2.2 primesgen === |
||
<blockquote>'''Source:''' <code>primesgen.cbl</code> WORKING-STORAGE SECTION<br /> |
|||
'''Copybooks included:''' <code>primes-ui</code> (WS) · <code>primes-dal</code> (WS) · <code>primes-session</code> (LINKAGE) |
|||
</blockquote> |
|||
'''Print control group (unused — print handled by primesui):''' |
|||
{| |
{| |
||
!width=" |
!width="25%"| Name |
||
!width=" |
!width="25%"| PIC |
||
!width=" |
!width="25%"| Initial |
||
!width=" |
!width="25%"| Description |
||
!width="20%"| Description |
|||
|- |
|||
| <code>filler</code> |
|||
| 01 |
|||
| X(32) VALUE “Start WS primesgen” |
|||
| DISPLAY |
|||
| Debug WS marker |
|||
|- |
|- |
||
| <code>file-buffer</code> |
| <code>file-buffer</code> |
||
| <code>X(132)</code> |
|||
| 01 |
|||
| X(132) |
|||
| DISPLAY |
|||
| FD record area for fprinter (declared but file not opened in primesgen) |
|||
|- |
|||
| <code>printer</code> |
|||
| 01 |
|||
| — |
| — |
||
| FD record area for fprinter — declared but file never opened here ⚠️ |
|||
| — |
|||
| Print control group (unused in primesgen; print handled by primesui) |
|||
|- |
|- |
||
| <code>print-buffer</code> |
| <code>print-buffer</code> |
||
| <code>X(132)</code> |
|||
| 03 |
|||
| |
| — |
||
| Working print line buffer |
|||
| DISPLAY |
|||
| Line buffer |
|||
|- |
|- |
||
| <code>line-number</code> |
| <code>line-number</code> |
||
| <code>99</code> |
|||
| 03 |
|||
| |
| 99 |
||
| Current line within page |
|||
| DISPLAY |
|||
| Current line counter |
|||
|- |
|- |
||
| <code>page-number</code> |
| <code>page-number</code> |
||
| <code>9999</code> |
|||
| 03 |
|||
| 0 |
|||
| 9(4) VALUE ZERO |
|||
| Current page number |
|||
| DISPLAY |
|||
|} |
|||
| Current page counter |
|||
'''Sieve control group (01 <code>primes</code>, local to primesgen):''' |
|||
{| |
|||
!width="25%"| Name |
|||
!width="25%"| PIC |
|||
!width="25%"| Initial |
|||
!width="25%"| Description |
|||
|- |
|- |
||
| <code> |
| <code>gen-methods</code> |
||
| <code>X(32)</code> |
|||
| 01 |
|||
| 9(9) |
|||
| DISPLAY |
|||
| Quotient from DIVIDE in sieve loop |
|||
|- |
|||
| <code>primes</code> |
|||
| 01 |
|||
| — |
| — |
||
| Verb for the local <code>primes</code> group calls to primes.cbl |
|||
| — |
|||
| Local sieve control group (mirrors primes-dal structure) |
|||
|- |
|- |
||
| <code> |
| <code>query-process</code> (88) |
||
| 03 |
|||
| X(32) |
|||
| DISPLAY |
|||
| Method verb for internal DAL calls |
|||
|- |
|||
| — <code>query-process</code> |
|||
| 88 |
|||
| — |
| — |
||
| <code>"query"</code> |
|||
| — |
|||
| Internal: query |
|||
| VALUE “query” |
|||
|- |
|- |
||
| |
| <code>start-process</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| <code>"start"</code> |
|||
| — |
|||
| Internal: start |
|||
| VALUE “start” |
|||
|- |
|- |
||
| |
| <code>next-divider</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| <code>"get"</code> |
|||
| — |
|||
| Internal: fetch next divider |
|||
| VALUE “get” |
|||
|- |
|- |
||
| |
| <code>write-prime</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| <code>"put"</code> |
|||
| — |
|||
| Internal: write prime |
|||
| VALUE “put” |
|||
|- |
|- |
||
| |
| <code>stop-process</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| <code>"stop"</code> |
|||
| — |
|||
| Internal: stop |
|||
| VALUE “stop” |
|||
|- |
|- |
||
| <code>primes-result</code> |
| <code>primes-result</code> |
||
| <code>9(2)</code> |
|||
| 03 |
|||
| 0 |
|||
| 9(2) VALUE ZERO |
|||
| Internal result code for local DAL calls |
|||
| DISPLAY |
|||
| Result of sieve DAL call |
|||
|- |
|- |
||
| |
| <code>init-primes-ok</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| |
| 1 |
||
| Initialisation succeeded |
|||
| VALUE 1 |
|||
|- |
|- |
||
| |
| <code>first-divider-ok</code> (88) |
||
| 88 |
|||
| — |
|||
| — |
| — |
||
| |
| 2 |
||
| First divisor retrieved |
|||
|- |
|- |
||
| |
| <code>next-divider-ok</code> (88) |
||
| 88 |
|||
| — |
|||
| — |
| — |
||
| |
| 3 |
||
| Next divisor retrieved |
|||
|- |
|- |
||
| <code>test-number</code> |
| <code>test-number</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| |
| — |
||
| '''Current candidate being tested for primality''' |
|||
| DISPLAY |
|||
| Current candidate being tested for primality |
|||
|- |
|- |
||
| <code>test-number-sqr</code> |
| <code>test-number-sqr</code> |
||
| <code>9(9)V9(9)</code> |
|||
| 03 |
|||
| — |
|||
| 9(9)V9(9) |
|||
| Square root of <code>test-number</code> — upper bound for divisors |
|||
| DISPLAY |
|||
| Square root of test-number (decimal) |
|||
|- |
|- |
||
| <code>test-divider</code> |
| <code>test-divider</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| |
| — |
||
| Current trial divisor (prime fetched from DB) |
|||
| DISPLAY |
|||
| Current trial divisor fetched from DB |
|||
|- |
|- |
||
| <code>test-rest</code> |
| <code>test-rest</code> |
||
| <code>9(9)V9(9)</code> |
|||
| 03 |
|||
| — |
|||
| 9(9)V9(9) |
|||
| Remainder: <code>test-number MOD test-divider</code> |
|||
| DISPLAY |
|||
| Remainder from DIVIDE |
|||
|- |
|- |
||
| <code>old-test-number</code> |
| <code>old-test-number</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| |
| — |
||
| Previous candidate — diagnostic use only, not active |
|||
| DISPLAY |
|||
| Previous test-number (diagnostic / unused) |
|||
|- |
|- |
||
| <code>old-ident</code> |
| <code>old-ident</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| |
| — |
||
| DB <code>ident</code> of the most recently fetched divisor |
|||
| DISPLAY |
|||
| ident of the last divider fetched; incremented before next fetch |
|||
|- |
|- |
||
| <code>new-ident</code> |
| <code>new-ident</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| 9(9) |
|||
| DISPLAY |
|||
| old-ident + 1; used as key in SELECT to get next divider |
|||
|- |
|||
| <code>primes-ui</code> |
|||
| 01 |
|||
| (group) |
|||
| — |
| — |
||
| <code>old-ident + 1</code> — used as key for the next divider SELECT |
|||
| COPY — see §4 |
|||
|- |
|||
| <code>primes-dal</code> |
|||
| 01 |
|||
| (group) |
|||
| — |
|||
| COPY — see §3 |
|||
|} |
|} |
||
''' |
'''Other:''' |
||
{| |
{| |
||
! Name |
!width="25%"| Name |
||
!width="25%"| PIC |
|||
! Source |
|||
!width="25%"| Initial |
|||
! Description |
|||
!width="25%"| Description |
|||
|- |
|- |
||
| <code> |
| <code>test-quot</code> |
||
| <code>9(9)</code> |
|||
| COPY primes-session |
|||
| — |
|||
| Passed in by primesmain |
|||
| Integer quotient from <code>DIVIDE test-number BY test-divider</code> |
|||
|} |
|} |
||
| Line 753: | Line 834: | ||
----- |
----- |
||
<span id=" |
<span id="primes-dal-1"></span> |
||
== |
=== 2.3 primes (DAL) === |
||
<blockquote>'''Source:''' <code>primes.cbl</code> WORKING-STORAGE SECTION<br /> |
|||
'''Copybooks included:''' <code>primes-ui</code> (WS) · <code>SQLCA</code> (via EXEC SQL INCLUDE) · <code>primes-table</code> (via EXEC SQL INCLUDE) · <code>primes-dal</code> (LINKAGE) |
|||
</blockquote> |
|||
'''Database credentials:''' |
|||
{| |
{| |
||
!width=" |
!width="25%"| Name |
||
!width=" |
!width="25%"| PIC |
||
!width=" |
!width="25%"| Initial |
||
!width=" |
!width="25%"| Description |
||
!width="20%"| Description |
|||
|- |
|||
| <code>filler</code> |
|||
| 01 |
|||
| X(32) VALUE “Start WS primes” |
|||
| DISPLAY |
|||
| Debug WS marker |
|||
|- |
|- |
||
| <code>DATASRC</code> |
| <code>DATASRC</code> |
||
| <code>X(64)</code> |
|||
| 01 |
|||
| |
| <code>"pgsql://localhost:5432/primes&default_schema=primes"</code> |
||
| GixSQL connection string ⚠️ hard-coded |
|||
| DISPLAY |
|||
| GixSQL connection string |
|||
|- |
|- |
||
| <code>DBUSR</code> |
| <code>DBUSR</code> |
||
| <code>X(64)</code> |
|||
| 01 |
|||
| <code>"primes_user"</code> |
|||
| X(64) VALUE “primes_user” |
|||
| Database user name ⚠️ hard-coded |
|||
| DISPLAY |
|||
| Database user name |
|||
|- |
|- |
||
| <code>DBPWD</code> |
| <code>DBPWD</code> |
||
| <code>X(64)</code> |
|||
| 01 |
|||
| <code>"pr1mes_user"</code> |
|||
| X(64) VALUE “pr1mes_user” |
|||
| Database password ⚠️ hard-coded in plain text |
|||
| DISPLAY |
|||
| Database password (plain-text) |
|||
|- |
|- |
||
| <code>CUR-STEP</code> |
| <code>CUR-STEP</code> |
||
| <code>X(16)</code> |
|||
| 01 |
|||
| |
| — |
||
| Diagnostic step label (<code>"CONNECT"</code> / <code>"DISCONNECT"</code>) |
|||
| DISPLAY |
|||
|} |
|||
| Diagnostic: current SQL step (“CONNECT” / “DISCONNECT”) |
|||
'''Cursor fetch buffer:''' |
|||
{| |
|||
!width="25%"| Name |
|||
!width="25%"| PIC |
|||
!width="25%"| Usage |
|||
!width="25%"| Description |
|||
|- |
|- |
||
| <code>primes-row</code> |
| <code>primes-row</code> |
||
| |
| (group) |
||
| — |
| — |
||
| Target group for <code>FETCH primescursor INTO :primes-row</code> |
|||
| — |
|||
| FETCH target for cursor |
|||
|- |
|- |
||
| <code>r-ident</code> |
| <code>r-ident</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| 9(9) |
|||
| COMP-3 |
| COMP-3 |
||
| Fetched |
| Fetched row identity value |
||
|- |
|- |
||
| <code>r-prime</code> |
| <code>r-prime</code> |
||
| <code>9(9)</code> |
|||
| 03 |
|||
| 9(9) |
|||
| COMP-3 |
| COMP-3 |
||
| Fetched prime value |
| Fetched prime value |
||
|} |
|||
'''Unused declarations:''' |
|||
{| |
|||
! Name |
|||
! PIC |
|||
! Note |
|||
|- |
|- |
||
| <code>prime-count</code> |
| <code>prime-count</code> |
||
| <code>9(9)</code> |
|||
| 01 |
|||
| Declared; not written to in current flow |
|||
| 9(9) |
|||
| DISPLAY |
|||
| (Unused in current flow) |
|||
|- |
|- |
||
| <code>prime_seq</code> |
| <code>prime_seq</code> |
||
| <code>9(9)</code> |
|||
| 01 |
|||
| Declared; not written to |
|||
| 9(9) |
|||
| DISPLAY |
|||
| (Unused in current flow) |
|||
|- |
|- |
||
| <code>divider</code> |
| <code>divider</code> |
||
| <code>9(9)</code> |
|||
| 01 |
|||
| Declared; not written to |
|||
| 9(9) |
|||
| DISPLAY |
|||
| (Unused in current flow) |
|||
|- |
|||
| <code>primes</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| Local copy of sieve control (mirrors primes-dal; used for internal paragraphs) |
|||
|- |
|||
| <code>SQLCA</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| COPY SQLCA — see §7 |
|||
|- |
|||
| <code>primes-table</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| EXEC SQL INCLUDE primes-table — see §5 |
|||
|- |
|||
| <code>primes-ui</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| COPY primes-ui — see §4 |
|||
|} |
|} |
||
'''Local sieve control group (01 <code>primes</code>, mirrors primesgen layout):''' |
|||
'''Linkage section:''' |
|||
Mirrors the <code>01 primes</code> group in primesgen. Contains <code>test-divider</code>, <code>old-ident</code>, <code>new-ident</code> etc., used internally by <code>r81-get-next-divider</code>. See [[#22-primesgen|§2.2]] for field descriptions. |
|||
{| |
|||
! Name |
|||
! Source |
|||
! Description |
|||
|- |
|||
| <code>primes-dal</code> |
|||
| COPY primes-dal |
|||
| Passed in by primesgen |
|||
|} |
|||
----- |
----- |
||
<span id=" |
<span id="primesui"></span> |
||
== |
=== 2.4 primesui === |
||
<blockquote>'''Source:''' <code>primesui.cbl</code> WORKING-STORAGE SECTION<br /> |
|||
'''Copybooks included:''' <code>primes-ui</code> (LINKAGE) |
|||
</blockquote> |
|||
'''Print row buffer:''' |
|||
{| |
{| |
||
!width="20%"| Name |
!width="20%"| Name |
||
!width="20%"| |
!width="20%"| PIC |
||
!width="20%"| Picture |
|||
!width="20%"| Usage |
!width="20%"| Usage |
||
!width="20%"| Initial |
|||
!width="20%"| Description |
!width="20%"| Description |
||
|- |
|- |
||
| <code> |
| <code>primes-table</code> (01) |
||
| 01 |
|||
| X(32) VALUE “start ws primesui” |
|||
| DISPLAY |
|||
| Debug WS marker |
|||
|- |
|||
| <code>primes-table</code> |
|||
| 01 |
|||
| — |
| — |
||
| — |
| — |
||
| — |
|||
| 6-column print accumulator (OCCURS 6) |
|||
| 6-element row accumulator |
|||
|- |
|- |
||
| <code>primes-cel</code> |
| <code>primes-cel</code> |
||
| OCCURS 6 INDEXED <code>primes-idx</code> |
|||
| 03 |
|||
| OCCURS 6 INDEXED primes-idx |
|||
| — |
| — |
||
| — |
|||
| One cell per prime entry on a print line |
|||
| One cell = one prime entry in the output line |
|||
|- |
|- |
||
| <code>t-ident</code> |
| <code>t-ident</code> |
||
| <code>Z(9)</code> |
|||
| 05 |
|||
| Z(9) |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Sequence number, zero-suppressed |
|||
| Zero-suppressed sequence number for this cell |
|||
|- |
|- |
||
| filler |
| filler |
||
| <code>X(2)</code> |
|||
| 05 |
|||
| X(2) |
|||
| DISPLAY |
| DISPLAY |
||
| |
| spaces |
||
| Column separator |
|||
|- |
|- |
||
| <code>t-prime</code> |
| <code>t-prime</code> |
||
| <code>Z(9)</code> |
|||
| 05 |
|||
| Z(9) |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Prime value, zero-suppressed |
|||
| Zero-suppressed prime value for this cell |
|||
|- |
|- |
||
| filler |
| filler |
||
| <code>X(2)</code> |
|||
| 05 |
|||
| X(2) |
|||
| DISPLAY |
| DISPLAY |
||
| |
| spaces |
||
| Column separator |
|||
|- |
|- |
||
| <code> |
| <code>primes-idx</code> |
||
| |
| INDEX |
||
| — |
| — |
||
| — |
| — |
||
| Current cell position (1–6); set by <code>SET primes-idx</code> |
|||
| Heading row (OCCURS 6) — “Sequence Prime” × 6 |
|||
|} |
|||
'''Column header:''' |
|||
{| |
|||
!width="33%"| Name |
|||
!width="33%"| PIC |
|||
!width="33%"| Description |
|||
|- |
|- |
||
| <code> |
| <code>table-header</code> (01) |
||
| OCCURS 6 |
|||
| 01 |
|||
| Static header row — <code>"Sequence Prime "</code> repeated 6 times |
|||
| — |
|||
|} |
|||
| — |
|||
| Print control group |
|||
'''Print control:''' |
|||
{| |
|||
!width="20%"| Name |
|||
!width="20%"| PIC |
|||
!width="20%"| Usage |
|||
!width="20%"| Initial |
|||
!width="20%"| Description |
|||
|- |
|- |
||
| <code>print-buffer</code> |
| <code>print-buffer</code> |
||
| <code>X(132)</code> |
|||
| 03 |
|||
| X(132) |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| Current line being built |
|||
| Working buffer written to <code>fprinter</code> |
|||
|- |
|- |
||
| <code>primes-prt-status</code> |
| <code>primes-prt-status</code> |
||
| <code>X(2)</code> |
|||
| 03 |
|||
| X(2) |
|||
| DISPLAY |
| DISPLAY |
||
| — |
|||
| File-status code for fprinter |
|||
| File status from last <code>fprinter</code> operation |
|||
|- |
|- |
||
| <code>page-number</code> |
| <code>page-number</code> |
||
| <code>9(4)</code> |
|||
| 03 |
|||
| 9(4) VALUE 1 |
|||
| DISPLAY |
| DISPLAY |
||
| 1 |
|||
| Current page number |
| Current page number |
||
|- |
|- |
||
| <code>print-new-page</code> |
| <code>print-new-page</code> |
||
| <code>9</code> |
|||
| 03 |
|||
| 9 VALUE 1 |
|||
| DISPLAY |
| DISPLAY |
||
| 1 |
|||
| Flag: 1 = new page needed |
|||
| New-page flag — 1 = heading must be written |
|||
|- |
|- |
||
| |
| <code>new-page</code> (88) |
||
| 88 |
|||
| — |
| — |
||
| — |
| — |
||
| |
| 1 |
||
| True when <code>print-new-page = 1</code> |
|||
|} |
|||
'''Static strings:''' |
|||
{| |
|||
!width="25%"| Name |
|||
!width="25%"| PIC |
|||
!width="25%"| Value |
|||
!width="25%"| Description |
|||
|- |
|- |
||
| <code>primes-heading</code> |
| <code>primes-heading</code> |
||
| <code>X(118)</code> |
|||
| 01 |
|||
| <code>"primes overview"</code> |
|||
| X(118) VALUE “primes overview” |
|||
| Left-justified page heading text |
|||
| DISPLAY |
|||
| Page heading text |
|||
|- |
|- |
||
| <code>primes-footing</code> |
| <code>primes-footing</code> |
||
| |
| (group) |
||
| — |
| — |
||
| Page footer group |
|||
| — |
|||
| Page footing group |
|||
|- |
|- |
||
| filler |
| filler |
||
| <code>X(118)</code> |
|||
| 03 |
|||
| |
| SPACE |
||
| Left padding of footer |
|||
| DISPLAY |
|||
| Left padding |
|||
|- |
|- |
||
| filler |
| filler |
||
| <code>X(6)</code> |
|||
| 03 |
|||
| <code>"page: "</code> |
|||
| X(6) VALUE “page:” |
|||
| Footer label |
|||
| DISPLAY |
|||
| Label |
|||
|- |
|- |
||
| <code>f-page-number</code> |
| <code>f-page-number</code> |
||
| <code>Z(3)9</code> |
|||
| 03 |
|||
| 1 |
|||
| Z(3)9 VALUE 1 |
|||
| Formatted page number (zero-suppressed 4-digit) |
|||
| DISPLAY |
|||
| Formatted page number |
|||
|- |
|||
| <code>primes-line</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| (Declared but not used in current flow) |
|||
|- |
|||
| <code>primes-total</code> |
|||
| 01 |
|||
| — |
|||
| — |
|||
| (Declared but not used in current flow) |
|||
|- |
|||
| <code>primes-count</code> |
|||
| 03 |
|||
| 9(8) |
|||
| DISPLAY |
|||
| (Declared but not used in current flow) |
|||
|} |
|} |
||
''' |
'''Unused:''' |
||
{| |
{| |
||
! Name |
! Name |
||
! |
! PIC |
||
! Note |
|||
! Description |
|||
|- |
|- |
||
| <code>primes- |
| <code>primes-line</code> |
||
| <code>X(132)</code> |
|||
| COPY primes-ui |
|||
| Declared; not written to in current flow |
|||
| Passed in by all callers |
|||
|- |
|||
| <code>primes-count</code> |
|||
| <code>9(8)</code> |
|||
| Declared; not used |
|||
|} |
|} |
||
| Line 1,028: | Line 1,084: | ||
<span id="database-objects"></span> |
<span id="database-objects"></span> |
||
== |
== 3. Database Objects == |
||
<span id="schema-primes"></span> |
|||
=== 3.1 Schema <code>primes</code> === |
|||
{| |
{| |
||
!width=" |
!width="25%"| Object |
||
!width=" |
!width="25%"| Type |
||
!width=" |
!width="25%"| Owner |
||
!width=" |
!width="25%"| Description |
||
!width="20%"| Definition |
|||
|- |
|- |
||
| <code>primes</code> |
| <code>primes</code> |
||
| |
| SCHEMA |
||
| <code>primes_user</code> |
|||
| — |
|||
| Container schema for all application objects |
|||
| primes_user |
|||
| Container schema |
|||
|- |
|- |
||
| <code>asc_ident</code> |
| <code>asc_ident</code> |
||
| SEQUENCE |
|||
| Sequence |
|||
| <code>primes_user</code> |
|||
| primes |
|||
| Auto-incrementing identity for <code>primes.ident</code> |
|||
| primes_user |
|||
| INTEGER, START 1, INCREMENT 1 |
|||
|- |
|- |
||
| <code>primes</code> |
| <code>primes.primes</code> |
||
| |
| TABLE |
||
| <code>primes_user</code> |
|||
| primes |
|||
| The prime numbers store |
|||
| primes_user |
|||
| See below |
|||
|- |
|||
| <code>primescursor</code> |
|||
| Cursor |
|||
| runtime |
|||
| — |
|||
| DECLARE … CURSOR FOR SELECT * FROM primes |
|||
|} |
|} |
||
----- |
|||
<span id="table-primes.primes"></span> |
<span id="table-primes.primes"></span> |
||
=== Table |
=== 3.2 Table <code>primes.primes</code> === |
||
<blockquote>'''DDL source:''' <code>primes_schema.sql</code> |
|||
</blockquote> |
|||
<syntaxhighlight lang="sql">CREATE TABLE primes.primes ( |
|||
ident integer DEFAULT nextval('primes.asc_ident'::regclass), |
|||
prime integer |
|||
);</syntaxhighlight> |
|||
{| |
{| |
||
!width="20%"| Column |
!width="20%"| Column |
||
!width="20%"| |
!width="20%"| Data type |
||
!width="20%"| Nullable |
!width="20%"| Nullable |
||
!width="20%"| Default |
!width="20%"| Default |
||
| Line 1,075: | Line 1,133: | ||
| INTEGER |
| INTEGER |
||
| YES |
| YES |
||
| nextval( |
| <code>nextval('primes.asc_ident')</code> |
||
| Auto-assigned insertion sequence |
| Auto-assigned insertion sequence; acts as primary key but has no formal PK constraint |
||
|- |
|- |
||
| <code>prime</code> |
| <code>prime</code> |
||
| Line 1,082: | Line 1,140: | ||
| YES |
| YES |
||
| — |
| — |
||
| |
| The prime number value |
||
|} |
|} |
||
<blockquote>⚠️ No PRIMARY KEY, UNIQUE constraint, or index is defined on either column. The <code>ident</code> column is the key used by <code>r81-get-next-divider</code> (<code>SELECT prime WHERE ident = :new-ident</code>). Without an index, this is a sequential scan. See [[Technical-Specification#7-known-technical-issues|Technical Specification — Defect T5]] (performance concern). |
|||
</blockquote> |
|||
----- |
|||
<span id="sequence-primes.asc_ident"></span> |
|||
=== 3.3 Sequence <code>primes.asc_ident</code> === |
|||
{| |
|||
! Attribute |
|||
! Value |
|||
|- |
|||
| Data type |
|||
| INTEGER |
|||
|- |
|||
| Start value |
|||
| 1 |
|||
|- |
|||
| Increment |
|||
| 1 |
|||
|- |
|||
| Minimum |
|||
| 1 (default) |
|||
|- |
|||
| Maximum |
|||
| 2,147,483,647 (INTEGER max) |
|||
|- |
|||
| Cache |
|||
| 1 |
|||
|- |
|||
| Cycle |
|||
| No |
|||
|} |
|||
----- |
|||
<span id="cursor-primescursor-runtime"></span> |
|||
=== 3.4 Cursor <code>primescursor</code> (runtime) === |
|||
<blockquote>Declared at compile time in <code>primes.cbl</code>. Opened and used only in the '''report path'''. |
|||
</blockquote> |
|||
{| |
|||
!width="50%"| Attribute |
|||
!width="50%"| Value |
|||
|- |
|||
| Declaration |
|||
| <code>DECLARE primescursor CURSOR FOR SELECT * FROM primes</code> |
|||
|- |
|||
| Connection alias |
|||
| <code>primes</code> |
|||
|- |
|||
| Declared at |
|||
| Compile time in <code>primes.cbl</code> |
|||
|- |
|||
| Transaction |
|||
| Opened inside <code>START TRANSACTION</code> in <code>s01-cursor</code> |
|||
|- |
|||
| Opened at |
|||
| <code>s01-cursor</code> paragraph (<code>EXEC SQL OPEN primescursor</code>) |
|||
|- |
|||
| Fetch target |
|||
| <code>primes-row</code> group (<code>r-ident</code>, <code>r-prime</code>) — COMP-3 fields |
|||
|- |
|||
| Close |
|||
| Not explicit; closed implicitly when <code>CONNECT RESET primes</code> is issued |
|||
|} |
|||
<blockquote>⚠️ <code>SELECT * FROM primes</code> is used. Best practice is to name columns explicitly (<code>SELECT ident, prime FROM primes</code>) to guard against schema changes. The pre-compiler listing (<code>primes_cbsql.out</code>) shows this was expanded from a <code>SELECT ident, prime</code> form in an earlier version. |
|||
</blockquote> |
|||
----- |
|||
'''← [[Technical-Specification|Technical Specification]]''' | [[Flow-Diagrams|Flow Diagrams →]] |
|||
Latest revision as of 22:57, 24 March 2026
Data Dictionary[edit]
Document ID: PGCBL-DDD-001 · Version: 1.0 · Status: Approved · Last updated: 2026-03-17
← Technical Specification | Flow Diagrams →
Contents[edit]
Conventions[edit]
| Symbol | Meaning |
|---|---|
PIC X(n)
|
Alphanumeric, n characters |
PIC 9(n)
|
Unsigned packed decimal display, n digits |
PIC S9(n)
|
Signed packed decimal display, n digits |
PIC 9(n)V9(m)
|
Unsigned numeric with m implied decimal places (no decimal point stored) |
PIC Z(n)
|
Zero-suppressed display numeric, n digits |
COMP-3
|
Packed-decimal binary storage (2 digits per byte + sign nibble) |
COMP-5
|
Native binary integer (platform word size) |
88
|
Condition-name — a boolean alias tested via IF <name> or WHEN <name>
|
—
|
Not applicable (group item or 88-level) |
| ⚠️ | Known issue or deviation from standard |
Level hierarchy used in this codebase:
01 Group root 03 Sub-group or elementary item 05 Nested elementary item 07 Doubly-nested elementary item 49 Special level for variable-length groups (SQLERRM in SQLCA) 88 Condition-name (under any level)
1. Control Blocks — Copybooks[edit]
1.1 primes-session[edit]
Source file:
primes-session.cpy
Included by:
primesmain.cbl(WORKING-STORAGE) ·primesgen.cbl(LINKAGE SECTION)
Purpose: Session-tier control block. primesmain setsmethods; primesgen reads it and setssession-result.
| Level | Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|---|
| 01 | primes-session
|
— | — | — | Root of session control block |
| 03 | methods
|
X(32)
|
DISPLAY | — | Method dispatch verb — set by primesmain before calling primesgen |
| 88 | report-primes
|
— | — | "report"
|
Run the cursor report path |
| 88 | generate-primes
|
— | — | "generate"
|
Run the sieve generation path |
| 88 | start-primes
|
— | — | "start"
|
Reserved — not used in current flow |
| 88 | stop-primes
|
— | — | "stop"
|
Reserved — not used in current flow |
| 88 | invalid-method
|
— | — | "bad"
|
Sentinel for unrecognised verb |
| 03 | session-result
|
9(2)
|
DISPLAY | 0 | Outcome code written by primesgen |
| 88 | session-method-ok
|
— | — | 0 | Operation succeeded |
| 88 | session-method-nok
|
— | — | 1 | Operation failed |
| 88 | session-method-eof
|
— | — | 9 | End of data (cursor exhausted) |
⚠️
session-method-eof(value 9) is never explicitly set in the current code. Fetch failure setssession-result = 1(nok), not 9. See Technical Specification — Defect T7.
1.2 primes-dal[edit]
Source file:
primes-dal.cpy
Included by:
primesgen.cbl(WORKING-STORAGE, caller) ·primes.cbl(LINKAGE SECTION, callee)
Purpose: DAL-tier control block. primesgen setsdal-methodsand reads backdal-resultandprimes-data.
| Level | Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|---|
| 01 | primes-dal
|
— | — | — | Root of DAL control block |
| 03 | dal-methods
|
X(32)
|
DISPLAY | — | Method dispatch verb |
| 88 | next-prime
|
— | — | "next-prime"
|
Fetch next row from open cursor |
| 88 | next-divider
|
— | — | "next-divider"
|
SELECT a prime by ident for use as trial divisor |
| 88 | write-prime
|
— | — | "write"
|
INSERT a confirmed prime into the table |
| 88 | db-cursor
|
— | — | "cursor"
|
START TRANSACTION and OPEN primescursor |
| 88 | db-connect
|
— | — | "connect"
|
Establish the PostgreSQL connection |
| 88 | db-disconnect
|
— | — | "disconnect"
|
Release the connection |
| 88 | invalid-method
|
— | — | "bad"
|
Sentinel for unrecognised verb |
| 03 | primes-data
|
— | — | — | Single-row data payload (one prime) |
| 05 | primes-sequence
|
9(9)
|
DISPLAY | — | Row identity (ident) of the fetched prime
|
| 05 | prime-number
|
9(9)
|
DISPLAY | — | The prime value itself |
| 03 | dal-result
|
9(2)
|
DISPLAY | 0 | Outcome code written by primes |
| 88 | dal-method-ok
|
— | — | 0 | Operation succeeded |
| 88 | dal-method-nok
|
— | — | 1 | Operation failed |
| 88 | dal-method-eof
|
— | — | 99 | Cursor exhausted (no more rows) |
1.3 primes-ui[edit]
Source file:
primes-ui.cpy
Included by: all four programs
Purpose: UI-tier control block. Any program setsui-methodsandprocess-message/u-primes, then calls primesui; primesui setsui-method-result.
| Level | Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|---|
| 01 | primes-ui
|
— | — | — | Root of UI control block |
| 03 | ui-methods
|
X(32)
|
DISPLAY | — | Method dispatch verb |
| 88 | write-ui
|
— | — | "write"
|
Add one prime row to the print buffer |
| 88 | message-ui
|
— | — | "log-message"
|
Write process-message to the console
|
| 88 | start-ui
|
— | — | "start"
|
Open primes.prt
|
| 88 | stop-ui
|
— | — | "stop"
|
Flush print buffer and close file |
| 03 | process-message
|
— | — | — | Structured 132-char console log record |
| 05 | program-name
|
X(20)
|
DISPLAY | — | Name of the calling program |
| 05 | program-line
|
— | — | — | Location within the calling program |
| 07 | program-paragraph
|
X(20)
|
DISPLAY | — | Name of the calling paragraph |
| 07 | program-message
|
X(92)
|
DISPLAY | — | Human-readable status or error text |
| 03 | u-primes
|
— | — | — | One prime row for the print writer |
| 05 | u-sequence
|
9(9)
|
DISPLAY | — | Sequence number (ident) to write to print buffer |
| 05 | u-number
|
9(9)
|
DISPLAY | — | Prime value to write to print buffer |
| 03 | ui-method-result
|
9(2)
|
DISPLAY | 0 | Outcome code written by primesui |
| 88 | ui-method-ok
|
— | — | 0 | Operation succeeded |
| 88 | ui-method-nok
|
— | — | 1 | Operation failed |
Console message layout (132 characters, left-to-right):
┌──────────────────────┬──────────────────────┬────────────────────────────────────────────────────────────────────────────────────────────┐ │ program-name (20) │ program-paragraph(20)│ program-message (92) │ └──────────────────────┴──────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────┘
1.4 primes-table — SQL Host Variable (character)[edit]
Source file:
primes-table.cpy
Included by:
primes.cblviaEXEC SQL INCLUDE primes-table END-EXEC
Purpose: Host variable layout for GixSQL to bind theprimes.primestable columns.
| Level | Name | PIC | Usage | Description |
|---|---|---|---|---|
| 01 | primes-table
|
— | — | Host variable group (character format) |
| 03 | ident
|
S9(9)
|
DISPLAY | Maps to primes.ident; signed for SQL compatibility
|
| 03 | prime
|
S9(9)
|
DISPLAY | Maps to primes.prime; signed for SQL compatibility
|
1.5 primes_table — SQL Host Variable (packed)[edit]
Source file:
primes_table.cpy
Included by:
primes.cbl(alternative layout)
Purpose: COMP-3 variant ofprimes-table. The underscore in both the filename and root name is a deviation from the project’s hyphen convention.
| Level | Name | PIC | Usage | Description |
|---|---|---|---|---|
| 01 | primes_table
|
— | — | Host variable group (COMP-3 format) |
| 03 | ident
|
S9(9)
|
COMP-3 | Row identity — packed decimal |
| 03 | prime
|
S9(9)
|
COMP-3 | Prime value — packed decimal |
⚠️ Two nearly identical copybooks exist.
primes-table.cpy(hyphens, DISPLAY) is used by the cursor FETCH target (primes-row). The canonical version should be designated and the other retired. See Technical Specification — Defect T6.
1.6 SQLCA — SQL Communications Area[edit]
Source file:
SQLCA.cpy
Included by:
primes.cblviaEXEC SQL INCLUDE SQLCA END-EXEC
Purpose: Standard GixSQL communications area. Updated after every SQL statement.
| Level | Name | PIC | Usage | Description |
|---|---|---|---|---|
| 01 | SQLCA
|
— | — | SQL communications area |
| 05 | SQLCAID
|
X(8)
|
DISPLAY | SQLCA identifier string |
| 05 | SQLCABC
|
S9(9)
|
COMP-5 | Byte length of SQLCA structure |
| 05 | SQLCODE
|
S9(9)
|
COMP-5 | SQL return code: 0=success · negative=error · +100=not found |
| 05 | SQLERRM
|
— | — | Error message group |
| 49 | SQLERRML
|
S9(4)
|
COMP-5 | Length of error message text |
| 49 | SQLERRMC
|
X(70)
|
DISPLAY | Error message text from the database engine |
| 05 | SQLERRP
|
X(8)
|
DISPLAY | Error procedure name (not used in this application) |
| 05 | SQLERRD
|
S9(9) OCCURS 6
|
COMP-5 | Diagnostic array; SQLERRD(3) = number of rows processed
|
| 05 | SQLWARN
|
— | — | Warning flags group (not used in this application) |
| 05 | SQLSTATE
|
X(5)
|
DISPLAY | ISO/ANSI SQL state code (5-char string) |
SQLCODE reference (PostgreSQL / GixSQL):
| Value | Meaning |
|---|---|
| 0 | Statement succeeded |
| +100 | No rows found (SELECT returned empty, cursor exhausted) |
| negative | Database error — see SQLERRMC for description
|
2. Working-Storage Variables[edit]
2.1 primesmain[edit]
Source:
primesmain.cblWORKING-STORAGE SECTION
Copybooks included:
primes-session·primes-ui
| Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|
filler
|
X(32)
|
DISPLAY | "Start WS primesmain"
|
Debug marker — locates WS start in memory dumps |
commandline-args
|
X(32)
|
DISPLAY | — | Command-line argument from ACCEPT … FROM COMMAND-LINE
|
execute-generate (88)
|
— | — | "generate"
|
True when commandline-args = “generate” |
execute-report (88)
|
— | — | "report"
|
True when commandline-args = “report” |
primes-session
|
(group) | — | — | COPY primes-session — see §1.1 |
primes-ui
|
(group) | — | — | COPY primes-ui — see §1.3 |
2.2 primesgen[edit]
Source:
primesgen.cblWORKING-STORAGE SECTION
Copybooks included:
primes-ui(WS) ·primes-dal(WS) ·primes-session(LINKAGE)
Print control group (unused — print handled by primesui):
| Name | PIC | Initial | Description |
|---|---|---|---|
file-buffer
|
X(132)
|
— | FD record area for fprinter — declared but file never opened here ⚠️ |
print-buffer
|
X(132)
|
— | Working print line buffer |
line-number
|
99
|
99 | Current line within page |
page-number
|
9999
|
0 | Current page number |
Sieve control group (01 primes, local to primesgen):
| Name | PIC | Initial | Description |
|---|---|---|---|
gen-methods
|
X(32)
|
— | Verb for the local primes group calls to primes.cbl
|
query-process (88)
|
— | "query"
|
Internal: query |
start-process (88)
|
— | "start"
|
Internal: start |
next-divider (88)
|
— | "get"
|
Internal: fetch next divider |
write-prime (88)
|
— | "put"
|
Internal: write prime |
stop-process (88)
|
— | "stop"
|
Internal: stop |
primes-result
|
9(2)
|
0 | Internal result code for local DAL calls |
init-primes-ok (88)
|
— | 1 | Initialisation succeeded |
first-divider-ok (88)
|
— | 2 | First divisor retrieved |
next-divider-ok (88)
|
— | 3 | Next divisor retrieved |
test-number
|
9(9)
|
— | Current candidate being tested for primality |
test-number-sqr
|
9(9)V9(9)
|
— | Square root of test-number — upper bound for divisors
|
test-divider
|
9(9)
|
— | Current trial divisor (prime fetched from DB) |
test-rest
|
9(9)V9(9)
|
— | Remainder: test-number MOD test-divider
|
old-test-number
|
9(9)
|
— | Previous candidate — diagnostic use only, not active |
old-ident
|
9(9)
|
— | DB ident of the most recently fetched divisor
|
new-ident
|
9(9)
|
— | old-ident + 1 — used as key for the next divider SELECT
|
Other:
| Name | PIC | Initial | Description |
|---|---|---|---|
test-quot
|
9(9)
|
— | Integer quotient from DIVIDE test-number BY test-divider
|
2.3 primes (DAL)[edit]
Source:
primes.cblWORKING-STORAGE SECTION
Copybooks included:
primes-ui(WS) ·SQLCA(via EXEC SQL INCLUDE) ·primes-table(via EXEC SQL INCLUDE) ·primes-dal(LINKAGE)
Database credentials:
| Name | PIC | Initial | Description |
|---|---|---|---|
DATASRC
|
X(64)
|
"pgsql://localhost:5432/primes&default_schema=primes"
|
GixSQL connection string ⚠️ hard-coded |
DBUSR
|
X(64)
|
"primes_user"
|
Database user name ⚠️ hard-coded |
DBPWD
|
X(64)
|
"pr1mes_user"
|
Database password ⚠️ hard-coded in plain text |
CUR-STEP
|
X(16)
|
— | Diagnostic step label ("CONNECT" / "DISCONNECT")
|
Cursor fetch buffer:
| Name | PIC | Usage | Description |
|---|---|---|---|
primes-row
|
(group) | — | Target group for FETCH primescursor INTO :primes-row
|
r-ident
|
9(9)
|
COMP-3 | Fetched row identity value |
r-prime
|
9(9)
|
COMP-3 | Fetched prime value |
Unused declarations:
| Name | PIC | Note |
|---|---|---|
prime-count
|
9(9)
|
Declared; not written to in current flow |
prime_seq
|
9(9)
|
Declared; not written to |
divider
|
9(9)
|
Declared; not written to |
Local sieve control group (01 primes, mirrors primesgen layout):
Mirrors the 01 primes group in primesgen. Contains test-divider, old-ident, new-ident etc., used internally by r81-get-next-divider. See §2.2 for field descriptions.
2.4 primesui[edit]
Source:
primesui.cblWORKING-STORAGE SECTION
Copybooks included:
primes-ui(LINKAGE)
Print row buffer:
| Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|
primes-table (01)
|
— | — | — | 6-element row accumulator |
primes-cel
|
OCCURS 6 INDEXED primes-idx
|
— | — | One cell = one prime entry in the output line |
t-ident
|
Z(9)
|
DISPLAY | — | Zero-suppressed sequence number for this cell |
| filler | X(2)
|
DISPLAY | spaces | Column separator |
t-prime
|
Z(9)
|
DISPLAY | — | Zero-suppressed prime value for this cell |
| filler | X(2)
|
DISPLAY | spaces | Column separator |
primes-idx
|
INDEX | — | — | Current cell position (1–6); set by SET primes-idx
|
Column header:
| Name | PIC | Description |
|---|---|---|
table-header (01)
|
OCCURS 6 | Static header row — "Sequence Prime " repeated 6 times
|
Print control:
| Name | PIC | Usage | Initial | Description |
|---|---|---|---|---|
print-buffer
|
X(132)
|
DISPLAY | — | Working buffer written to fprinter
|
primes-prt-status
|
X(2)
|
DISPLAY | — | File status from last fprinter operation
|
page-number
|
9(4)
|
DISPLAY | 1 | Current page number |
print-new-page
|
9
|
DISPLAY | 1 | New-page flag — 1 = heading must be written |
new-page (88)
|
— | — | 1 | True when print-new-page = 1
|
Static strings:
| Name | PIC | Value | Description |
|---|---|---|---|
primes-heading
|
X(118)
|
"primes overview"
|
Left-justified page heading text |
primes-footing
|
(group) | — | Page footer group |
| filler | X(118)
|
SPACE | Left padding of footer |
| filler | X(6)
|
"page: "
|
Footer label |
f-page-number
|
Z(3)9
|
1 | Formatted page number (zero-suppressed 4-digit) |
Unused:
| Name | PIC | Note |
|---|---|---|
primes-line
|
X(132)
|
Declared; not written to in current flow |
primes-count
|
9(8)
|
Declared; not used |
3. Database Objects[edit]
3.1 Schema primes[edit]
| Object | Type | Owner | Description |
|---|---|---|---|
primes
|
SCHEMA | primes_user
|
Container schema for all application objects |
asc_ident
|
SEQUENCE | primes_user
|
Auto-incrementing identity for primes.ident
|
primes.primes
|
TABLE | primes_user
|
The prime numbers store |
3.2 Table primes.primes[edit]
DDL source:
primes_schema.sql
<syntaxhighlight lang="sql">CREATE TABLE primes.primes (
ident integer DEFAULT nextval('primes.asc_ident'::regclass),
prime integer
);</syntaxhighlight>
| Column | Data type | Nullable | Default | Description |
|---|---|---|---|---|
ident
|
INTEGER | YES | nextval('primes.asc_ident')
|
Auto-assigned insertion sequence; acts as primary key but has no formal PK constraint |
prime
|
INTEGER | YES | — | The prime number value |
⚠️ No PRIMARY KEY, UNIQUE constraint, or index is defined on either column. The
identcolumn is the key used byr81-get-next-divider(SELECT prime WHERE ident = :new-ident). Without an index, this is a sequential scan. See Technical Specification — Defect T5 (performance concern).
3.3 Sequence primes.asc_ident[edit]
| Attribute | Value |
|---|---|
| Data type | INTEGER |
| Start value | 1 |
| Increment | 1 |
| Minimum | 1 (default) |
| Maximum | 2,147,483,647 (INTEGER max) |
| Cache | 1 |
| Cycle | No |
3.4 Cursor primescursor (runtime)[edit]
Declared at compile time in
primes.cbl. Opened and used only in the report path.
| Attribute | Value |
|---|---|
| Declaration | DECLARE primescursor CURSOR FOR SELECT * FROM primes
|
| Connection alias | primes
|
| Declared at | Compile time in primes.cbl
|
| Transaction | Opened inside START TRANSACTION in s01-cursor
|
| Opened at | s01-cursor paragraph (EXEC SQL OPEN primescursor)
|
| Fetch target | primes-row group (r-ident, r-prime) — COMP-3 fields
|
| Close | Not explicit; closed implicitly when CONNECT RESET primes is issued
|
⚠️
SELECT * FROM primesis used. Best practice is to name columns explicitly (SELECT ident, prime FROM primes) to guard against schema changes. The pre-compiler listing (primes_cbsql.out) shows this was expanded from aSELECT ident, primeform in an earlier version.