Apologies for the machine translation. I welcome the help of the editors (it has been some time since the last time).
COBOL does not have "strings", in the sense that there is no field with a terminal (such as a null or a new line) that COBOL would interpret as the end of piece of data.
COBOL has fields of fixed length.
How does Oacle know how long you have your user password and password? No.
You need to find out how Oracle can understand the length of your data.
The first approach is to consult the Pro * COBOL (Oracle COBOL) documentation. There you will see a data setting including VARYING for userid and password.
VARYING (in this particular context) belongs to Pro * COBOL. It would be considered a Language Extension for COBOL.
It is unclear which COBOL compiler you are using.
Gnucobol has ANYLENGTH, but is not (yet) available for WORKING-STORAGE settings. Micro Focus COBOL (if you are using one of them) may have ANYLENGTH or something equivalent: if you refer to the / Knowledgebase documentation, I would hope that you can find something.
However, it can be done on any simple COBOL, although you need to calculate the length of the data yourself (it will not be automatic, unlike VARYING and ANYLENGTH).
First, you need to understand how Oracle expects data to reach it from Pro * COBOL.
What VARYING actually does, can be defined as this:
01 Senha do usuário.
05 UP-Length COMP-5 PIC 9 (4).
05 UP-Username PIC X (30).
Oracle expects a type "varchar". A binary of two bytes (integers) in length, immediatelt before the data.
You MOVE your required userid to UP-Username, then you would work out how many traiing blanks there are in the field, subtract that from 30, and put the result in UP-Length. Depending on the COBOL compiler you have, there are more or less easy ways to do this.
You need to do this for all fields of type "varchar".
Without the length before the data, Oracle would have used the first two characters of data as a binary integer.
Original English:
COBOL does not have "strings", in the sense that there is no field with a terminal (like a null or a newline) which COBOL would interpret as being the end of Piece of data.
COBOL has Fixed-length Fields.
How does Oacle know how long your userid and password are? It doesn’t.
You need to find out how Oracle can understand the length of your data.
First approach is to Consult the Pro*COBOL (Oracle’s COBOL) Ocumentation. There you will see a data-Definition including VARYING for the userid and password.
VARYING (in that particular context) belongs to Pro*COBOL. It would be considered a Language Extension for COBOL.
It is not clear which COBOL Compiler you are using.
Gnucobol does have ANYLENGTH, but it is not (yet) available for WORKING-STORAGE Definitions. Micro Focus COBOL (if you happen to be using one of theirs) may have ANYLENGTH or Something equivalent: if you Consult their Documentation/Knowledgebase, I’d expect you may find Something.
However, it can be done in any Plain COBOL, Although you need to work out the length of the data yourself (it will not be Automatic, Unlike the VARYING and the ANYLENGTH).
First, you need to understand how Oracle expects the data to arrive to it from Pro*COBOL.
What the VARYING Actually does, can be defined like this:
01 User-Password.
05 UP-Length COMP-5 PIC 9(4).
05 UP-Username PIC X(30).
Oracle expects a "varchar"-type. A two-byte Binary (integer) length, immediatelt before the data.
You would MOVE your required userid to UP-Username, then you would work out how Many traiing Blanks there are in the field, subtract that from 30, and put the result into UP-Length. Depending on which COBOL Compiler you have, there are more or Less easy Ways to do that.
You need to do that for all "varchar"-type Fields.
Without the length before the data, Oracle would have used the first two characters of data as a Binary integer.
Can Voce show settings for your host variables?
– Bill Woodger
LISTENER= (Description= (address_list)= (address=(Protocol=tcp)(host=127.0.0.1)(port=1521)) (ADDRESS = (PROTOCOL=IPC)(KEY=IPC)) ) SID_LIST_LISTER = (SID_LIST = (SID_DESC = (SID_NAME = orcl)&##Xa; (ORACLE_HOME = /home/cat/app/cat/product/11.2.0/dbhome_1/bin) (PROGRAM = dg4odbc) ) ) ADR_BASE_LISTENER = /home/cat/app/cat/product/11.2.0/dbhome_1/bin/oracle
– orlando
tnsnames.ora Network Configuration File: /home/cat/app/cat/product/11.2.0/dbhome_1/network/admin/tnsnames.ora /home/cat/app/product/11.2.0/dbhome_1/network/admin/tnsnames.ora # Generated by Oracle Configuration tools. LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = PROCEXT)) ) ORCL = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT= 1521)) (CONNECT_DATA=(SID=orcl)) )
– orlando
USERNAME and PASSWD. Definitions in COBOL WORKING-STORAGE SECTION, sff.
– Bill Woodger
I have tried with USERNAME='JEFF' and PASSWD='ORACLEPASSWORD', which was a user I created in sqlplus. Now I’m trying with: 01 dsn pic x(130) value "Driver={Oracle ODBC Driver}; - "Dbq=ORCL.SITE;Uid=sys;Pwd=africa12;".
– orlando