Menu

dbpre GNUCOBOL with mysql

Anonymous
2015-06-07
2021-11-28
<< < 1 2 3 4 5 > >> (Page 3 of 5)
  • Rob Heath

    Rob Heath - 2017-02-19

    Hello,
    I'm failing at this:- gcc -I/usr/include/mysql -c cobmysqlapi.c
    I don;t see the mysql file when I look in usr/include/ folders ?

    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0$ gcc -I/usr/include/mysql -c cobmysqlapi.c
    gcc: error: cobmysqlapi.c: No such file or directory
    gcc: fatal error: no input files
    compilation terminated.
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0$

    I run mysql from terminal like this:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0$ mysql -u root -p

    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 39
    Server version: 5.5.54-0ubuntu0.12.04.1 (Ubuntu)

    Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql>

    The packages I see installed are (see attachment):-
    I cannot see a package just called mysql?

    Am I misisng a program or package I need from somewhere?

    regards

    rob

     
  • Rob Heath

    Rob Heath - 2017-02-19

    I found mysql folder here on my system:- /etc/mysql
    So tried that in the gcc command:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ gcc -I/etc/mysql -c cobmysqlapi.c
    but it still cannot find the .h file?
    cobmysqlapi.c:27:26: fatal error: mysql.h: No such file or directory
    compilation terminated.

     
    • Vincent (Bryan) Coen

      Having installed the MySQL server did you also install the client
      libraries and sources ?

      See my early response to you some weeks? ago.

      Vince

      On 19/02/17 14:48, Rob Heath wrote:

      I found mysql folder here on my system:- /etc/mysql
      So tried that in the gcc command:-
      rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$
      gcc -I/etc/mysql -c cobmysqlapi.c
      but it still cannot find the .h file?
      cobmysqlapi.c:27:26: fatal error: mysql.h: No such file or directory
      compilation terminated.


       
  • Anonymous

    Anonymous - 2017-02-19

    I have added as many packages as I can see with mysql in them.
    Then I tried:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ gcc -I/usr/include/mysql -c cobmysqlapi.c
    This returned-
    cobmysqlapi.c: In function ‘MySQL_fetch_record’:
    cobmysqlapi.c:324:7: warning: format not a string literal and no format arguments [-Wformat-security]
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$
    I'm assuming a warning is not fatal so from here I tried c return
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ c
    c: command not found
    but in above I have:-
    c cobmysqlapi.c cobol-dir.png dbpre.c PCTB003B PCTB003B.param~ PCTB003B.sh PGCTBBAT README.TXT
    capi cobmysqlapi.o cPCTB003B dbpre-lower-folder.png PCTB003B.param PCTB003B.scb pctb3-pic.png PGCTBBATWS SQLCA

    Can you nudge me a bit further please?

    rgds
    rob

     
  • Rob Heath

    Rob Heath - 2017-02-19

    Because typing c at command line didn;t do anything.
    I ran the commands in the c file seperately and got:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ gcc dbpre.c -odbpre -O5 -ggdb
    dbpre.c: In function ‘main’:
    dbpre.c:1729:14: warning: ' ' flag used with ‘%s’ gnu_printf format [-Wformat]
    dbpre.c:1734:14: warning: ' ' flag used with ‘%s’ gnu_printf format [-Wformat]
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ sudo cp dbpre /usr/local/bin
    [sudo] password for rob:
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$

     
  • Rob Heath

    Rob Heath - 2017-02-19

    So I then followed:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ dbpre --help
    dbpre V 0.3 2014-06-02
    dbpre [options] progname

    Options

    -h, --help - this message
    -v, --version - print version of dbpre
    -I - specify path for copybooks, e.g -I/tmp/copybooks/
    -ts - tab stop, tabs will be expanded to nnn spaces, e.g. -ts=3

    Developed by the_piper@web.de
    For more infos see here: http://pipersopencoboltoolbox.blogspot.de/
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$

    I will now go and try the sample program you have given.

    Many many Thank yous for your patience so far.

    rob

     
  • Vincent (Bryan) Coen

    Last mail disappeared so trying again :

    The c file which is a command file but some what crude should work and it should be run at a command prompt in terminal or similar.
    The user as with all work should be done as your normal user and NOT as root.

    I seem to recall you are in the UK, if so email me at vbcoen at gmail dot com

    and I will send you my landline #

    Vince

     
  • Rob Heath

    Rob Heath - 2017-02-19

    BIG Thanks to Vince for kindly giving of his time.
    I have managed to get it running (with Vince's help).
    So finally I go to this directory:-
    /Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre
    I then compile PVTB003B by running this script that I makred as executable
    cPCTB003B
    After running this I go into mysql and build this table in database testdb :-
    mysql> describe example_table;
    +--------+----------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +--------+----------+------+-----+---------+-------+
    | field1 | char(20) | NO | | NULL | |
    | field2 | char(16) | NO | | NULL | |
    | field3 | char(32) | NO | | NULL | |
    +--------+----------+------+-----+---------+-------+
    3 rows in set (0.00 sec)
    I then execute program PVTB003B from dbpre folder with this command:-
    rob@rob-desktop:~/Programs/COBOL/COBSQLSTUFF/open-cobol-code-1417-branches-gnu-cobol-2.0/gnu-cobol-2.0/dbpre$ ./PCTB003B
    It runs no error messages and outputs End....: 2017-02-19 23:25:28
    Looking at the example_table after run in mysql I see:-
    mysql> select * from example_table;
    +---------------+--------+--------+
    | field1 | field2 | field3 |
    +---------------+--------+--------+
    | UpdatedValue1 | Value2 | Value3 |
    | 00000002 | Value2 | Value3 |
    | UpdatedValue3 | Value2 | Value3 |
    | 00000004 | Value2 | Value3 |
    | 00000005 | Value2 | Value3 |
    | 00000006 | Value2 | Value3 |
    | 00000007 | Value2 | Value3 |
    | 00000008 | Value2 | Value3 |
    | 00000009 | Value2 | Value3 |
    | 00000010 | Value2 | Value3 |
    +---------------+--------+--------+

    So I think big claps for everyone's kind help.
    I can attempt to use sql from cobol under ubuntu now.

    Thank you ;-)))))

    Vince, I will try and think about the more modern version and PCTB4 param stuff later.
    I think I need to read stuff about root as well.

    Thank you for all your time.

    Regards and many thanks

    rob

     
  • Alan Honeyman

    Alan Honeyman - 2020-06-24

    I'd like to use DBPRe on my windows system but have neither the skill nor knowledge of Linux/Unix to achieve the result. Has anyone compiled the DBPre program on windows and would be willing to guide me to achieving that result?

     
  • celsofigueiredo

    celsofigueiredo - 2020-06-27

    Dears.

    what do i have to do to make dbpre work in a windows environment?

    Celso henrique

     
  • Vincent (Bryan) Coen

    Follow the detailed instructions (in README.TXT) and build it having downloaded the sources for dbpre19 and installed the mysqld connector package.

    This assuming you have already installed Mysql or Mariadb.

    Then run it.

     
  • Alan Honeyman

    Alan Honeyman - 2020-06-28

    As I said above, the problem for me is how to compile the C++ program DBPre on a windows system.

     
    • Vincent (Bryan) Coen

      As I stated follow the instructions and run the scripts / batch files in
      order.

      So run :

      capi               - to compile the C api into an object file
      c                  - script to compile dbpre using gcc

      See README.TXT for more information and testing processes..

      This assumes you have installed : -

      gcc
      MySql   or mariadb
      the above connector package which includes the headers etc.

      GnuCobol

      run capi and after that is run ok then run c

      Yes he names his scripts very oddly.

      The above assumes you have fully installed the windows version  of
      gnucobol say from Arnold.

      On 28/06/2020 04:38, Alan Honeyman wrote:

      As I said above, the problem for me is how to compile the C++ program
      DBPre on a windows system.

       
  • The_Piper

    The_Piper - 2020-08-20

    BUMP

    Since i've been exchanging emails with Alan since a few days or weeks, i found somehow a solution.

    First fun fact: cobmysqlapi.c does not compile under Windows with dev-cpp, because it uses syslog.h (and its functions) for debugging/error reporting issues.

    So i have to do a few changes to cobmysqlapi.c, and that brings me to fact #2.

    I don't know which or where is the actual version of cobmysqlapi.c?

    The one i've been working with tonight is:
    **
    * Version 007--Changes to work together with GnuCobol either 1.xx and 2.xx
    * 05/18/2014--The_Piper@web.de 20140518
    **
    the one, which is in my dbpre project.

    Are there other versions of cobmysqlapi.c which ppl use?

    And since i am going to update the dbpre project at Sourceforge, are there any workarounds ppl use with dbpre, which should be added to the project?

    And if this all works, we will have a dbpre.exe for windows with a working cobmysqlapi :)

     
    • Alan Honeyman

      Alan Honeyman - 2020-08-20

      Piper, great work and thank you!

      Alan.

       

      Last edit: Simon Sobisch 2020-08-20
    • Simon Sobisch

      Simon Sobisch - 2020-08-20

      Is there any reason to use dev-cpp instead of:

      • grab Arnold's package (either the Mingw32 one or one of the MSYS2 versions)
      • use the contained GCC to compile cobjapi.c
       
  • The_Piper

    The_Piper - 2020-08-20

    @Simon
    No, there isnt except that i don't know what Arnold's package is. All i used to compile cobmysqlapi was gcc.exe.

     

    Last edit: The_Piper 2020-08-20
    • Simon Sobisch

      Simon Sobisch - 2020-08-20

      No, there isnt except except that i don't know what Arnold's package is

      Arnold took the responsibility to create the official mingw-based binary packages (I did this up to GC1.1 and am still happy that he does this now).
      You find the packages at https://arnoldtrembley.com/GnuCOBOL.htm#binaries for example https://arnoldtrembley.com/GC31-rc1-G-BDB-rename-7z-to-exe.7z - download, unpack wherever you like (if you don't have 7zip installed just rename to .exe for a self-extracting archive) and double click on set_env.cmd to start a new cmd-window with everything setup for common GnuCOBOL use,, including GCC.

      BTW @piper1: the @ sf-mensch was correct, leading to a notification, the @ + Simon will notify the user named that way

       
  • Vincent (Bryan) Coen

    Regarding version of the API lib :

    In the JC code base I have version 38 which heads show the following :

    /*  cob-mysql  Version  3.2                            18/May/2014    */
    /*  Copyright (C) sanpontze. All Rights Reserved                      */
    /*  cobmysqlapi versions 3.6 - 3.7, copyright. The_Piper, GPL v3      */
    /*                                                                    */
    /*  cobmysqlapi Version 3.8                                           */
    /*  Copyright (c) Vincent Coen, under GPL v3 2017 - 2018              */
    /*  Use with library sources from mysql-connector-c via mysql.com and
     *   other source locations                                           */
    /**********************************************************************
    *   Version 003--Changed to correctly map to COBOL data types.
    *                05/07/2009--Marc Rodriguez
    *   Version 004--Changed to correctly place NULLs into numeric types.
    *                1225978--Sandy Doss
    *                07/01/2009--Marc Rodriguez
    *   Version 005--Added new MySQL call to fetch entire row selected
    *                using "select *".  Also fixed potential bug in
    *                MySQL_fetch_row that compares number of passed
    *                parameters (inclusive of WS-MYSQL-RESULT) against
    *                number of fields returning from MySQL select.
    *                1331073--Jim Currey
    *                12/16/2009--Pete McThompson
    *
    *   Version 006--Changes to work together with the precompiler
    *                Added commit() and rollback() functions
    *                Added read_params()
    *                04/18/2012--The_Piper@web.de
    *
    *   Version 007--Changes to work together with GnuCobol either 1.xx and 2.xx
    *                05/18/2014--The_Piper@web.de 20140518
    *
    *   Version 3.8--Changed version style to n.yy
    *                Added mysql_sqlstate to get the ANSI & ODBC standard error codes
    *                A value that begins with "00" means no error.
    *                A value of "HY000" means general error.
    *                This value is used for those MySQL errors that have not yet
    *                 been assigned more-specific SQLSTATE codes.
    *                Why? because writing a dup key does not create an error within
    *                 SQL-ERR and for SQL_STATE it does (23000) there could be other
    *                examples of such:
    *                A full list of these codes can be found in :
    *                /usr/include/mysql/sql_state.h assuming you have installed
    *                mysql-connector-c-6.1.6-src.tar.gz (.rpm or .zip etc)
    *                Latest versions will always be available here :
    *                03 Jan 2017--Vincent Coen - Applewood Computers {170103}
    *                [http://www.applewood.linkpc.net/files/ ]
    *                then goto directory 
    *                MySQL-Pre-Compilers/JC-Versions/nightly/
    *   Version 3.8A--Updated url here as address has small change
    *                [http://www.applewood.linkpc.net/files/ ]
    *                v3.8 is corrected.
    

    As you can see from above notes for v3.8 it adds extra functionality which I use within my CAS accounting system to give extra feedback for errors / warnings during execution etc.

    This along with a script to build it as cobmysqlapi38.sh
    Contains only - -

    gcc -I/usr/local/mysql/include -c cobmysqlapi38.c -o cobmysqlapi.o -fPIC
    
     
  • The_Piper

    The_Piper - 2020-08-20

    Thanks @vcoen, found your version, and if no one else has concerns or suggestions, i'm going to add my changes to it and upload it to my sf dbpre project.

     
  • Vincent (Bryan) Coen

    When you have finished documented and tesed it please send me a copy so I can update versions here, pls use vbcoen <at> gmail.com</at>

    Ta

     
  • The_Piper

    The_Piper - 2020-08-21

    @vcoen
    Will do, it's already working with dbpre under Linux, with some minor changes/additions.

    Most important change was, a function in your cobmysqlapi.c was gone, get_cobol_version() and some defines for it.

    But nothing which should affect your changes.

    Going to work on that Windows related stuff, replacement for syslog.h, tomorrow or so.

    Oh, just an idea:

    Would it make sense to have a single place where "the official" cobmysqlapi.c is stored, maybe in the repository under tools?

    And @sf-mensch
    maybe add dbpre too to the tools in the repository?

     
    • Vincent (Bryan) Coen

      On 21/08/2020 02:00, The_Piper wrote:

      @vcoen https://sourceforge.net/u/vcoen/
      Will do, it's already working with dbpre under Linux, with some minor
      changes/additions.

      Most important change was, a function in your cobmysqlapi.c was gone,
      get_cobol_version() and some defines for it.

      But nothing which should affect your changes.

      Going to work on that Windows related stuff, replacement for syslog.h,
      tomorrow or so.

      Oh, just an idea:

      Would it make sense to have a single place where "the official"
      cobmysqlapi.c is stored, maybe in the repository under tools?

      I have no problem with that - just a question on if users can handle it ?

      Vince

       
  • The_Piper

    The_Piper - 2020-08-21

    LOL, and a hint about the naming conventions of my shell scripts :P

    Usually my development environment has 3 shell scripts:
    v c t

    v - vi the scource code to edit it
    c - compile the source code
    t - test, run the binary

    But since i've put all files in only one directory, its a little bit messy with only v c t.
    So i named the compile scripts c<progname> like cPCTB003B and should have done it too with other scripts.</progname>

    But since i am now working on dbpre again, i will change that and provide hopefully a better solution, like putting source code into directories and such.

    Shit happens :P

     
    • Vincent (Bryan) Coen

      On 21/08/2020 02:15, The_Piper wrote:

      LOL, and a hint about the naming conventions of my shell scripts :P

      Usually my development environment has 3 shell scripts:
      v c t

      v - vi the scource code to edit it
      c - compile the source code
      t - test, run the binary

      But since i've put all files in only one directory, its a little bit
      messy with only v c t.
      So i named the compile scripts c<progname> like cPCTB003B and should
      have done it too with other scripts.</progname>

      But since i am now working on dbpre again, i will change that and
      provide hopefully a better solution, like putting source code into
      directories and such.

      Are you now supporting sources in FREE format ?

      Vince

       
<< < 1 2 3 4 5 > >> (Page 3 of 5)

Anonymous
Anonymous

Add attachments
Cancel