Menu

cobol and oracle database

Anonymous
2014-08-07
2016-05-10
1 2 > >> (Page 1 of 2)
  • Anonymous

    Anonymous - 2014-08-07

    Hello my name is Johann Guttner and I would like your help please because I am a beginner with Cobol
    I am using Oracle Database and did already compile Cobol source code with SQL and Cobol Code I found on the Internet using GNUCobol Version 2.0
    I did so with Pro*Cobol Compiler from Oracle

    I saw esqlOC but this is just for MySQL
    I want to connect to my Oracle Database with a small Cobol Program but I do not know how
    If possible I would like to connect with Connection string with DSN

    I use Oracle Linux 6.5 and I tried to install GNUCobol too but it says GMP Header and Library do not match
    So I compile with Pro*Cobol first and compile later with Cygwin
    I hope you people can help me and I thank you for it

     
  • Anonymous

    Anonymous - 2014-08-07

    I think I made progress
    I used Code fragements from the Internet
    I compiled again with Pro*Cobol, now I compile with GNUCobol and it there is no error.
    but when I run the program it shows me

    datenbank.cbl: 132: libcob: Cannot find module 'sqladr'

    because I cannot install GNUCobol on Oracle Linux 6.5 I compiled it with Lubuntu now
    I copied libsql12.a and libclntsh.so.12.1 to Lubuntu
    I used this command here

    export COB_LIBRARY_PATH="~/Desktop/lib/"
    COB_PRE_LOAD=libsql12.a
    cobc -x -I ./copy/ -L ./lib/ -sql12.a
    export COB_LIBRARY_PATH="~/Desktop/lib/"
    COB_PRE_LOAD=libsql12.a
    ./datenbank

    and I also tried with clntsh instead of sql12
    I renamed "CALL SQLADR" to "CALL sqladr" also because libsql12.a has lower characters with sqladr
    thank you again

     
  • Simon Sobisch

    Simon Sobisch - 2014-08-07

    I've never used Pro*COBOL before. Without further investigation I think libsql12.a may be a static library (just add it to your cobc command line in this case, for example 'cobc -x -I ./copy datenbank.cbl libsql12.a') while libclntsh.so (Where did you copied the .so.12.1 file from?) is a dynamically loading library (which should be renamed to .so and put into environment via export COB_PRE_LOAD=libclntsh (.so will be added by libcob))?

    If you're sure sqladr is exported only with lower characters the change to lowercase is correct.

    What does the manual for Pro*COBOL says?

    Simon

     
  • Anonymous

    Anonymous - 2014-08-08

    I tried with 'cobc -x -I ./copy datenbank.cbl libsql12.a'
    It did not work
    I renamed to libclntsh.so too
    I copied the .so.12.1 file from $ORACLE_HOME$/lib

    This files come from Oracle Database Version 12c
    Oracle says:
    For clarity and ease of development, the library structure is changed starting with Oracle Database 12c Release 1 (12.1). The client shared library, libclntsh.so.12.1, depends on libclntshcore.so.12.1. The libclntshcore.so.12.1 library contains the NLS and CORE functionality. Both of these libraries must be installed in the same directory.

    And yes I copied libclntshcore too
    Oracle Documentation about Pro*Cobol is not very good
    Maybe it is better if I am able to install GNUCobol on Oracle Linux Server 6.5 because everything else is installed there already

    You do not know how to solve this GMP Error or?
    [oracle@localhost gnu-cobol-2.0]$ ./configure -enable-debug
    .
    .
    .
    .
    checking gmp.h usability... yes
    checking gmp.h presence... yes
    checking for gmp.h... yes
    checking for __gmpz_init in -lgmp... yes
    checking matching GMP version ... no
    Header has version 6.0.0
    Library has version 4.3.1
    configure: error: Unable to use GMP - Please check config.log

     
  • Anonymous

    Anonymous - 2014-08-11

    does noone at least know how to fix the GMP Error?

     
  • Brian

    Brian - 2014-08-11

    as far as I'm aware you probably installed gmp with yum.
    ol6.repo is pretty old not to say ancient which leads to your library version 4.3.1 .

    did you try to install gmp from source?

     
  • Anonymous

    Anonymous - 2014-08-12

    I installed gmp6-0-0 now and now I get this Error when I do ./configure --enable-debug

    configure: error: Unable to extract GMP version information from gmp.h

    I tried to run configure with Administrator too

     
    • Brian

      Brian - 2014-08-13

      this has nothing to do with gmp.h .
      it's IMHO a missing symbolic link.
      I'm pretty sure you're using a 64bit oracle linux.

      do something like this:

      ::php
      
      locate libgmp
      e.g. output: /usr/local/lib/libgmp.so.10
      sudo ln -s /usr/local/lib/libgmp.so.10 /usr/lib64/libgmp.so.10
      

      best wishes,
      Brian

       
  • Simon Sobisch

    Simon Sobisch - 2014-08-12

    Sounds weird. How did you installed gmp?
    Please post config.log and we will see more details.

    BTW: You do know that your configure line leads to debugging symbols in GNU Cobol, don't you?

    Simon

     
  • Anonymous

    Anonymous - 2014-08-13

    Thank you Brian I was able to install GNUCobol now and I was able to compile everything without SQLADR Error
    But I get a Error when I run the program now
    Pro*Cobol makes a "CALL SQLBEX" into my program and it crashes when it wants to be called

    the Error says
    Attempt to reference unallocated memory (Signal SIGSEGV)

     
  • Klaus Schäfer

    Klaus Schäfer - 2014-08-13

    Can you post the program and markt the part with the error ? May be there is something missing, what the precompiler is not printing out sqlca or other things. I wrote many sql-oracle-Programs on an IBM Z/OS-Host with Cobol85 and they work fine.

     
  • Klaus Schäfer

    Klaus Schäfer - 2014-08-13

    are all libs same architecture all 64Bit or all 32Bit ?

     
  • Anonymous

    Anonymous - 2014-08-14

    I do not know if all are 64bit how shall I check that?

    I tried this program

    ::cobol
             identification division.
             program-id. oracle.
             data division.
             working-storage section.
                     exec sql include sqlca end-exec.
                     exec sql begin declare section end-exec.
             01 username pic x(10).
             01 password pic x(10).
                     exec sql end declare section end-exec.
    
             procedure division.
             login.
                     move "pmuser" to username. 
                     move "oracle" to password. 
                     display "sql connecting".
                     exec sql 
                         connect :username identified by :password 
                     end-exec. 
                     display "sql connected".
    

    It crashes with the Database Login

    ::cobol
          *          exec sql 
          *              connect :username identified by :password 
          *          end-exec.
                     MOVE 10 TO SQL-ITERS
                     MOVE 5 TO SQL-OFFSET
                     MOVE 0 TO SQL-OCCURS
                     CALL "SQLADR" USING
                         SQLCUD
                         SQL-CUD
                     CALL "SQLADR" USING
                         SQLCA
                         SQL-SQLEST
                     MOVE 4352 TO SQL-SQLETY
                     CALL "SQLADR" USING
                         USERNAME
                         SQL-SQHSTV(1)
                     MOVE 10 TO SQL-SQHSTL(1)
                     MOVE 10 TO SQL-SQHSTS(1)
                     MOVE 0 TO SQL-SQINDV(1)
                     MOVE 0 TO SQL-SQINDS(1)
                     MOVE 0 TO SQL-SQHARM(1)
                     CALL "SQLADR" USING
                         PASSWORD
                         SQL-SQHSTV(2)
                     MOVE 10 TO SQL-SQHSTL(2)
                     MOVE 10 TO SQL-SQHSTS(2)
                     MOVE 0 TO SQL-SQINDV(2)
                     MOVE 0 TO SQL-SQINDS(2)
                     MOVE 0 TO SQL-SQHARM(2)
                     CALL "SQLADR" USING
                         SQL-SQHSTV(1)
                         SQL-SQPHSV
                     CALL "SQLADR" USING
                         SQL-SQHSTL(1)
                         SQL-SQPHSL
                     CALL "SQLADR" USING
                         SQL-SQHSTS(1)
                         SQL-SQPHSS
                     CALL "SQLADR" USING
                         SQL-SQINDV(1)
                         SQL-SQPIND
                     CALL "SQLADR" USING
                         SQL-SQINDS(1)
                         SQL-SQPINS
                     CALL "SQLADR" USING
                         SQL-SQHARM(1)
                         SQL-SQPARM
                     CALL "SQLADR" USING
                         SQL-SQHARC(1)
                         SQL-SQPARC
    
                     CALL "SQLBEX" USING
                         SQLCTX
                         SQLEXD
                         SQLFPN
                         .
                     display "sql connected".
    

    run:

    [oracle@localhost Desktop]$ ./oracle
    sql connecting
    
    oracle.cob: 180: Attempt to reference unallocated memory (Signal SIGSEGV)
    Abnormal termination - File contents may be incorrect
    
     

    Last edit: Simon Sobisch 2014-09-11
  • Brian

    Brian - 2014-08-14

    @Johann: I'm 99.9% sure to know the cause of your problem.
    you should register to be able to post without moderation and I'd also send you a private message with my skype id if you need further help.

    best wishes,
    Brian

     
    • Andoli

      Andoli - 2014-09-11

      Hi Brian I have the same problem. Have you find a solution?
      Andrea

       
      • Brian

        Brian - 2014-09-15

        hi Andrea,

        does your problem still persist?
        if so pls check for correct COMP/COMP-5 config settings first

        best wishes,
        Brian

         
        • Andoli

          Andoli - 2014-09-15

          Thanks Brian for support,
          where I found instruction for right configuration?
          I tried to put in the file pcbcfg.cfg "Comp5 = yes" and "Comp5 = no" without solving the problem.
          Andrea

           
          • Brian

            Brian - 2014-09-15

            okay Andrea,

            could you clarify what your exact problem is?
            if possible provide some code for better explanation please.

            best wishes,
            Brian

             
            • Anonymous

              Anonymous - 2014-09-15

              This is the code Brian:


              ::cobol
                     IDENTIFICATION DIVISION.
                     PROGRAM-ID. RDS-TEST.
                    **********************************************
                    * Test connessione a db                      *
                    **********************************************
                     ENVIRONMENT DIVISION.
                     CONFIGURATION SECTION.
                     INPUT-OUTPUT SECTION.
                     DATA DIVISION.                                                           
                    *
                     WORKING-STORAGE SECTION.
                    *
                         EXEC SQL BEGIN DECLARE SECTION END-EXEC.
                    *
                     01  WK-USER              PIC X(10)  VARYING.
                     01  WK-PWD               PIC X(10)  VARYING.
                     01  OWK-DB               PIC X(10)  VARYING.
                    *
                         EXEC SQL END DECLARE SECTION END-EXEC.
              
                    *
                         EXEC SQL INCLUDE SQLCA.COB END-EXEC.
                    *
                     PROCEDURE DIVISION.                                                      
                    *
                     CONNESSIONE-ORACLE.
                         DISPLAY "COLLEGAMENTO AL DB IN CORSO...".
                         MOVE "********" TO WK-USER.
                         MOVE "********" TO WK-PWD.
                         MOVE "***" TO OWK-DB.
                         EXEC SQL WHENEVER SQLWARNING CONTINUE END-EXEC.
                         EXEC SQL WHENEVER SQLERROR GOTO CHIUDI END-EXEC.
                         EXEC SQL WHENEVER NOT FOUND GOTO CHIUDI END-EXEC.
                    *
                     CONNECT-ORACLE.
                         EXEC SQL 
                              CONNECT :WK-USER IDENTIFIED BY :WK-PWD
                              AT :OWK-DB USING :OWK-DB
                         END-EXEC.
                         DISPLAY "COLLEGAMENTO AL DB RIUSCITO!".
                    *
                     CHIUDI.
                         DISPLAY SQLERRMC.
                         STOP RUN.
              

              This is my pcbcfg.cfg parameter

              ::text
              define=bit64
              picx=varchar2
              comp5=yes
              mode=oracle
              maxopencursors=40
              

              This is my procob.mk

              ::text
              COB=cobc
              
              # InstantClient Directories.
              ICSDKHOME=$(ORACLE_HOME)/sdk
              ICLIBHOME=$(ORACLE_HOME)/
              
              MKLINK=ln
              REMOVE=rm -rf
              CLNCACHE=cleancache
              CACHEDIR=SunWS_cachea
              MAKE=make
              MAKEFILE=procob.mk
              PROCOBDEMO=$(ORACLE_HOME)/*
              
              PROCOB=$(ICSDKHOME)/procob
              ICLIBPATH=$(LDPATHFLAG)$(ICLIBHOME)
              SO_EXT=.so
              # MICROFOCUS
              # COBFLAGS=-C IBMCOMP -C NESTCALL -t -x
              # OPENCOBOL
              COBFLAGS=-x 
              #PROCOBFLAGS=picx=varchar2
              LDPATHFLAG=-L
              COBSQLINTF=$(ICLIBHOME)cobsqlintf.o
              LDLIBS=$(EXSYSLIBS) $(MATHLIB) $(USRLIBS)
              EXSYSLIBS=-ldl
              MATHLIB=-lm
              COBOL_PROLDLIBS=$(SHARED_CLIENTLIBS) $(LDLIBS)
              SHARED_CLIENTLIBS=$(LLIBCLNTSH) $(LDFLAGS)
              LLIBCLNTSH=$(LDLIBFLAG)$(LIBCLNTSHNAME)
              LDLIBFLAG=-l
              LIBCLNTCORENAME=clntshcore
              LIBCLNTSHNAME=clntsh
              LDFLAGS=-g
              
              DEMO_PROCOB_BUILD=$(COB) $(COBFLAGS) -o $(EXE) $(COBS) $(ICLIBPATH) $(COBSQLINTF) $(COBOL_PROLDLIBS)
              #DEMO_PROCOB_BUILD=$(COB) -x -o $(EXE) $(COBS) $(ICLIBPATH) $(COBSQLINTF) $(COBOL_PROLDLIBS)
              
              ##### MICROFOCUS
              #DEMO_PROCOB_BUILD_SHARED=$(COB) $(COBFLAGS) -o $(EXE) $(COBS) $(LDPATHFLAG)$(LIBHOME) $(COBSQLINTF) $(COBOL_PROLDLIBS)
              
              ##### OPENCOBOL
              #DEMO_PROCOB_BUILD_SHARED=$(COB) $(COBFLAGS) $(COBS) $(LDPATHFLAG)$(LIBHOME) $(COBSQLINTF) $(COBOL_PROLDLIBS)
              
              ##### MICROFOCUS
              #DEMO_PROCOB_BUILD_STATIC=$(COB) $(COBFLAGS) -o $(EXE) $(COBS) $(LDPATHFLAG)$(LIBHOME) $(COBSQLINTF) $(COBOL_STATICPROLDLIBS)
              
              ##### OPENCOBOL
              #DEMO_PROCOB_BUILD_STATIC=$(COB) $(COBFLAGS) $(COBS) $(LDPATHFLAG)$(LIBHOME) $(COBSQLINTF) $(COBOL_STATICPROLDLIBS)
              
              #-----------------------------------------------------------------------------
              # Targets for building the procob sample programs.
              #
              # The target 'build' puts together an executable $(EXE) from the cobol
              # sources in $(COBS) and the libraries in $(COBOL_PROLDLIBS).
              # The rules to make .cob files from .pco files are later in this file.
              #
              all: clean $(PROCOBDEMO)
              
              $(PROCOBDEMO):
                  $(MAKE) -f $(MAKEFILE) build COBS=$@.cob EXE=$@
              
              build: $(CLNCACHE) $(COBS)
                  $(MKLINK) $(ICLIBHOME)libclntshcore$(SO_EXT).12.1 $(ICLIBHOME)libclntshcore$(SO_EXT)
                  $(MKLINK) $(ICLIBHOME)libclntsh$(SO_EXT).12.1 $(ICLIBHOME)libclntsh$(SO_EXT)
                  $(DEMO_PROCOB_BUILD)
                  $(REMOVE) $(ICLIBHOME)libclntshcore$(SO_EXT)
                  $(REMOVE) $(ICLIBHOME)libclntsh$(SO_EXT)
              
              #
              .SUFFIXES: .cob .cbl .o .pco $(GNT)
              
              .pco.cob:
                  $(PROCOB) $(PROCOBFLAGS) iname=$*.pco
              
              .cob$(GNT):
                  $(COB2GNT)
              
              clean: $(CLNCACHE)
                  $(REMOVE) $(PROCOBDEMO) $(PROCOBDEMO).o $(PROCOBDEMO).cob $(PROCOBDEMO).lis $(PROCOBDEMO).int $(PROCOBDEMO).idy 
              
              cleancache:
                  $(REMOVE) $(CACHEDIR)
                  $(REMOVE) $(ICLIBHOME)libclntshcore$(SO_EXT)
                  $(REMOVE) $(ICLIBHOME)libclntsh$(SO_EXT)
              

              When I compile this is output:

              ::text
              rm -rf SunWS_cachea
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntsh.so
              /usr/lib/oracle/instantclient_12_1/sdk/procob  iname=/WRK/COBOL/SORGENTI/rds-test.pco
              
              Pro*COBOL: Release 12.1.0.2.0 - Production on Mon Sep 15 11:32:11 2014
              
              Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
              
              System default option values taken from: /usr/lib/oracle/instantclient_12_1/precomp/admin/pcbcfg.cfg
              
              ln /usr/lib/oracle/instantclient_12_1/libclntshcore.so.12.1 /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              ln /usr/lib/oracle/instantclient_12_1/libclntsh.so.12.1 /usr/lib/oracle/instantclient_12_1/libclntsh.so
              cobc -x  -o /WRK/COBOL/COMPILE/rds-test /WRK/COBOL/SORGENTI/rds-test.cob -L/usr/lib/oracle/instantclient_12_1/ /usr/lib/oracle/instantclient_12_1/cobsqlintf.o -lclntsh -g -ldl -lm
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntsh.so
              RDS oracle@opencobol:/WRK/COBOL/SORGENTI$ ./compila-oracle rds-test
              rm -rf SunWS_cachea
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntsh.so
              ln /usr/lib/oracle/instantclient_12_1/libclntshcore.so.12.1 /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              ln /usr/lib/oracle/instantclient_12_1/libclntsh.so.12.1 /usr/lib/oracle/instantclient_12_1/libclntsh.so
              cobc -x  -o /WRK/COBOL/COMPILE/rds-test /WRK/COBOL/SORGENTI/rds-test.cob -L/usr/lib/oracle/instantclient_12_1/ /usr/lib/oracle/instantclient_12_1/cobsqlintf.o -lclntsh -g -ldl -lm
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntshcore.so
              rm -rf /usr/lib/oracle/instantclient_12_1/libclntsh.so
              

              When I run the program... this is the error:

              ::text
               ./rds-test
              COLLEGAMENTO AL DB IN CORSO...
              
              /WRK/COBOL/SORGENTI/rds-test.cob: 243: Attempt to reference unallocated memory (Signal SIGSEGV)
              Abnormal termination - File contents may be incorrect
              

              At line 243 in rds-test.cob there is this instruction:

              ::text
              236           CALL "SQLADR" USING
              237               SQL-SQHARM(1)
              238               SQL-SQPARM
              239           CALL "SQLADR" USING
              240               SQL-SQHARC(1)
              241               SQL-SQPARC
              242
              243           CALL "SQLBEX" USING
              244               SQLCTX
              245               SQLEXD
              246               SQLFPN
              247
              248       IF SQLCODE IN SQLCA IS LESS THAN 0
              249             THEN GO TO CHIUDI END-IF.
              250          DISPLAY "COLLEGAMENTO AL DB RIUSCITO!".
              251
              

              The error is generated if I declare the variable "PIC X" as "varying". If I do not put "varying" this runtime error does not appear but unfortunately not applied the parameter "Picx = varchar2" but "Picx = Charf" although in the configuration file (pcbcfg.cfg) there is.
              Not removing the spaces in the bottom of the strings and the connection fails, however, the activity with sql strings become complicated ...
              You need some more information?
              I hope that I have not posted too much stuff ...

              Thanks a lot.
              Andrea

               

              Last edit: Brian Tiffin 2014-10-14
            • Andoli

              Andoli - 2014-09-15

              My code is the same of "Anonymous" posted 2014-08-14, the only difference is on variable declaration (I put VARYING).

              The runtime error (Attempt to reference unallocated memory (Signal SIGSEGV)
              Abnormal termination - File contents may be incorrect) is generated if I declare the variable "PIC X" as "varying". If I do not put "varying" this runtime error does not appear but unfortunately not applied the parameter "Picx = varchar2" but "Picx = Charf" although in the configuration file (pcbcfg.cfg) there is.
              Not removing the spaces in the bottom of the strings and the connection fails, however, the activity with sql strings become complicated ...

               
              • Brian

                Brian - 2014-09-15

                Oracle DB needs to know the password and username length.
                in your code you only supply pw & username.

                you also need something like:
                MOVE 10 TO PASSWORD-LEN.
                MOVE 10 TO USERNAME-LEN.

                 
                • Andoli

                  Andoli - 2014-09-16

                  Hi Brian,
                  problems persist in every way ...
                  If I use the statement "VARYING" I have a runtime error "Attempt to reference unallocated memory (Signal SIGSEGV)", also adding correctly the "MOVE" you suggested
                  But if I do not use "VARYING" I can not operate the variables "PIC X" as "varchar" instead of "Charf." In pcbcfg file (Oracle precompiler) I put "Picx = varchar2" without results ...

                  Thanks for your patience

                  Andrea

                   
                  • Andoli

                    Andoli - 2014-09-16

                    I've found this note on Oracle support... maybe...
                    My Oracle Client e Precompiler are 64bit (12.1 release).
                    I've installed Opencobol 2.0 but where can i found if it is 64 or 32?

                     
                    • Brian

                      Brian - 2014-09-16

                      you can use the 'file' command if you've produced an executable (cobc -x)

                      e.g.:

                      'file ~/Desktop/gnuc'

                      or

                      'file gnuc' if you already are in the working directory

                       

                      Last edit: Brian 2014-09-16
                      • Andoli

                        Andoli - 2014-09-16

                        ok is 64 bit
                        ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=5ea1697b84416c488fc55d0b2977f21494533ff0, not stripped

                        Oracle client and precompiler sdk is 64 bit too.

                        This is not the right way ...

                        I keep looking for the solution to the problem ...

                        Thanks

                         
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.