× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You have a few options on each field.  Here's the three options
CREATE TABLE XFILE 
 (IFUTCOD CHAR (4 ), 
  NOPTCOD CHAR (6 ) NOT NULL, 
  IOPTCOD CHAR (6 ) NOT NULL WITH DEFAULT)
 RCDFMT XFILER 
IFUTCOD allows null
NOPTCOD will not allow null
IOPTCOD will not allow null but if nothing is passed will default it to 
blanks.

Like,

INSERT INTO ROB/JOEP (ifutcod) VALUES('A') 
Null values not allowed in column or variable *N.
Failed because NOPTCOD is NOT NULL and does not specify a default.

INSERT INTO ROB/JOEP (NOPTCOD) VALUES('A')
1 rows inserted in JOEP in ROB. 
worked fine because IFUTCOD allows a null.  And IOPTCOD got defaulted to 
blanks.

Problem with DDS created files.  DDS created files are built to allow crap 
in most fields.  Some legacy thing when people got off grunting, thumping 
their chest and writing batch programs that checked fields down to the 
byte level for data that is right.  Like the first COBOL program I wrote 
in a class - make sure a field that is supposed to be numeric, is.  DDS 
files are fast to write to, but slow to read from because they don't care 
what kind of data you write to them.  But they'll check the data quality 
on a read.  When you think about it, most of your data access is reading, 
right?
SQL created files check data on a write.  Not on a read.
Recently saw a classic example of this.
Compile this:
                R JOEPR
                  MYCHAR         5A
                  MYPACK         9P 2 
with CRTPF FILE(ROB/JOEP) SRCFILE(ROB/QDDSSRC)
Run this command:  CRTPF FILE(ROB/JOEP2) RCDLEN(10)
STRSQL
INSERT INTO ROB/JOEP2 VALUES('NOWISTHETI')

CREATE TABLE ROB/JOEP3 
(MYCHAR CHAR (5 ) NOT NULL WITH DEFAULT, 
 MYPACK DEC (9 , 2) NOT NULL WITH DEFAULT)
RCDFMT JOEP3R
(exit sql)

CPYF FROMFILE(JOEP2) TOFILE(JOEP) MBROPT(*ADD) FMTOPT(*NOCHK)
Notice:  Allowed crap into JOEP.  You have a packed decimal field with 
alpha characters in it.

But CPYF FROMFILE(JOEP2) TOFILE(JOEP3) MBROPT(*ADD) FMTOPT(*NOCHK)
Tells me to bugger off with CPF5035-Data mapping error on member JOEP3.

Now if I attempt to read the corrupted DDS created file with a simple 
RPGLE cycle program
     FJOEP      IP   E             DISK
     FQSYSPRT   O    F   80        PRINTER
     OQSYSPRT   D
     O                       MYCHAR
     O                                              ' '
     O                       MYPACK 
I will get RNQ0907-Decimal-data error occurred.

Verifying that DDS files check data integrity on read.  SQL created files 
check data integrity on write.


Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.