Quantcast
Channel: Visual COBOL
Viewing all articles
Browse latest Browse all 5819

Forum Post: Micro Focus COBOL new style and old style

$
0
0
I compared side by side of 2 COBOL code styles and hopefully someone can tell me how to do it: Old style: ---Connect.sqb ==============================================        Working-Storage Section.            copy "sqlenv.cbl".            copy "sql.cbl".            copy "sqlca.cbl".            EXEC SQL BEGIN DECLARE SECTION END-EXEC.        01 dbalias.           49 dbalias-len    pic s9(4) comp-5 value 0.           49 dbalias-buf    pic x(9) value " ".        01 userid.           49 userid-len     pic s9(4) comp-5 value 0.           49 userid-buf     pic x(128) value " ".        01 pswd.           49 pswd-len       pic s9(4) comp-5 value 0.           49 pswd-buf       pic x(19).            EXEC SQL END DECLARE SECTION END-EXEC.       PROCEDURE DIVISION.            display "Enter database alias( 'sample' by default): "               with no advancing.            accept dbalias-buf.            if dbalias-buf = spaces               move "sample" to dbalias-buf.            inspect dbalias-buf               tallying dbalias-len for characters before initial " ".            display "Enter user id( current by default)        : "               with no advancing.            accept userid-buf.            inspect userid-buf               tallying userid-len for characters before initial " ".            if userid-buf not equal spaces               display "Enter password                            : "                  with no advancing               accept pswd-buf.               inspect pswd-buf                  tallying pswd-len for characters before initial " ".            if userid-buf = spaces               EXEC SQL CONNECT TO :dbalias END-EXEC            else               EXEC SQL                 CONNECT TO :dbalias USER :userid USING :pswd               END-EXEC. =================================================== I can use db2 command to create both  bind file and cbl file: db2 prep Connect.sqb  bindfile target mfcob CALL_RESOLUTION DEFERRED New style: ---Connect.sqb ============================================== working-storage section.            EXEC SQL INCLUDE SQLCA END-EXEC.        01 ws-db        pic x(08).        01 ws-usr       pic x(08).        01 ws-pass      pic x(18). procedure division.            EXEC SQL                CONNECT TO :ws-db USER :ws-usr  USING :ws-pass            END-EXEC        procedure division.            display "Enter database alias to connect to (Eg Sample) "                    with no advancing            accept ws-db            display "Enter username  "                     with no advancing            accept ws-usr            display "Enter password  "                     with no advancing            accept ws-pass            EXEC SQL                CONNECT TO :ws-db USER :ws-usr  USING :ws-pass            END-EXEC ========================================== With the new style I can create  both Connect.bnd file and executable from  Visual COBOL eclipse But with db2 command, db2 prep Connect.sqb  bindfile target mfcob CALL_RESOLUTION DEFERRED I create Connect.cbl but no Connect.bnd file with  error: ==================================================    57   SQL4911N  The host variable data type is not valid.    81   SQL4002N  "WS-PASS" and "WS-USR" are undeclared host                   variables that cannot both be used as descriptor names in a                   single SQL statement.   110   SQL4002N  "WS-VAR-PASS" and "WS-USR" are undeclared host                   variables that cannot both be used as descriptor names in a                   single SQL statement.         SQL0095N  No bind file was created because of previous                   errors. =============================================== Is there anyway -- without changing the code style,  I can make all Visual COBOL embedded samples  working under db2 command line? Thank you in advance, -Jack

Viewing all articles
Browse latest Browse all 5819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>