M
Member 310024
Guest
I am having trouble finding a good explanation/example
of how to use VARCHAR in a COBOL/DB2 program.
I am aware of the 2 x 49 levels concept,
the 1st 49 level being a 2-byte length,
and the 2nd 49 being a pic x(?) that is big enough
to hold the 'max-size' variable.
eg
03 DESCRIPTION.
49 DESCRIPTION-LENGTH PIC S9(04) COMP-3.
49 DESCRIPTION-TEXT PIC X(100).
In my embedded SQL SELECT, do I SELECT INTO DESCRIPTION
or DESCRIPTION-TEXT? I presume DESCRIPTION!
But say I want to do an INSERT or an UPDATE.
How do I set up my fields?
Do I say MOVE 'My Description' to DESCRIPTION
and then issue my UPDATE statement,
or do I say:
MOVE 'My Description' to DESCRIPTION-TEXT
and then MOVE 14 TO DESCRIPTION-LENGTH.
(Note: 'My Description' is 14 characters long.)
and then issue my UPDATE statement.
If it's the latter, then it means that my UPDATE
statement will have to break the pattern of the
target-name not matching the source-name
eg
EXEC SQL
UPDATE TABLE-XYZ
SET
DESCRIPTION = ESCRIPTION-TEXT
WHERE
etc ....
END-EXEC.
ie the source name is DESCRIPTION-TEXT, but
the target name is DESCRIPTION.
Is this how it works?
of how to use VARCHAR in a COBOL/DB2 program.
I am aware of the 2 x 49 levels concept,
the 1st 49 level being a 2-byte length,
and the 2nd 49 being a pic x(?) that is big enough
to hold the 'max-size' variable.
eg
03 DESCRIPTION.
49 DESCRIPTION-LENGTH PIC S9(04) COMP-3.
49 DESCRIPTION-TEXT PIC X(100).
In my embedded SQL SELECT, do I SELECT INTO DESCRIPTION
or DESCRIPTION-TEXT? I presume DESCRIPTION!
But say I want to do an INSERT or an UPDATE.
How do I set up my fields?
Do I say MOVE 'My Description' to DESCRIPTION
and then issue my UPDATE statement,
or do I say:
MOVE 'My Description' to DESCRIPTION-TEXT
and then MOVE 14 TO DESCRIPTION-LENGTH.
(Note: 'My Description' is 14 characters long.)
and then issue my UPDATE statement.
If it's the latter, then it means that my UPDATE
statement will have to break the pattern of the
target-name not matching the source-name
eg
EXEC SQL
UPDATE TABLE-XYZ
SET
DESCRIPTION = ESCRIPTION-TEXT
WHERE
etc ....
END-EXEC.
ie the source name is DESCRIPTION-TEXT, but
the target name is DESCRIPTION.
Is this how it works?