11. Impuesto sobre sociedades
11.3. Evolución en el Impuesto sobre Sociedades
TheSQLILERPG precompileronlyrecognizesasubsetof validILE RPGdeclarationsasvalidhost variabledeclarations.
MostvariablesdefinedinILERPG canbe usedinSQLstatements.Apartiallisting ofvariablesthatare notsupportedincludesthefollowing:
v Unsignedintegers v Pointer v Tables v UDATE v UDAY v UMONTH v UYEAR v Look-aheadfields v Namedconstants
v Multipledimensionarrays
v Definitionsrequiringtheresolutionof%SIZEor%ELEM
v DefinitionsrequiringtheresolutionofconstantsunlesstheconstantisusedinOCCURS orDIM.
Fieldsusedashostvariablesarepassed toSQLusingtheCALL/PARMfunctionsofILE RPG.Ifafield cannotbe usedintheresult fieldofthePARM,itcannotbeusedasa hostvariable.
Dateandtimehostvariablesarealwaysassignedtocorresponding dateand timesubfieldsinthe structuresgeneratedbytheSQLprecompiler.Thegenerateddateandtimesubfieldsaredeclaredusing theformatandseparator specifiedbytheDATFMT,DATSEP,TIMFMT,andTIMSEPparametersonthe CRTSQLRPGIcommandorwiththeSETOPTIONstatement. Conversionfromtheuser declaredhost variableformattotheprecompilespecified formatoccursonassignmenttoand fromtheSQLgenerated structure.IftheDATFMTparametervalueisasystem format(*MDY,*YMD,*DMY,or*JUL),then all inputandoutputhostvariablesmustcontaindatevalueswithintherange1940-2039.Ifanydatevalue is outsideofthisrange, thentheDATFMTontheprecompilemust bespecifiedasoneoftheIBMSQL formatsof*ISO,*USA,*EUR,or*JIS.
GraphichostvariableswillusetheRPGCCSIDvalue ifoneisspecified.AnSQLDECLAREVARIABLE statementcannotbe usedtochangetheCCSIDofahostvariable whoseCCSIDhasbeendefinedinRPG, orahostvariable thatisdefinedasUCS-2orUTF-16.
TheprecompilerwillgenerateanRPGlogical(indicator)variableasacharacteroflength 1.Thistype can beusedwhereverSQLallowsacharacterhostvariable. Itcannotbe usedasanSQLindicatorvariable.It isupto theuser tomakesurethatonlyvaluesof 1or0 areassignedtoit.
TheprecompilersupportsEXTNAME(filename:fmtname),butdoesnotsupportEXTNAME(filename: fmtname:fieldtype),wherefieldtype is*ALL, *INPUT,*OUTPUT,or*KEY.
TheprecompilersupportsLIKEREC(intrecname),butdoesnotsupport theoptionalsecondparameter. Ifthereisanunnamed subfield,theprecompilerwillnotallowthedatastructure containingthesubfield tobeusedintheblockedfetchandblocked insertstatements.ForallotherSQLstatementswhere the datastructurecontainingthesubfieldisused,onlythesubfieldsthatarenamedwillbeused.
IfthePREFIXkeywordhasaprefixthatcontainsa period,theprecompilerwillnotrecognizethe externallydescribedfile.
Declaringbinaryhostvariablesin ILERPGapplicationsthatuseSQL:
ILERPG doesnothavevariablesthatcorrespondtotheSQLbinarydatatypes.
Tocreatehostvariablesthatcanbe usedwiththesedatatypes, usetheSQLTYPEkeyword.TheSQL precompilerreplacesthisdeclaration withanILE RPGlanguagedeclarationintheoutputsourcemember. Binarydeclarationscanbe eitherstandaloneorwithin adatastructure.
BINARYexample
Thefollowingdeclaration:
D MYBINARY S SQLTYPE(BINARY:50)
resultsinthegenerationofthefollowingcode:
D MYBINARY S 50A
VARBINARYexample
Thefollowingdeclaration:
D MYVARBINARY S SQLTYPE(VARBINARY:100)
resultsinthegenerationofthefollowingcode:
D MYVARBINARY S 100A VARYING
1. ForBINARYhostvariables,thelengthmustbe intherange1 to32766.
2. ForVARBINARYhostvariables,thelengthmustbe intherange1to32740.
3. BINARYandVARBINARY hostvariablesare allowedtobedeclaredinhoststructures.
4. SQLTYPE,BINARY,andVARBINARY canbe inmixedcase.
5. SQLTYPEmustbebetweenpositions 44to80.
6. Whena BINARYorVARBINARYisdeclaredasastandalonehost variable,position24must
containthecharacterSand position25must beblank.
7. ThestandalonefieldindicatorSinposition24shouldbeomittedwhenaBINARYor
VARBINARYhostvariableisdeclaredinahoststructure.
DeclaringLOBhostvariablesinILERPG applicationsthatuseSQL:
ILERPG doesnothavevariablesthatcorrespondtotheSQLdatatypesforLOBs (largeobjects). Tocreatehostvariablesthatcanbe usedwith thesedatatypes, usetheSQLTYPEkeyword.TheSQL precompilerreplacesthisdeclaration withanILE RPGlanguagestructureintheoutputsourcemember. LOBdeclarationscanbe eitherstandaloneorwithin adatastructure.
LOBhostvariablesin ILERPGapplicationsthatuseSQL:
Herearesomeexamples ofLOBhostvariables(CLOB,DBCLOB,BLOB) inILERPGapplications.
CLOBexample
Thefollowingdeclaration:
D MYCLOB S SQLTYPE(CLOB:1000)
resultsinthegenerationofthefollowingstructure:
D MYCLOB DS
D MYCLOB_LEN 10U
D MYCLOB_DATA 1000A
DBCLOBexample
Thefollowingdeclaration:
D MYDBCLOB S SQLTYPE(DBCLOB:400)
resultsinthegenerationofthefollowingstructure:
D MYDBCLOB DS
D MYDBCLOB_LEN 10U
D MYDBCLOB_DATA 400G
BLOBexample
Thefollowingdeclaration:
D MYBLOB S SQLTYPE(BLOB:500)
resultsinthegenerationofthefollowingstructure:
D MYBLOB DS
D MYBLOB_LEN 10U
D MYBLOB_DATA 500A
Notes:
1. ForBLOBand CLOB,1 ≤lob-length≤ 65 531 |
2. ForDBCLOB,1≤lob-length≤ 16 383
3. LOBhostvariablesareallowedtobe declaredinhoststructures.
4. LOBhostvariablesarenotallowedinhoststructure arrays.LOBlocatorsshouldbeused
instead.
5. LOBhostvariablesdeclaredinstructurearrays cannotbe usedasstandalonehost variables.
6. SQLTYPE,BLOB,CLOB,DBCLOBcanbe inmixedcase.
7. SQLTYPEmustbe betweenpositions44to80.
8. Whena LOBisdeclaredasa stand-alonehostvariable,position24must containthe
character’S’andposition25must beblank.
9. Thestand-alonefieldindicatorSinposition24shouldbeomittedwhenaLOBisdeclaredin
ahoststructure.
10. LOBhostvariablescannotbe initialized.
LOBlocatorsinILE RPGapplicationsthatuseSQL:
BLOB,CLOB,andDBCLOB locatorshavesimilarsyntax.Hereisanexampleofa BLOBlocator.
Example:BLOBlocator
Thefollowingdeclaration:
D MYBLOB S SQLTYPE(BLOB_LOCATOR)
resultsinthefollowinggeneration:
D MYBLOB S 10U
Notes:
1. LOBlocatorsareallowedtobe declaredinhoststructures.
2. SQLTYPE,BLOB_LOCATOR, CLOB_LOCATOR,DBCLOB_LOCATORcanbeinmixedcase.
3. SQLTYPEmustbe betweenpositions 44to80.
4. Whena LOBlocatorisdeclaredasastandalonehost variable,position24mustcontainthe
character’S’ andposition25mustbe blank.
5. ThestandalonefieldindicatorSinposition24shouldbeomittedwhenaLOBlocatoris
declaredina hoststructure. 6. LOBlocatorscannotbe initialized.
LOBfilereferencevariables inILE RPGapplicationsthatuseSQL:
Hereisanexampleofa CLOBfilereference variableinILERPG. BLOBandDBCLOBfilereference variableshavesimilarsyntax.
CLOBfilereferenceexample
Thefollowingdeclaration:
D MY_FILE S SQLTYPE(CLOB_FILE)
resultsinthegenerationofthefollowingstructure:
D MY_FILE DS
D MY_FILE_NL 10U
D MY_FILE_DL 10U
D MY_FILE_FO 10U
D MY_FILE_NAME 255A
Notes:
1. LOBfilereference variablesareallowedtobedeclaredinhoststructures.
2. SQLTYPE,BLOB_FILE,CLOB_FILE,DBCLOB_FILEcanbe inmixedcase.
3. SQLTYPEmustbebetweenpositions 44to80.
4. Whena LOBfilereference isdeclaredasastandalone hostvariable,position24must contain
thecharacter’S’and position25mustbeblank.
5. Thestandalonefieldindicator’S’inposition24shouldbeomittedwhenaLOBfilereference
variableisdeclaredin ahoststructure.
6. LOBfilereference variablescannotbe initialized.
Thepre-compilerwillgeneratedeclarationsforthefollowingfileoptionconstants.Youcanusethese constantstosetthexxx_FOvariablewhenyouusefilereference hostvariables.
v SQFRD(2)
v SQFCRT(8)
v SQFOVR(16)
v SQFAPP(32) Related reference
LOBfilereferencevariables
DeclaringROWIDvariablesinILERPG applicationsthatuseSQL:
ILERPG doesnothaveavariable thatcorrespondstotheSQLdatatypeROWID.
Tocreatehostvariablesthatcanbe usedwith thisdatatype,usetheSQLTYPEkeyword.The SQL
precompilerreplacesthisdeclaration withanILE RPGlanguagedeclarationintheoutputsourcemember. ROWIDdeclarationscanbeeitherstandalone orwithina datastructure.
ROWIDexample
Thefollowingdeclaration:
D MY_ROWID S SQLTYPE(ROWID)
resultsinthefollowinggeneration:
D MYROWID S 40A VARYING
Notes:
1. SQLTYPE,ROWID canbe inmixedcase.
2. ROWIDhostvariablesareallowedtobe declaredin hoststructures.
3. SQLTYPEmustbebetweenpositions 44and80.
4. Whena ROWIDisdeclaredasa standalonehostvariable,position24must containthe
character’S’ andposition25mustbe blank.
5. Thestandalonefieldindicator’S’inposition24shouldbeomittedwhenaROWID isdeclared
inahoststructure.
6. ROWIDhostvariablescannotbe initialized.