TheprecompilerdeterminesthebaseSQLTYPEand SQLLENofhostvariablesaccordingtothis table.Ifa hostvariableappears withanindicatorvariable,theSQLTYPEisthebase SQLTYPEplusone.
Table9.ILERPGdeclarationsmappedtotypicalSQLdatatypes
RPGdatatype RPGcoding SQLTYPEof hostvariable SQLLENofhost variable SQLdatatype Datastructure (withoutsubfields)
Table9.ILERPGdeclarationsmappedtotypicalSQLdatatypes (continued)
RPGdatatype RPGcoding SQLTYPEof hostvariable
SQLLENofhost variable
SQLdatatype
Zoneddata v DefinedonDefinition
specificationassubfield withdatatypeSorblank. v DefinedonDefinition
specificationwithdata typeS.
v DefinedonInput
specificationwithdata typeSorblank.
488 pinbyte1,sin byte2
NUMERIC(p,s)wherep isthenumberofdigits andsisthenumberof decimalplaces
Packeddata v DefinedonDefinition
specificationwithdecimal positions(pos69-70)not blank.
v
DefinedonDefinition
specificationsubfieldwith datatypeP.
v DefinedonDefinition
specificationwithdata typePorblank. v DefinedonInput
specificationwithdata typeP.
484 pinbyte1,sin byte2
DECIMAL(p,s)wherepis thenumberofdigitsands isthenumberofdecimal places
2-bytebinarywith zerodecimal positions
v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeBandbyte length2.
v
DefinedonDefinition
specificationwithdata typeBanddigitsfrom1 to4.
v DefinedonInput
specificationwithdata typeBandbytelength2
500 2 SMALLINT
4-bytebinarywith zerodecimal positions
v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeBandbyte length4.
v DefinedonDefinition
specificationwithdata typeBanddigitsfrom5 to9.
v DefinedonInput
specificationwithdata typeBandbytelength4.
Table9.ILERPGdeclarationsmappedtotypicalSQLdatatypes (continued)
RPGdatatype RPGcoding SQLTYPEof hostvariable
SQLLENofhost variable
SQLdatatype
2-byteinteger v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeIandbyte length2.
v DefinedonDefinition
specificationwithdata typeIanddigits5. v DefinedonInput
specificationwithdata typeIandbytelength2.
500 2 SMALLINT
4-byteinteger v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeIandbyte length4.
v DefinedonDefinition
specificationwithdata typeIanddigits10. v DefinedonInput
specificationwithdata typeIandbytelength4.
496 4 INTEGER
8-byteinteger v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeIandbyte length8.
v DefinedonDefinition
specificationwithdata typeIanddigits20. v DefinedonInput
specificationwithdata typeIandbytelength8.
492 8 BIGINT
shortfloat Datatype=F,length=4. 480 4 FLOAT(singleprecision) longfloat Datatype=F,length=8. 480 8 FLOAT(doubleprecision) Character Datatype=Aorblank,
decimalpositionsblank, lengthbetween1and32766.
452 n CHAR(n)wherenisthe
length Charactervarying
lengthgreaterthan 254
Datatype=Aorblank, decimalpositionsblank, VARYINGkeywordon Definitionspecificationor format*VARonInput specification. 448 n VARCHAR(n)wherenis thelength Charactervarying lengthbetween1 and254
Datatype=Aorblank, decimalpositionsblank, VARYINGkeywordon Definitionspecificationor format*VARonInput specification.
456 n VARCHAR(n)wherenis
Table9.ILERPGdeclarationsmappedtotypicalSQLdatatypes (continued)
RPGdatatype RPGcoding SQLTYPEof hostvariable
SQLLENofhost variable
SQLdatatype
graphic v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeGand byte-lengthb. v DefinedonDefinition
specificationwithdata typeGandlengthn. v DefinedonInput
specificationwithdata typeGandbyte-lengthb
468 m GRAPHIC(m)wherem=
norm=b/2
varyinggraphic v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeGand byte-lengthband VARYINGkeyword. v DefinedonDefinition
specificationwithdata typeGandlengthnand VARYINGkeyword. v DefinedonInput
specificationwithdata typeGandbyte-lengthb andformat*VAR.
464 m VARGRAPHIC(m)where
m=norm=(b-2)/2
UCS-2 v
DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeCand byte-lengthb. v DefinedonDefinition
specificationwithdata typeCandlengthn. v DefinedonInput
specificationwithdata typeCandbyte-lengthb.
468 m GRAPHIC(m)withCCSID
13488wherem=norm= b/2
varyingUCS-2 v DefinedonDefinition
specificationassubfield withfromandtopositions anddatatypeCand byte-lengthband VARYINGkeyword. v DefinedonDefinition
specificationwithdata typeCandlengthnand VARYINGkeyword. v DefinedonInput
specificationwithdata typeCandbyte-lengthb andformat*VAR.
464 m VARGRAPHIC(m)with
CCSID13488wherem=n orm=b/2
Table9.ILERPGdeclarationsmappedtotypicalSQLdatatypes (continued)
RPGdatatype RPGcoding SQLTYPEof hostvariable
SQLLENofhost variable
SQLdatatype
Date v DefinedonDefinition
specificationwithdata typeD,formatfand separatorsfromDATFMT keyword.
v DefinedonInput
specificationwithdata typeDandformatinpos 31-34,separatorinpos35.
384 n DATEDATFMT(f)
DATSEP(s)1
Time v DefinedonDefinition
specificationwithdata typeT,formatfand separatorsfromTIMFMT keyword.
v
DefinedonInput
specificationwithdata typeTandformatinpos 31-34,separatorinpos35.
388 n TIMETIMFMT(f)
TIMSEP(s)1
Timestamp DatatypeZ. 392 n TIMESTAMP
1
SQLcreatesthedate/timesubfieldusingtheDATE/TIMEformatspecifiedontheCRTSQLRPGIcommand.The conversiontothehostvariableDATE/TIMEformatoccurswhenthemappingisdonebetweenthehostvariables andtheSQL-generatedsubfields.
ThefollowingtablecanbeusedtodeterminetheRPG datatypethatisequivalenttoagivenSQLdata type.
Table10.SQLdatatypesmappedtotypicalRPGdeclarations
SQLdatatype RPGdatatype Notes
SMALLINT Definitionspecification.Iinposition 40,lengthmustbe5and0inposition 42.
OR
Definitionspecification.Binposition 40,lengthmustbe≤4and0in position42.
INTEGER Definitionspecification.Iinposition 40,lengthmustbe10and0in position42.
OR
Definitionspecification.Binposition 40,lengthmustbe≤9and≥5and0 inposition42.
BIGINT Definitionspecification.Iinposition 40,lengthmustbe20and0in position42.
Table10.SQLdatatypesmappedtotypicalRPGdeclarations (continued)
SQLdatatype RPGdatatype Notes
DECIMAL Definitionspecification.Pinposition 40orblankinposition40fora non-subfield,0through30inposition 41,42.
OR
Definedasnumericonnon-definition specification.
Maximumlengthof16(precision30) andmaximumscaleof30.
NUMERIC Definitionspecification.Sinposition 40orblankinposition40fora subfield,0through30inposition 41,42.
Maximumlengthof30(precision30) andmaximumscaleof30.
FLOAT(singleprecision) Definitionspecification.Finposition 40,lengthmustbe4.
FLOAT(doubleprecision) Definitionspecification.Finposition 40,lengthmustbe8.
CHAR(n) Definitionspecification.Aorblankin positions40andblanksinposition 41,42.
OR
Inputfielddefinedwithoutdecimal places.
OR
Calculationresultfielddefined withoutdecimalplaces.
ncanbefrom1to32766.
CHAR(n) Datastructurenamewithno
subfieldsinthedatastructure.
ncanbefrom1to32766. VARCHAR(n) Definitionspecification.Aorblankin
position40andVARYINGin positions44-80.
ncanbefrom1to32740.
CLOB Notsupported UseSQLTYPEkeywordtodeclarea
CLOB. GRAPHIC(n) Definitionspecification.Ginposition
40. OR
InputfielddefinedwithGinposition 36.
ncanbe1to16383.
VARGRAPHIC(n) Definitionspecification.Ginposition 40andVARYINGinpositions44-80.
ncanbefrom1to16370.
DBCLOB Notsupported UseSQLTYPEkeywordtodeclarea
DBCLOB.
BINARY Notsupported UseSQLTYPEkeywordtodeclarea
BINARY.
VARBINARY Notsupported UseSQLTYPEkeywordtodeclarea
Table10.SQLdatatypesmappedtotypicalRPGdeclarations (continued)
SQLdatatype RPGdatatype Notes
BLOB Notsupported UseSQLTYPEkeywordtodeclarea
BLOB.
DATE Acharacterfield
OR
DefinitionspecificationwithaDin position40.
OR
InputfielddefinedwithDinposition 36.
Iftheformatis*USA,*JIS,*EUR,or *ISO,thelengthmustbeatleast10.If theformatis*YMD,*DMY,or*MDY, thelengthmustbeatleast8.Ifthe formatis*JUL,thelengthmustbeat least6.
TIME Acharacterfield
OR
DefinitionspecificationwithaTin position40.
OR
InputfielddefinedwithTinposition 36.
Lengthmustbeatleast6;toinclude seconds,lengthmustbeatleast8.
TIMESTAMP Acharacterfield
OR
DefinitionspecificationwithaZin position40.
OR
InputfielddefinedwithZinposition 36.
Lengthmustbeatleast19;toinclude microseconds,lengthmustbeatleast 26.Iflengthislessthan26,truncation occursonthemicrosecondpart.
DATALINK Notsupported
ROWID Notsupported UseSQLTYPEkeywordtodeclarea
ROWID.