My COBOL program cannot connect to oracle when the password field is defined longer than actual password length for a user. i.e, if the password value is 'mypasswd', the host variable to keep password must be defined with "PIC X(8)", otherwise, connection will fail; for example:
1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. SAMPLE.
3 ENVIRONMENT DIVISION.
4 DATA DIVISION.
5 WORKING-STORAGE SECTION.
6 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
7 01 USERNAME PIC X(010).
8 01 PASSWD PIC X(010).
9 01 DBSTRING PIC X(020).
10 EXEC SQL END DECLARE SECTION END-EXEC.
11 EXEC SQL INCLUDE SQLCA END-EXEC.
12
13 PROCEDURE DIVISION.
14 BEGIN-PGM.
15 EXEC SQL WHENEVER SQLERROR
16 DO PERFORM SQL-ERROR
17 END-EXEC.
18 LOGON.
19 MOVE "myuser" TO USERNAME.
20 MOVE "mypasswd" TO PASSWD.
21 MOVE "mydb" TO DBSTRING.
22 EXEC SQL
23 CONNECT :USERNAME IDENTIFIED BY :PASSWD USING :DBSTRING
24 END-EXEC.
25 LOGOUT.
26 DISPLAY "HAVE A GOOD DAY.".
27 EXEC SQL COMMIT WORK RELEASE END-EXEC.
28 STOP RUN.
29 SQL-ERROR.
30 EXEC SQL WHENEVER SQLERROR CONTINUE END-EXEC.
31 DISPLAY "ORACLE ERROR DETECTED:".
32 DISPLAY SQLERRMC.
33 EXEC SQL ROLLBACK WORK RELEASE END-EXEC.
34 STOP RUN.
I must get a connect failure: ORACLE ERROR DETECTED: ORA-01017: invalid username/password; logon denied
But when I change the password field definition to: 8 01 PASSWD PIC X(008). i.e. length is the same length of real password value (length("mypasswd")=8), the program can connect to Oracle successfully.
My situation is that we need users to be able to provide their own username and password, so we must firstly define a username and password fields long enough to keep the maximum length we allow. However, as stated above, all connection requests will be failed if a user chooses a shorter password than the maximum.
The program is migrated from an old version of Oracle 11.2.0.1.0, where we don't have this issue, the program was working fine, the connect operation was successful. But the problem occurred after we migrate to Oracle 12.1.0.1.0.