/*============================================================================================= /* Notes /*============================================================================================= /* Compile with ACTGRP(XMS9001) /*============================================================================================= /* Control Specifications /*============================================================================================= H NoMain /*============================================================================================= /* File Specifications /*============================================================================================= /*============================================================================================= /* Prototype Specifications /*============================================================================================= /*============================================================================================= /* Data Specifications /*============================================================================================= /*--------------------------------------------------------------------------------------------- /* Data Structure Specifications /*--------------------------------------------------------------------------------------------- /Include QRPGCBSRC,STRING.H /Include QRPGCBSRC,MI_CPYBYTE /Include QRPGCBSRC,XMS9001 /Include QRPGCBSRC,PVS9999 /*--------------------------------------------------------------------------------------------- /* Array Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Indicator Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Standalone Data Specifications /*--------------------------------------------------------------------------------------------- D CLOBLocator S SQLTYPE(CLOB_LOCATOR) /*--------------------------------------------------------------------------------------------- /* Constant Specifications /*--------------------------------------------------------------------------------------------- /*############################################################################################# /* Procedure Deleclaration - Get String From CLOB /*############################################################################################# P getStringFromCLob... P B Export /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* Procedure Interface /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ D getStringFromCLob... D PI 10I 0 D string * Value D stringLength 10I 0 Value D clob 10U 0 Value /*============================================================================================= /* Procedure Data Specifications /*============================================================================================= /*--------------------------------------------------------------------------------------------- /* Procedure Data Structure Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Array Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Indicator Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Standalone Data Specifications /*--------------------------------------------------------------------------------------------- D clobString S 32000A D clobLength S 10I 0 D start S 10I 0 D length S 10I 0 /*--------------------------------------------------------------------------------------------- /* Procedure Constant Specifications /*--------------------------------------------------------------------------------------------- D nullTerminator... D S 1A Inz(x'00') /*--------------------------------------------------------------------------------------------- /* Procedure Key Lists /*--------------------------------------------------------------------------------------------- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* Procedure Code /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C/Exec SQL C+ set option commit=*ALL C/End-Exec /Free CLOBLocator = clob; ExSr validateParms; start = 1; length = %Size(clobString); DoW start < stringLength and start < clobLength; If clobLength < start + length; length = clobLength - start + 1; ElseIf stringLength < start + length; length = stringLength - start + 1; EndIf; /End-Free C/Exec SQL C+ values(substr(:CLOBLocator, :start, :length)) into :clobString C/End-Exec /Free sqlErrorTrap(sqlcod : 'Values' : 'Clob Locator' : sqlstt); cpyBytes(string + start - 1 : %Addr(clobString) : length); start += length; EndDo; If memcmp(string + (clobLength - 1): %Addr(nullTerminator) : 1) <> 0; If clobLength < stringLength; cpyBytes(string + clobLength : %Addr(nullTerminator) : 1); clobLength += 1; Else; cpyBytes(string + (stringLength - 1) : %Addr(nullTerminator) : 1); EndIf; EndIf; Return clobLength; //=========================================================================================== // Validate Parameters //=========================================================================================== BegSr validateParms; //------------------------------------------------------------------------------------------- // String If string = *NULL; Return -1; EndIf; //------------------------------------------------------------------------------------------- // String Length If stringLength < 1; Return -2; EndIf; //------------------------------------------------------------------------------------------- // clob /End-Free C/Exec SQL C+ values(length(:CLOBLocator)) into :clobLength C/End-Exec /Free sqlErrorTrap(sqlcod : 'Values' : 'Clob Locator' : sqlstt); If clobLength = 0; cpyBytes(string : %Addr(nullTerminator) : 1); Return clobLength; EndIf; EndSr; /End-Free P getStringFromCLob... P E /*############################################################################################# /* Procedure Deleclaration - Put String Into CLOB /*############################################################################################# P PutStringIntoCLob... P B Export /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* Procedure Interface /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ D putStringIntoCLob... D PI 10U 0 D string * Value D stringLength 10I 0 Value D clob 10U 0 Value /*============================================================================================= /* Procedure Data Specifications /*============================================================================================= /*--------------------------------------------------------------------------------------------- /* Procedure Data Structure Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Array Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Indicator Specifications /*--------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------- /* Procedure Standalone Data Specifications /*--------------------------------------------------------------------------------------------- D clobString S 32000A D clobLength S 10I 0 D newstring S * D start S 10I 0 D length S 10I 0 /*--------------------------------------------------------------------------------------------- /* Procedure Constant Specifications /*--------------------------------------------------------------------------------------------- D nullTerminator... D S 1A Inz(x'00') /*--------------------------------------------------------------------------------------------- /* Procedure Key Lists /*--------------------------------------------------------------------------------------------- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* Procedure Code /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /Free ExSr validateParms; CLOBLocator = clob; /End-Free C/Exec SQL C+ set :CLOBLocator = '' C/End-Exec /Free sqlErrorTrap(sqlcod : 'Set' : 'Clob Locator' : sqlstt); if memcmp(string + (stringLength - 1) : %Addr(nullTerminator) : 1) <> 0; stringlength += 1; newstring = %alloc(stringlength); cpybytes(newstring : string : stringlength - 1); memset(newstring + (stringlength - 1) : x'00' : 1); else; newstring = %alloc(stringlength); cpybytes(newstring : string : stringlength - 1); endIf; start = 0; length = %Size(clobString); DoW start < stringLength; If stringLength < start + length; length = stringLength - start; EndIf; cpyBytes(%Addr(clobString) : newstring + start : length); /End-Free C/Exec SQL C+ set :CLOBLocator = C+ :CLOBLocator || clob(substr(:clobString, 1, :length)) C/End-Exec /Free sqlErrorTrap(sqlcod : 'Set' : 'Clob Locator' : sqlstt); start += length; EndDo; DeAlloc(ne) newstring; Return clobLocator; //=========================================================================================== // Validate Parameters //=========================================================================================== BegSr validateParms; //------------------------------------------------------------------------------------------- // String If string = *NULL; Return 0; EndIf; //------------------------------------------------------------------------------------------- // String Length If stringLength < 1; Return 0; EndIf; EndSr; /End-Free P putStringIntoCLob... P E //===========================================================================================