PetePhillips
Programmer
I'm an IBM Cobol DB2/SQL programmer learning Oracle ProCobol.
The A96109 ProCobol PreCompiler Programmer's Guide 9.2 contains SAMPLE1.PCO on page 2-30 :
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME PIC X(10) VARYING.
01 EMP-REC-VARS.
05 EMP-NAME PIC X(10) VARYING.
05 PASSWD PIC X(10) VARYING.
EXEC SQL END DECLARE SECTION END-EXEC.
MOVE "SCOTT" TO USERNAME-ARR.
MOVE 5 TO USERNAME-LEN.
MOVE "TIGER" TO PASSWD-ARR.
MOVE 5 TO PASSWD-LEN.
EXEC SQL CONNECT :USERNAME IDENTIFIED BY ASSWD
END-EXEC.
QUESTIONS :
1. USERNAME-ARR and USERNAME-LEN are not explicitly
declared.
Does the precompiler generate these field name suffixes
for VARYING variables ?
2.'The DECLARE section is optional' (p.2-20).
What happens if I omit it and code :
01 USERNAME PIC X(10) VARYING.
I don't think VARYING is a valid Cobol datatype (should
be OCCURS DEPENDING).
3. I have forgotten what Cobol datatype is generated
for a DB2 VARCHAR. Is it an ODO ?
4. The code also moves spaces to the host variable EMP-NAME- ARR prior to a SELECT. What happens if you don't ?
5. IBM has a DCLGEN utility which generates data
structures from existing DB2 tables to be EXEC SQL
INCLUDEd.
In Oracle should I code my own structures and EXEC SQL
INCLUDE them ?
6. The hardcoded username and password are naive.
Do I AUTO_CONNECT, automatic logon (p.3-9) ?
What's 'best practice' for connects ?
Thankyou.
The A96109 ProCobol PreCompiler Programmer's Guide 9.2 contains SAMPLE1.PCO on page 2-30 :
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME PIC X(10) VARYING.
01 EMP-REC-VARS.
05 EMP-NAME PIC X(10) VARYING.
05 PASSWD PIC X(10) VARYING.
EXEC SQL END DECLARE SECTION END-EXEC.
MOVE "SCOTT" TO USERNAME-ARR.
MOVE 5 TO USERNAME-LEN.
MOVE "TIGER" TO PASSWD-ARR.
MOVE 5 TO PASSWD-LEN.
EXEC SQL CONNECT :USERNAME IDENTIFIED BY ASSWD
END-EXEC.
QUESTIONS :
1. USERNAME-ARR and USERNAME-LEN are not explicitly
declared.
Does the precompiler generate these field name suffixes
for VARYING variables ?
2.'The DECLARE section is optional' (p.2-20).
What happens if I omit it and code :
01 USERNAME PIC X(10) VARYING.
I don't think VARYING is a valid Cobol datatype (should
be OCCURS DEPENDING).
3. I have forgotten what Cobol datatype is generated
for a DB2 VARCHAR. Is it an ODO ?
4. The code also moves spaces to the host variable EMP-NAME- ARR prior to a SELECT. What happens if you don't ?
5. IBM has a DCLGEN utility which generates data
structures from existing DB2 tables to be EXEC SQL
INCLUDEd.
In Oracle should I code my own structures and EXEC SQL
INCLUDE them ?
6. The hardcoded username and password are naive.
Do I AUTO_CONNECT, automatic logon (p.3-9) ?
What's 'best practice' for connects ?
Thankyou.