IDENTIFICATION DIVISION. SYSGEN
PROGRAM-ID. BGE018Q. SYSGEN
* Created automatically by
MsgGen
SYSGEN
*
on : 25-Nov-1998 15:01:39
SYSGEN
*
SYSGEN
* DO NOT EDIT LINES WITH IN COLUMN 73!!! SYSGEN
* SYSGEN
*
SYSGEN
* Program Description:
SYSGEN
* Get Property Values SYSGEN
*
SYSGEN
* Common routine used to retrieve
property values used in
SYSGEN
* many different areas of the
system. SYSGEN
*
.............................................................. SYSGEN
*
.............................................................. SYSGEN
*
SYSGEN
* Maintenance Log
SYSGEN
* ===============
SYSGEN
* CR Nbr Who
Details
SYSGEN
* ------ ---
------- SYSGEN
* 1554 kahase
When investigating 1554 found that the order of <<1554
* 10/03/99 status property values returned for
document <<1554
* is sometimes in the wrong order
when the start <<1554
* dates are the same. Added the
end date to the <<1554
* order to solve.
<<1554
* EM
When Inventory DateActive and DateDeactive are <<EM 27/6/99
* modified to be virtual
properties, the property <<EM
27/6/99
* grid started falling over.
Investigation showed <<EM
27/6/99
* that this code had to be
modified to expect null <<EM 27/6/99
* values for virtual
properties. <<EM
27/6/99
* 28/03/00 sel Fixed Host variable definition for floating
point
* data type properties.
*
* BTB193 PJL
Populate the new field NULLFLG for numeric <<BTB193
* properties to 'Y', if the table
contains a NULL <<BTB193
* value.
<<BTB193
*
*
ENVIRONMENT DIVISION.
SYSGEN
*
DATA DIVISION. SYSGEN
*
WORKING-STORAGE SECTION.
SYSGEN
*
************* DO NOT REMOVE OR
CHANGE THESE FIELDS!! *************SYSGEN
*
The Revision Number and Checkin Date fields are updated SYSGEN
*
automatically each time the source is checked in to PVCS SYSGEN
01
WS-REVISION-NBR PIC X(59) VALUE SYSGEN
'$Revision:
\hubu_unix_src\main\5 $'.
01
WS-CHECKIN-DATE
PIC X(40) VALUE
SYSGEN
'$Date: Tue Jan 21 15:16:16
2003 $'.
SYSGEN
************* DO NOT REMOVE OR CHANGE THESE
FIELDS!! *************SYSGEN
*
01
WS-CONSTANTS.
SYSGEN
03 CN-SET-YES
PIC X(01)
VALUE 'Y'. SYSGEN
03 CN-MULTI-MSG PIC X(01) VALUE 'N'. SINGLE
*
03 CN-MULTI-MSG PIC X(01) VALUE 'Y'. ARRAY
*
03 CN-ARR-MAX PIC 9(04) VALUE 50. ARRAY
*
01
WS-FLAGS.
SYSGEN
03 FL-FIRSTTIME PIC X(01) VALUE 'Y'.
88 FIRSTTIME VALUE 'Y'.
*
03 FL-DEFAULTS PIC X(01) VALUE ' '. SYSGEN
* 88 DEFAULTS-MAY-BE-NECESSARY VALUE 'Y'. SYSGEN
* 88 DEFAULTS-NOT-NECESSARY VALUE 'N'. SYSGEN
*
03 FL-END-OF-FETCH PIC X(01). SYSGEN
* 88 END-OF-FETCH VALUE 'Y'. SYSGEN
*
01
WS-COUNTERS.
SYSGEN
*
03 CT-CUR-PTR PIC 9(09). ARRAY
*
03 CT-ARR-PTR PIC 9(04). ARRAY
03 CT-MSG-PTR PIC 9(04). SYSGEN
03 CT-QRY-PTR PIC 9(04).
*
01
WS-GENERAL-VARIABLES. SYSGEN
03 GV-Q-KeyValue PIC 9(9).
03 L1 PIC 9(2).
03 L2 PIC 9(2).
03 L3 PIC 9(2).
03 L4 PIC 9(2).
03 L5 PIC 9(2).
03 GV-NBR-OF-QUESTIONS PIC 9(6).
03 GV-QUESTION OCCURS 200.
05 GV-PFCODE PIC X(05).
05 GV-KEYVALUE PIC 9(09).
05 GV-KEYVALUE-X PIC X(09).
05 GV-PROPERTYKEY PIC X(30).
05 GV-VIRTUALCOLNAME PIC X(30).
05 GV-DATATYPE PIC X(01).
03 GV-KEYVALUE-TEMP PIC 9(09).
03 GV-TRACE.
05 GV-MSG PIC X(30).
05 GV-FILLER-TRACE PIC X(1).
*
EXEC SQL
SYSGEN
BEGIN DECLARE SECTION
SYSGEN
END-EXEC.
SYSGEN
*
01
WS-SQL-VARIABLES.
SYSGEN
03 SV-SQL-LEN
PIC S9(9) COMP
SYNC.
03 SV-SQL-FC PIC S9(9) COMP
SYNC.
03 SV-IND-PROPVALCHAR PIC S9(4) COMP. SINGLE
03 SV-IND-DFLTVALUE PIC S9(4) COMP. SINGLE
03 SV-IND-PROPVALDATE PIC S9(4) COMP. SINGLE
03 SV-IND-PROPVALNUMBER PIC S9(4) COMP. SINGLE
03 SV-IND-DATESTART PIC S9(4) COMP. SINGLE
03
SV-IND-DATEEND
PIC S9(4) COMP.
SINGLE
03 SV-PF-IND-TABLENAME PIC S9(4) COMP. SINGLE
03 SV-PF-IND-IDCOLNAME PIC S9(4) COMP. SINGLE
03 SV-PF-IND-FKCOLNAME PIC S9(4) COMP. SINGLE
03 SV-PF-IND-OBJECTTABLENAME PIC S9(4) COMP.
03 SV-TN-IND-PROPVALCHAR PIC S9(4) COMP. SINGLE
03 SV-TN-IND-PROPVALDATE PIC S9(4) COMP. SINGLE
03 SV-TN-IND-PROPVALNUMBER PIC S9(4) COMP. SINGLE
03 SV-TN-IND-DATESTART PIC S9(4) COMP. SINGLE
03 SV-TN-IND-DATEEND PIC S9(4) COMP. SINGLE
03 SV-TN-IND-IDCOLVALUE PIC S9(4) COMP. SINGLE
*
*
03 SV-SQL-STMT PIC X(4000) SYNC.
03 SV-SQL-STMT-6000 PIC X(4000). SYSGEN
03 SV-SQL-STMT-7000 PIC X(4000) VARYING. SYSGEN
03 SV-TOTAL-ROWS PIC S9(9) COMP-5. SYSGEN
03 SV-TMP-DFLTVALUE PIC X(250). SYSGEN
*----------------------------------------------------------------
03 SV-IDCOLVALUE PIC S9(9) COMP-5. SINGLE
03 SV-KEYVALUE PIC S9(9) COMP-5. SINGLE
03 SV-PROPERTYKEY PIC X(30). SINGLE
03 SV-PROPVALCHAR PIC X(250). SINGLE
03 SV-DFLTVALUE PIC X(250). SINGLE
03 SV-PROPVALDATE PIC X(14). SINGLE
03
SV-PROPVALNUMBER
PIC S9(12)V9(6) COMP-3.
03 SV-DATESTART PIC X(14). SINGLE
03 SV-DATEEND PIC X(14). SINGLE
03 SV-RowID
PIC
X(18). SINGLE
03 SV-ROWVERSION PIC X(1). SINGLE
*----------------------------------------------------------------
03 SV-PF-TABLENAME PIC X(30).
03 SV-PF-IDCOLNAME PIC X(30).
03 SV-PF-FKCOLNAME PIC X(30).
03 SV-PF-OBJECTTABLENAME PIC X(30).
*
03 SV-WK-PFCODE PIC X(05). SINGLE
03 SV-WK-KEYVALUE PIC S9(9) COMP-5. SINGLE
03 SV-WK-KEYVALUE-X PIC X(09). SINGLE
03 SV-WK-PROPERTYKEY PIC X(30). SINGLE
03
SV-WK-VIRTUALCOLNAME
PIC X(30).
SINGLE
03 SV-WK-DATATYPE PIC X(01). SINGLE
*
03 SV-WK-USERREADFLG PIC X(01). SINGLE
03 SV-WK-USERWRITEFLG PIC X(01). SINGLE
*
03 SV-TN-PROPVALCHAR PIC X(250). SINGLE
03 SV-TN-PROPVALDATE PIC X(14). SINGLE
03 SV-TN-PROPVALNUMBER PIC S9(12)V9(6) COMP-3.
03 SV-TN-DATESTART PIC X(14). SINGLE
03 SV-TN-DATEEND PIC X(14). SINGLE
03 SV-TN-IDCOLVALUE PIC S9(9) COMP-5. SINGLE
03 SV-TN-ROWID PIC X(18). SINGLE
03 SV-TN-ROWVERSION PIC X(01). SINGLE
*
*
EXEC SQL
SYSGEN
INCLUDE "SQLCA.COB"
SYSGEN
END-EXEC.
SYSGEN
*
EXEC SQL SYSGEN
INCLUDE
"DB2INC.COB"
SYSGEN
END-EXEC.
SYSGEN
*
EXEC SQL
SYSGEN
END DECLARE SECTION
SYSGEN
END-EXEC.
SYSGEN
*
LINKAGE SECTION.
SYSGEN
*
COPY "H1SYSPFX".
SYSGEN
*
* Created automatically by
MsgGen
*
on : 26-Jun-1997 15:53:57
* Modified for MCI Phase 2 by
Thomas Lobo
*
on : 26-Apr-1999 08:30:00
*
* Implements Message SYSPFX
* VB Class is QR_SysPrefix
*
* DO NOT EDIT !!!
*
01 HUB-MESSAGE-LINKAGE.
03 SYSPFX-REC.
05 SYSPFX-FUNCTION PIC X(8).
05 SYSPFX-USERID PIC S9(9).
05 SYSPFX-ERRORCODE PIC S9(6).
05 SYSPFX-ERRORMSG PIC X(250).
05 SYSPFX-ERRORLOGID PIC S9(9).
05 SYSPFX-ROWCOUNT PIC S9(9).
05 SYSPFX-ROWLEN PIC S9(9).
05 SYSPFX-ROWTOTAL PIC S9(9).
05 SYSPFX-SESSIONID PIC S9(9).
05 SYSPFX-VERSIONID PIC S9(9).
05 SYSPFX-CONTINUE PIC X(01).
05 SYSPFX-ORIG-ECODE PIC S9(6).
05
SYSPFX-ERROR-SOURCE PIC X(5).
05 SYSPFX-ERROR-XLATE-FLG PIC X(01).
05 SYSPFX-MSG-LEN PIC S9(9).
05 FILLER PIC X(51).
03 HUB-MESSAGE-BUFFER PIC X(4095600).
COPY "BGE018Q". SYSGEN
COPY "BGE018R1".
SYSGEN
*
*
PROCEDURE DIVISION USING
HUB-MESSAGE-LINKAGE.
SYSGEN
*
0000-MAIN SECTION.
SYSGEN
*
*
MOVE 'BGE018Q-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
PERFORM 1000-INITIALISE.
*
MOVE ZEROES TO
SQL-RETURN-CODE.
SYSGEN
*
EXEC SQL SYSGEN
WHENEVER SQLERROR DO
PERFORM 9000-SQL-ERROR-ROUTINE
SYSGEN
END-EXEC.
SYSGEN
*
IF SYSPFX-VERSIONID NOT =
BGE018Q-VER SYSGEN
MOVE 001000 TO
SQLCODE
SYSGEN
STRING "Incorrect
Version of Message "
SYSGEN
"BGE018Q" SYSGEN
DELIMITED BY
SIZE
SYSGEN
INTO SQLERRMC
SYSGEN
GO TO PROG-EXIT
SYSGEN
END-IF.
SYSGEN
*
*
PERFORM 7100-PREPARE-SQL.
*
PERFORM 7200-DECLARE-CURSOR.
*
PERFORM VARYING CT-QRY-PTR
FROM 1 BY 1
UNTIL CT-QRY-PTR >
GV-NBR-OF-QUESTIONS
*
PERFORM
6050-GET-QUESTION-DETAILS
*
IF SV-KEYVALUE < ZERO
PERFORM
5000-DECLARE-CURSOR
PERFORM
5100-OPEN-CURSOR
PERFORM
5200-FETCH-ROWS
PERFORM 5300-CLOSE-CURSOR
ELSE
IF
SV-WK-VIRTUALCOLNAME <>
SPACES
PERFORM
6100-PREPARE-SQL
PERFORM
6200-DECLARE-CURSOR
PERFORM
6400-OPEN-CURSOR
PERFORM 6500-FETCH-ROWS
PERFORM
6600-CLOSE-CURSOR
ELSE
PERFORM
7100-PREPARE-SQL
PERFORM
7200-DECLARE-CURSOR
PERFORM
7400-OPEN-CURSOR
PERFORM UNTIL NOT
SQL-OK
PERFORM
7500-FETCH-ROWS
END-PERFORM
PERFORM
7600-CLOSE-CURSOR
SET SQL-OK TO
TRUE
END-IF
END-IF
END-PERFORM. SYSGEN
*
*
SUBTRACT 1 FROM CT-MSG-PTR. SYSGEN
MOVE CT-MSG-PTR TO
SV-TOTAL-ROWS. SYSGEN
*
PROG-EXIT.
SYSGEN
*
MOVE SQLCODE TO SYSPFX-ERRORCODE. SYSGEN
MOVE SQLERRMC TO SYSPFX-ERRORMSG. SYSGEN
MOVE ZEROES TO SYSPFX-ERRORLOGID. SYSGEN
MOVE BGE018R1-LEN TO SYSPFX-ROWLEN. SYSGEN
MOVE CT-MSG-PTR TO SYSPFX-ROWCOUNT. SYSGEN
MOVE SV-TOTAL-ROWS TO
SYSPFX-ROWTOTAL
SYSGEN
MOVE BGE018R1-VER TO SYSPFX-VERSIONID. SYSGEN
*
*
MOVE 'BGE018Q-END' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
GOBACK. SYSGEN
*
*
1000-INITIALISE SECTION. SYSGEN
*
INITIALIZE
SYSGEN
WS-COUNTERS
SYSGEN
* WS-FLAGS
SYSGEN
WS-GENERAL-VARIABLES SYSGEN
WS-SQL-VARIABLES. SYSGEN
*
*----------------------------------------------------------------
*
Both Q and R1 messages redefine HUB-MESSAGE-BUFFER so,
*
let's store all questions in Working Storage before
*
they get overwritten by our answers:
*----------------------------------------------------------------
*
PERFORM VARYING CT-QRY-PTR
FROM 1 BY 1
UNTIL CT-QRY-PTR >
BGE018Q-OCC
OR F-PFCODE OF
BGE018Q-REC (CT-QRY-PTR) = SPACES
MOVE F-PFCODE OF BGE018Q-REC (CT-QRY-PTR)
TO GV-PFCODE (CT-QRY-PTR)
MOVE F-KEYVALUE OF BGE018Q-REC (CT-QRY-PTR)
TO GV-KEYVALUE (CT-QRY-PTR)
MOVE F-KEYVALUE OF BGE018Q-REC (1)
TO SV-KEYVALUE
MOVE GV-KEYVALUE (CT-QRY-PTR)
TO GV-KEYVALUE-X (CT-QRY-PTR)
INSPECT GV-KEYVALUE-X (CT-QRY-PTR)
REPLACING LEADING
ZEROES BY SPACES
MOVE F-PROPERTYKEY OF BGE018Q-REC (CT-QRY-PTR)
TO GV-PROPERTYKEY (CT-QRY-PTR)
MOVE F-VIRTUALCOLNAME OF
BGE018Q-REC (CT-QRY-PTR)
TO GV-VIRTUALCOLNAME (CT-QRY-PTR)
MOVE F-DATATYPE OF BGE018Q-REC (CT-QRY-PTR)
TO GV-DATATYPE (CT-QRY-PTR)
END-PERFORM.
*
COMPUTE GV-NBR-OF-QUESTIONS =
CT-QRY-PTR - 1.
*
IF GV-PFCODE (1) <>
SPACES
PERFORM
1100-GET-FKCOLNAME
END-IF.
*
*
1100-GET-FKCOLNAME SECTION.
*
MOVE GV-PFCODE (1) TO SV-WK-PFCODE.
*
EXEC SQL
SELECT TABLENAME
,IDCOLNAME
,FKCOLNAME
,OBJECTTABLENAME
INTO :SV-PF-TABLENAME:SV-PF-IND-TABLENAME
,:SV-PF-IDCOLNAME:SV-PF-IND-IDCOLNAME
,:SV-PF-FKCOLNAME:SV-PF-IND-FKCOLNAME
,:SV-PF-OBJECTTABLENAME:SV-PF-IND-OBJECTTABLENAME
FROM PROPERTYFUNCTION
WHERE PFCODE
= :SV-WK-PFCODE
END-EXEC.
*
MOVE SQLCODE TO SQL-RETURN-CODE.
*
*
2000-LOAD-MESSAGE SECTION. SYSGEN
MOVE SV-IDCOLVALUE TO F-IDCOLVALUE SINGLE
OF BGE018R1-REC (CT-MSG-PTR).
SINGLE
*
MOVE SV-PROPERTYKEY TO
F-PROPERTYKEY SINGLE
* OF BGE018R1-REC
(CT-MSG-PTR). SINGLE
MOVE SV-WK-PROPERTYKEY TO F-PROPERTYKEY SINGLE
OF BGE018R1-REC (CT-MSG-PTR).
SINGLE
IF SV-IND-PROPVALCHAR <
ZERO
SINGLE
MOVE SPACES TO F-PROPVALCHAR SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
ELSE SINGLE
MOVE SV-PROPVALCHAR
SINGLE
TO F-PROPVALCHAR
SINGLE
OF BGE018R1-REC (CT-MSG-PTR) SINGLE
END-IF.
SINGLE
IF SV-IND-PROPVALDATE <
ZERO
SINGLE
MOVE SPACES TO F-PROPVALDATE SINGLE
OF BGE018R1-REC
(CT-MSG-PTR) SINGLE
ELSE
SINGLE
MOVE SV-PROPVALDATE
SINGLE
TO F-PROPVALDATE SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
END-IF.
SINGLE
IF SV-WK-DATATYPE = 'N' <<BTB193
IF SV-TN-IND-PROPVALNUMBER
< 0
<<BTB193
MOVE 'Y' TO F-NULLFLG <<BTB193
OF BGE018R1-REC (CT-MSG-PTR)
<<BTB193
ELSE
<<BTB193
MOVE 'N' TO F-NULLFLG <<BTB193
OF BGE018R1-REC (CT-MSG-PTR)
<<BTB193
END-IF
<<BTB193
END-IF.
<<BTB193
IF SV-IND-PROPVALNUMBER <
ZERO
SINGLE
MOVE ZERO TO F-PROPVALNUMBER SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
ELSE
SINGLE
MOVE SV-PROPVALNUMBER
SINGLE
TO F-PROPVALNUMBER
SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
END-IF. SINGLE
IF SV-IND-DATESTART <
ZERO
SINGLE
MOVE SPACES TO F-DATESTART SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
ELSE
SINGLE
MOVE SV-DATESTART
SINGLE
TO F-DATESTART
SINGLE
OF
BGE018R1-REC (CT-MSG-PTR) SINGLE
END-IF.
SINGLE
IF SV-IND-DATEEND <
ZERO
SINGLE
MOVE SPACES TO F-DATEEND SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
ELSE
SINGLE
MOVE SV-DATEEND SINGLE
TO F-DATEEND
SINGLE
OF BGE018R1-REC (CT-MSG-PTR)
SINGLE
END-IF. SINGLE
MOVE SV-RowID TO F-RowID SINGLE
OF BGE018R1-REC (CT-MSG-PTR).
SINGLE
MOVE SV-ROWVERSION TO F-ROWVERSION SINGLE
OF
BGE018R1-REC (CT-MSG-PTR). SINGLE
MOVE SV-WK-VIRTUALCOLNAME TO F-VIRTUALCOLNAME SINGLE
OF BGE018R1-REC (CT-MSG-PTR).
SINGLE
*
*
5000-DECLARE-CURSOR SECTION.
EXEC SQL
SYSGEN
DECLARE SQL1 CURSOR
FOR
SYSGEN
SELECT DFLTVALUE SYSGEN
FROM
PROPERTYSETMBR PSM
SYSGEN
WHERE PSM.PSID
= -( :SV-KEYVALUE ) SYSGEN
AND
PSM.PROPERTYKEY = :SV-WK-PROPERTYKEY
SYSGEN
AND USERREADFLG =
'Y'
END-EXEC.
SYSGEN
*
*
5100-OPEN-CURSOR SECTION.
EXEC SQL
SYSGEN
OPEN SQL1
SYSGEN
END-EXEC.
SYSGEN
*
*
5200-FETCH-ROWS SECTION.
MOVE SPACES TO SV-DFLTVALUE
MOVE ZERO TO
SV-IND-DFLTVALUE
EXEC SQL
SYSGEN
FETCH SQL1
SYSGEN
INTO
:SV-DFLTVALUE:SV-IND-DFLTVALUE
<<EM 27/6/99
END-EXEC.
*
MOVE SQLCODE TO
SQL-RETURN-CODE.
IF SQL-NOT-FOUND
MOVE ZEROS TO
SQL-RETURN-CODE
MOVE ZEROS TO
SQLCODE
MOVE SQLCODE TO
SQL-RETURN-CODE
MOVE -1 TO
SV-IND-DFLTVALUE
END-IF.
*
IF SQL-OK
EVALUATE
SV-WK-DATATYPE
SYSGEN
WHEN "C" SYSGEN
IF SV-IND-DFLTVALUE
< 0
MOVE -1 TO
SV-IND-PROPVALCHAR
MOVE SPACES TO SV-PROPVALCHAR
ELSE
IF
SV-DFLTVALUE(1:1) = '='
INSPECT
SV-DFLTVALUE
REPLACING
FIRST '=' BY SPACE
EXEC SQL
SELECT
:SV-DFLTVALUE
INTO
:SV-PROPVALDATE
FROM DUAL
END-EXEC
ELSE
MOVE
SV-DFLTVALUE TO
SV-PROPVALCHAR
END-IF
MOVE ZEROES TO SV-IND-PROPVALCHAR
END-IF
<<EM 27/6/99
WHEN "D"
SYSGEN
IF SV-IND-DFLTVALUE
< 0
MOVE -1 TO
SV-IND-PROPVALDATE
MOVE SPACES TO SV-PROPVALDATE
ELSE
<<EM 27/6/99
IF
SV-DFLTVALUE(1:1) = '='
INSPECT
SV-DFLTVALUE
REPLACING FIRST '=' BY SPACE
EXEC SQL
SELECT
:SV-DFLTVALUE
INTO
:SV-PROPVALDATE
FROM
DUAL
END-EXEC
ELSE
MOVE
SV-DFLTVALUE TO SV-PROPVALDATE
END-IF
MOVE ZEROES TO SV-IND-PROPVALDATE
END-IF
<<EM 27/6/99
WHEN "N"
SYSGEN
IF SV-IND-DFLTVALUE
< 0
MOVE -1 TO
SV-IND-PROPVALNUMBER
MOVE ZEROES TO SV-PROPVALNUMBER <<EM 27/6/99
ELSE
<<EM 27/6/99
IF
SV-DFLTVALUE(1:1) = '='
MOVE 0 TO L5
INSPECT
SV-DFLTVALUE TALLYING L5
FOR CHARACTERS BEFORE
INITIAL " "
INSPECT
SV-DFLTVALUE
REPLACING
FIRST '=' BY SPACE
*
STRING
"SELECT
TO_NUMBER(" DELIMITED BY SIZE
SV-DFLTVALUE(1:L5)
") FROM
DUAL"
DELIMITED BY
SIZE
INTO
SV-TMP-DFLTVALUE
END-STRING
*
EXEC SQL
PREPARE S3
FROM :SV-TMP-DFLTVALUE
END-EXEC
*
EXEC SQL
DECLARE
DFT3 CURSOR FOR S3
END-EXEC
*
EXEC SQL
OPEN
DFT3
END-EXEC
*
EXEC SQL
FETCH DFT3
INTO
:SV-PROPVALNUMBER
END-EXEC
*
EXEC SQL
CLOSE
DFT3
END-EXEC
ELSE
*
EXEC SQL
SELECT
TO_NUMBER(:SV-DFLTVALUE)
INTO
:SV-PROPVALNUMBER
FROM DUAL
END-EXEC
END-IF
MOVE ZEROES TO SV-IND-PROPVALNUMBER
END-IF
<<EM 27/6/99
END-EVALUATE
MOVE SPACES TO SV-ROWID
MOVE SPACES TO SV-ROWVERSION
END-IF.
*
IF SQL-OK AND NOT
SQL-NOT-FOUND
ADD 1 TO CT-MSG-PTR
PERFORM
2000-LOAD-MESSAGE
END-IF.
*
*
5300-CLOSE-CURSOR SECTION.
*
EXEC SQL
SYSGEN
CLOSE SQL1
SYSGEN
END-EXEC.
*
*
6050-GET-QUESTION-DETAILS
SECTION.
*
MOVE "Y" TO
FL-FIRSTTIME
MOVE GV-PFCODE (CT-QRY-PTR) TO SV-WK-PFCODE.
MOVE GV-KEYVALUE (CT-QRY-PTR) TO SV-WK-KEYVALUE
GV-KEYVALUE-TEMP.
MOVE GV-KEYVALUE-X (CT-QRY-PTR) TO SV-WK-KEYVALUE-X.
MOVE GV-PROPERTYKEY (CT-QRY-PTR) TO SV-WK-PROPERTYKEY.
MOVE GV-VIRTUALCOLNAME
(CT-QRY-PTR) TO SV-WK-VIRTUALCOLNAME.
MOVE GV-DATATYPE (CT-QRY-PTR) TO SV-WK-DATATYPE.
6100-PREPARE-SQL SECTION.
SYSGEN
*
*
MOVE '6100-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
MOVE 01
TO SV-SQL-LEN.
MOVE 0 TO L1.
MOVE 0 TO L2.
MOVE 0 TO L3.
MOVE SPACES TO
SV-SQL-STMT-6000.
*
INSPECT
SV-WK-VIRTUALCOLNAME TALLYING
L1
FOR CHARACTERS BEFORE
INITIAL SPACE.
INSPECT SV-PF-OBJECTTABLENAME
TALLYING L2
FOR CHARACTERS BEFORE
INITIAL SPACE.
INSPECT SV-PF-FKCOLNAME TALLYING L3
FOR CHARACTERS BEFORE
INITIAL SPACE.
*
*----------------------------------------------------------------
* VirtualColName <>
SPACES
*----------------------------------------------------------------
STRING
"SELECT "
SV-WK-VIRTUALCOLNAME (1:L1) " "
", ROWID "
", ROWVERSION
"
"FROM " SV-PF-OBJECTTABLENAME (1:L2) " "
"WHERE " SV-PF-FKCOLNAME (1:L3)
" = "
GV-KEYVALUE-TEMP "
"
*
DELIMITED BY SIZE
INTO
SV-SQL-STMT-6000
WITH POINTER
SV-SQL-LEN
END-STRING.
*
*
EXEC SQL
SYSGEN
PREPARE S6000 FROM :SV-SQL-STMT-6000 SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '6100-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
6200-DECLARE-CURSOR SECTION.
SYSGEN
*
*
MOVE '6200-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL
SYSGEN
DECLARE SQL6000 CURSOR FOR S6000 SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '6200-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
6400-OPEN-CURSOR SECTION.
SYSGEN
*
*
MOVE '6400-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL SYSGEN
OPEN SQL6000
SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '6400-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
6500-FETCH-ROWS SECTION.
SYSGEN
*
*
MOVE '6500-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
MOVE SPACES TO SV-PROPVALCHAR.
MOVE SPACES TO SV-PROPVALDATE.
MOVE ZEROES TO SV-PROPVALNUMBER.
MOVE SPACES TO SV-DATEEND.
*
EVALUATE SV-WK-DATATYPE SYSGEN
WHEN "C"
SYSGEN
EXEC SQL
SYSGEN
FETCH SQL6000 SYSGEN
INTO
:SV-TN-PROPVALCHAR:SV-TN-IND-PROPVALCHAR
<<EM 27/6/99
,:SV-TN-ROWID
SYSGEN
,:SV-TN-ROWVERSION SYSGEN
END-EXEC
WHEN "D"
SYSGEN
EXEC SQL
SYSGEN
FETCH SQL6000 SYSGEN
INTO
:SV-TN-PROPVALDATE:SV-TN-IND-PROPVALDATE
<<EM 27/6/99
,:SV-TN-ROWID
SYSGEN
,:SV-TN-ROWVERSION SYSGEN
END-EXEC
WHEN "N"
SYSGEN
EXEC SQL
SYSGEN
FETCH SQL6000 SYSGEN
INTO
:SV-TN-PROPVALNUMBER:SV-TN-IND-PROPVALNUMBER
<<EM 27/6/99
,:SV-TN-ROWID
SYSGEN
,:SV-TN-ROWVERSION SYSGEN
END-EXEC
END-EVALUATE.
SYSGEN
*
MOVE SQLCODE TO
SQL-RETURN-CODE.
*
IF SQL-OK
EVALUATE
SV-WK-DATATYPE
SYSGEN
WHEN "C"
SYSGEN
IF
SV-TN-IND-PROPVALCHAR < 0 <<EM
27/6/99
MOVE SPACES TO SV-PROPVALCHAR <<EM 27/6/99
ELSE
<<EM 27/6/99
MOVE
SV-TN-PROPVALCHAR TO
SV-PROPVALCHAR
MOVE ZEROES TO SV-IND-PROPVALCHAR
END-IF <<EM
27/6/99
WHEN "D"
SYSGEN
IF
SV-TN-IND-PROPVALDATE < 0 <<EM
27/6/99
MOVE SPACES TO SV-PROPVALDATE <<EM 27/6/99
ELSE
<<EM 27/6/99
MOVE
SV-TN-PROPVALDATE TO
SV-PROPVALDATE
MOVE ZEROES TO SV-IND-PROPVALDATE
END-IF
<<EM 27/6/99
WHEN "N"
SYSGEN
IF
SV-TN-IND-PROPVALNUMBER < 0 <<EM 27/6/99
MOVE ZEROES TO SV-PROPVALNUMBER <<EM 27/6/99
ELSE
<<EM 27/6/99
MOVE
SV-TN-PROPVALNUMBER TO SV-PROPVALNUMBER
MOVE ZEROES TO SV-IND-PROPVALNUMBER
END-IF
<<EM 27/6/99
END-EVALUATE
MOVE SV-TN-ROWID TO SV-ROWID
MOVE SV-TN-ROWVERSION TO SV-ROWVERSION
END-IF.
*
IF SQL-OK
AND NOT SQL-NOT-FOUND
ADD 1 TO CT-MSG-PTR
PERFORM
2000-LOAD-MESSAGE
END-IF.
*
*
MOVE '6500-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
6600-CLOSE-CURSOR SECTION.
SYSGEN
*
*
MOVE '6600-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL
SYSGEN
CLOSE SQL6000
SYSGEN
END-EXEC.
*
*
MOVE '6600-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
7100-PREPARE-SQL SECTION.
SYSGEN
*
*
MOVE '7100-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
MOVE 01 TO SV-SQL-LEN.
MOVE 0 TO L1.
MOVE 0 TO L2.
MOVE 0 TO L3.
MOVE 0 TO L4.
*
MOVE SPACES TO SV-SQL-STMT-7000.
*
*
MOVE 'INSPECT-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
INSPECT SV-PF-IDCOLNAME TALLYING L1
FOR CHARACTERS BEFORE
INITIAL SPACE.
INSPECT SV-PF-TABLENAME TALLYING L2
FOR CHARACTERS BEFORE
INITIAL SPACE.
INSPECT SV-PF-FKCOLNAME TALLYING L3
FOR CHARACTERS BEFORE
INITIAL SPACE.
INSPECT SV-PF-OBJECTTABLENAME
TALLYING L4
FOR CHARACTERS BEFORE
INITIAL SPACE.
*
MOVE FUNCTION UPPER-CASE
(SV-PF-TABLENAME)
TO SV-PF-TABLENAME .
*
*
MOVE 'INSPECT-END' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*----------------------------------------------------------------
* VirtualColName = SPACES
*----------------------------------------------------------------
*
MOVE 'STRING-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
STRING
"SELECT "
SV-PF-IDCOLNAME (1:L1) " "
",PROPVALCHAR
"
",PROPVALDATE
"
",PROPVALNUMBER "
DELIMITED BY SIZE
INTO
SV-SQL-STMT-7000-ARR
WITH POINTER
SV-SQL-LEN
END-STRING.
*
IF SV-PF-TABLENAME <>
"RRPROPERTY"
STRING
",DATESTART
"
",DATEEND
"
DELIMITED BY
SIZE
INTO
SV-SQL-STMT-7000-ARR
WITH POINTER
SV-SQL-LEN
END-STRING
END-IF.
*
STRING
",ROWID
"
",ROWVERSION
"
"FROM " SV-PF-TABLENAME (1:L2) " "
"WHERE " SV-PF-TABLENAME (1:L2) ".PROPERTYKEY = "
"RTRIM(:PROPERTYKEY)
"
*
DELIMITED BY SIZE
INTO
SV-SQL-STMT-7000-ARR
WITH POINTER
SV-SQL-LEN
END-STRING.
*
*
IF SV-WK-KeyValue-X <> SPACES
IF GV-KEYVALUE-X (1) <>
SPACES
STRING
"AND " SV-PF-FKCOLNAME (1:L3) " = "
* "LTRIM("
SV-WK-KEYVALUE-X ") "
":KEYVALUE
"
DELIMITED BY
SIZE
INTO SV-SQL-STMT-7000-ARR
WITH POINTER
SV-SQL-LEN
END-STRING
END-IF.
*
IF SV-PF-TABLENAME <>
"RRPROPERTY"
STRING
* "ORDER BY DATESTART
" <<1554
"ORDER BY
DATESTART, DATEEND"
<<1554
DELIMITED BY
SIZE
INTO
SV-SQL-STMT-7000-ARR
WITH POINTER
SV-SQL-LEN
END-STRING
END-IF.
*
*
DISPLAY SV-SQL-STMT-7000.
COMPUTE SV-SQL-STMT-7000-LEN =
SV-SQL-LEN - 1.
*
*
MOVE 'STRING-END' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL SYSGEN
PREPARE S7000 FROM
:SV-SQL-STMT-7000
SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '7100-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
7200-DECLARE-CURSOR SECTION.
SYSGEN
*
*
MOVE '7200-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL
SYSGEN
DECLARE SQL7000 CURSOR FOR
S7000
SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '7200-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
7400-OPEN-CURSOR SECTION.
SYSGEN
*
*
MOVE '7400-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
IF GV-KEYVALUE-X (1) <> SPACES
EXEC SQL
SYSGEN
OPEN SQL7000 USING
:SV-WK-PROPERTYKEY
,:SV-WK-KEYVALUE
END-EXEC
ELSE
EXEC SQL
OPEN SQL7000 USING
:SV-WK-PROPERTYKEY
END-EXEC
END-IF.
SYSGEN
*
*
MOVE '7400-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
7500-FETCH-ROWS SECTION.
SYSGEN
*
*
MOVE '7500-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
IF SV-PF-TABLENAME <>
"RRPROPERTY"
EXEC SQL
SYSGEN
FETCH SQL7000
INTO
:SV-TN-IDCOLVALUE:SV-TN-IND-IDCOLVALUE
,:SV-TN-PROPVALCHAR:SV-TN-IND-PROPVALCHAR
,:SV-TN-PROPVALDATE:SV-TN-IND-PROPVALDATE
,:SV-TN-PROPVALNUMBER:SV-TN-IND-PROPVALNUMBER
,:SV-TN-DATESTART:SV-TN-IND-DATESTART
,:SV-TN-DATEEND:SV-TN-IND-DATEEND
,:SV-TN-ROWID
,:SV-TN-ROWVERSION
END-EXEC
ELSE
EXEC SQL SYSGEN
FETCH SQL7000
INTO
:SV-TN-IDCOLVALUE:SV-TN-IND-IDCOLVALUE
,:SV-TN-PROPVALCHAR:SV-TN-IND-PROPVALCHAR
,:SV-TN-PROPVALDATE:SV-TN-IND-PROPVALDATE
,:SV-TN-PROPVALNUMBER:SV-TN-IND-PROPVALNUMBER
,:SV-TN-DATESTART:SV-TN-IND-DATESTART
,:SV-TN-DATEEND:SV-TN-IND-DATEEND
,:SV-TN-ROWID
,:SV-TN-ROWVERSION
END-EXEC
END-IF.
*
MOVE SQLCODE TO
SQL-RETURN-CODE.
*
*
IF SQL-NOT-FOUND
AND FIRSTTIME
MOVE ZEROES TO SV-IDCOLVALUE
MOVE SPACES TO SV-PROPVALCHAR
MOVE -1 TO SV-IND-PROPVALCHAR
MOVE SPACES TO SV-PROPVALDATE
MOVE -1 TO SV-IND-PROPVALDATE
MOVE ZEROES TO SV-PROPVALNUMBER
MOVE -1 TO SV-IND-PROPVALNUMBER
MOVE SPACES TO SV-DATESTART
MOVE SPACES TO SV-DATEEND
MOVE -1 TO SV-IND-DATESTART
MOVE -1 TO SV-IND-DATEEND
MOVE SPACES TO SV-ROWID
MOVE '0' TO SV-ROWVERSION
MOVE 0 TO
SQL-RETURN-CODE
display 'loaded over sql
not found ' SV-WK-PROPERTYKEY
ELSE IF SQL-OK
IF
SV-TN-IND-IDCOLVALUE < 0
MOVE ZEROES TO SV-IDCOLVALUE
ELSE
MOVE
SV-TN-IDCOLVALUE TO
SV-IDCOLVALUE
* MOVE ZEROES TO SV-IND-IDCOLVALUE
END-IF
IF
SV-TN-IND-PROPVALCHAR < 0
MOVE SPACES TO SV-PROPVALCHAR
ELSE
MOVE
SV-TN-PROPVALCHAR TO SV-PROPVALCHAR
MOVE ZEROES TO SV-IND-PROPVALCHAR
END-IF
IF
SV-TN-IND-PROPVALDATE < 0
MOVE SPACES TO SV-PROPVALDATE
ELSE
MOVE SV-TN-PROPVALDATE TO SV-PROPVALDATE
MOVE ZEROES TO SV-IND-PROPVALDATE
END-IF
IF SV-TN-IND-PROPVALNUMBER
< 0
MOVE ZEROES TO SV-PROPVALNUMBER
ELSE
MOVE SV-TN-PROPVALNUMBER TO
SV-PROPVALNUMBER
MOVE ZEROES TO SV-IND-PROPVALNUMBER
END-IF
*
IF SV-PF-TABLENAME
<> "RRPROPERTY"
IF
SV-TN-IND-DATESTART < 0
MOVE SPACES TO SV-DATESTART
ELSE
MOVE
SV-TN-DATESTART TO SV-DATESTART
END-IF
IF
SV-TN-IND-DATEEND < 0
MOVE SPACES TO SV-DATEEND
ELSE
MOVE
SV-TN-DATEEND TO SV-DATEEND
END-IF
END-IF
*
MOVE SV-TN-ROWID TO SV-ROWID
MOVE SV-TN-ROWVERSION TO SV-ROWVERSION
END-IF
END-IF.
*
IF SQL-OK
OR ( FIRSTTIME AND
SQL-NOT-FOUND)
* AND NOT SQL-NOT-FOUND
ADD 1 TO CT-MSG-PTR
PERFORM 2000-LOAD-MESSAGE
END-IF.
*
MOVE "N" TO
FL-FIRSTTIME.
*
*
MOVE '7500-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
7600-CLOSE-CURSOR SECTION. SYSGEN
*
*
MOVE '7600-START' TO
GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
EXEC SQL
SYSGEN
CLOSE SQL7000 SYSGEN
END-EXEC.
SYSGEN
*
*
MOVE '7600-END' TO GV-MSG.
*
CALL 'tslog' USING BY REFERENCE GV-TRACE.
*
*
9000-SQL-ERROR-ROUTINE
SECTION.
SYSGEN
*
MOVE SQLCODE TO SYSPFX-ERRORCODE. SYSGEN
MOVE SQLERRMC TO SYSPFX-ERRORMSG. SYSGEN
MOVE ZEROES TO SYSPFX-ERRORLOGID SYSGEN
SYSPFX-ROWLEN.
SYSGEN
MOVE CT-MSG-PTR TO SYSPFX-ROWCOUNT. SYSGEN
MOVE SV-TOTAL-ROWS TO
SYSPFX-ROWTOTAL
SYSGEN
MOVE SPACES TO SYSPFX-CONTINUE. SYSGEN
MOVE BGE018R1-VER TO SYSPFX-VERSIONID. SYSGEN
*
MOVE 4000 TO SV-SQL-LEN.
SYSGEN
CALL "SQLGLS" USING
BY REFERENCE SV-SQL-STMT,
SYSGEN
BY
REFERENCE SV-SQL-LEN,
SYSGEN
BY
REFERENCE SV-SQL-FC
SYSGEN
END-CALL.
SYSGEN
*
CALL "BERRLOG" USING
SYSPFX-REC,
SYSGEN
SV-SQL-STMT,
SYSGEN
SV-SQL-LEN
SYSGEN
END-CALL.
SYSGEN
*
STOP RUN.
* GOBACK.
SYSGEN
999999*