Editing
COBOL Std 8 Data Definition Rules
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!
== 8. Data Definition Rules == === 8.1 Numeric Usage === * Signed arithmetic fields must use the S prefix: <code>PIC S9(9)</code>. * Packed-decimal (COMP-3) is the preferred internal numeric type for arithmetic fields β smaller footprint and faster on most platforms. * Binary (COMP-5) for SQL Communications Area fields (SQLCODE etc.) to match GixSQL generated C types. * DISPLAY numeric only for print-output or host-variable character-format copybooks. {| class="wikitable" style="width:100%" ! Use Case !! Recommended PIC !! Notes |- | Integer counter || <code>S9(9) COMP-3</code> || Handles values to Β±999,999,999. |- | Currency / amount || <code>S9(9)V99 COMP-3</code> || Odd digit count for packed efficiency. |- | Square root / remainder || <code>9(9)V9(9) DISPLAY</code> || 18-digit decimal for precision comparisons. |- | DB identity / sequence || <code>S9(9) COMP-3</code> || Match PostgreSQL INTEGER type. |- | SQLCODE / SQLERRD || <code>S9(9) COMP-5</code> || Required by GixSQL SQLCA layout. |} === 8.2 88-Level Condition Names === * Define 88-level conditions for every significant state a field can hold; never test magic numbers directly in procedural code. * 88-level names must be self-documenting: <code>SW-END-OF-FILE</code> rather than <code>SW-FLAG-1</code>. * Comment the business meaning of each 88 at its definition. <syntaxhighlight lang="cobol"> 03 DAL-RESULT PIC 9(2) VALUE ZERO. *-- 0 = operation succeeded 88 DAL-METHOD-OK VALUE 0. *-- 1 = operation failed; caller should log and stop 88 DAL-METHOD-NOK VALUE 1. *-- 2 = end of data / not found; not an error 88 DAL-METHOD-EOF VALUE 2. </syntaxhighlight> === 8.3 Host Variable Copybooks === * SQL host variables must be defined in a dedicated copybook (suffix <code>-TAB</code>) included via <code>EXEC SQL INCLUDE</code>. * Do not define host variables inline in WORKING-STORAGE outside a designated include. * Character-format and packed-decimal versions are separate copybooks if both are needed; name them unambiguously (e.g. <code>PRIMES-TAB-PKD.cpy</code> vs <code>PRIMES-TAB.cpy</code>). ---- ---- ''[[Cobol programming standards|β Back to index]]''
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