Menu

Regarding Gix-IDE test001

GnuCOBOL
2025-10-24
6 days ago
  • compiletaro

    compiletaro - 2025-10-24

    Environment:

    Windows 11
    Installed : Gix-IDE using gixsql-installer-windows-x64-mingw-1.0.20-1.exe

    I launched Gix-IDE and tried to connect to a local PostgreSQL database using a sample file test001.gix as a reference. The build completes successfully, but when I run the program, it seems to stop at the line:

    CONNECT TO :DBNAME USER :DBAUTH

    After this line, nothing happens.
    There is no SQLCODE returned, and no logs or error messages are displayed either.
    I'm currently stuck and unsure how to establish a proper database connection.
    If anyone has experience with this or any suggestions, I would greatly appreciate your guidance.

     
  • Simon Sobisch

    Simon Sobisch - 2025-10-24

    As that is very early I'd enable the full logging and check its output
    https://github.com/mridoni/gixsql?tab=readme-ov-file#logging

    This can be set from the program before the very first call to any GixSQL function as well:

    SET ENVIRONMENT "GIXSQL_LOG_LEVEL" TO "debug"

    And also check the plain connect to the databese on your machine outside of COBOL.

    @jamesbwhite has setup this recently (not with the GixIDE, only with GixSQL, but that doesn't matter)

     

    Last edit: Simon Sobisch 2025-10-24
  • compiletaro

    compiletaro - 2025-10-24

    Hi. Mr.Simon.

    Thank you for your response.
    I enabled logging and obtained the following output:

    [2025-10-24 17:03:09.836] [libgixsql] [info] GixSQL logger started (PID: 21188)
    [2025-10-24 17:03:09.836] [libgixsql] [debug] gixsql.cpp>GIXSQLConnect: GIXSQLConnect start
    [2025-10-24 17:03:25.301] [libgixsql] [info] Terminating logger
    

    Also, I have confirmed that I can connect to the database from psql outside of the COBOL program.!

     
  • Simon Sobisch

    Simon Sobisch - 2025-10-24

    OK, that looks like a good start, I'd suggest to set the log level to trace.

    And just to check that the encoding is not an issue, try SET ENVIRONMENT "GIXSQL_CLIENT_ENCODING" TO "SJIS" as well (GixSQL defaults to UTF8).

     
  • compiletaro

    compiletaro - 2025-10-24

    I set the log level to "trace" and ran it.
    Then I added the encoding setting and ran it again.

     
  • Simon Sobisch

    Simon Sobisch - 2025-10-24

    Those aren't EXEC SQL but have to be specified before the first EXEC SQL - but you can use the DISPLAY UPON / ACCEPT FROM syntax which is used otherwise in this example as well .

     

    Last edit: Simon Sobisch 2025-10-24
  • compiletaro

    compiletaro - 2025-10-24

    Sorry,

    It’s partly my misunderstanding, but I’m not really sure where or how exactly I should add it.

    If it’s okay, could you provide a sample code for me?

     
    • Simon Sobisch

      Simon Sobisch - 2025-10-24
               SET ENVIRONMENT "GIXSQL_LOG_LEVEL" TO "trace"
               SET ENVIRONMENT "GIXSQL_CLIENT_ENCODING" TO "SJIS"
               DISPLAY "DBNAME" UPON ENVIRONMENT-NAME.
               ACCEPT   DBNAME  FROM ENVIRONMENT-VALUE.
               DISPLAY "DBAUTH" UPON ENVIRONMENT-NAME.
               ACCEPT   DBAUTH  FROM ENVIRONMENT-VALUE.
      
       
  • compiletaro

    compiletaro - 2025-10-24

    Thanks!

    I added the sample and ran it, but didn’t notice any changes in the logs.

    I’m wrapping up for today, so I’ll continue working on this on Oct 27.

     
    • Mickey White

      Mickey White - 2025-10-24

      Welcome to the forum!
      First thought is that you may need to create a separate user for your database. And use that user in the program.
      On Linux a superuser is not allowed to access PostgreSQL tables and your userID may be the issue. Not sure how Windows does this.
      I will post how I did things.. soon today.

       
  • Mickey White

    Mickey White - 2025-10-24

    Here is my info on how I did run on Linux. Not sure if it will help on Windows.
    My Linux Install and Compiling PostgreSQL GnuCOBOL programs.
    Simon gave me this info to install manually:
    wget https://github.com/mridoni/gixsql/releases/download/v1.0.20b/gixsql-1.0.20b.tar.gz
    sudo apt install libpq-dev flex libspdlog-dev libfmt-dev
    you may add libmariadb-dev unixodbc-dev if you additional want support for MariaDB (MySQL) and/or ODBC to the install.
    Then I just did the tar and ./config and make make install.... usual.

    I had some issue on the copybook for SQL so I put them in my library where my copybooks are: ( yes I need to clean that up )

    mickeyw@mickeyw-Meerkat:~/cpy$ echo $HOME/cpy
    /home/mickeyw/cpy
    # and extract of the list I think it used:
    -rw-r--r-- 1 mickeyw mickeyw   1003 Aug 18 12:07  sqlca.cpy
    -rw-r--r-- 1 mickeyw mickeyw   2737 Aug 18 12:07  sqlda.cpy
    -rw-r--r-- 1 mickeyw mickeyw   1003 Sep  5 11:07  SQLCA
    -rw-r--r-- 1 mickeyw mickeyw   2737 Sep  5 11:08  SQLDA
    -rw-rw-r-- 1 mickeyw mickeyw    479 Sep  7 15:44  customer
    -rw-rw-r-- 1 mickeyw mickeyw    479 Sep  7 16:33  CUSTOMER
    

    Note: I use dynamic subroutines but I did add to my COB-PRE-LOAD environment variable:

    COB_PRE_LOAD=/home/mickeyw/lib/mwoc.so:/usr/local/lib/libgixsql-pgsql.so:/usr/local/lib/libgixsql.so

    This is the gixsql compile line I used:
    gixsql test002.sqb test002.cbl -I "$HOME/cpy/" && cobc -x test002.cbl

    Note: I do not like EXIT and prefer no goto or perform thru exit, but I had to have the end of the program NOT be the end of the SQL... probably just me..
    Here is my test002 program that makes the connection and selects the count on the table:

          IDENTIFICATION DIVISION.
           PROGRAM-ID. test002.
          *> gixsql test002.sqb test002.cbl -I "$HOME/cpy/" && cobc -x test002.cbl 
    
           ENVIRONMENT DIVISION.
    
           CONFIGURATION SECTION.
           SOURCE-COMPUTER. IBM-AT.
           OBJECT-COMPUTER. IBM-AT.
    
           INPUT-OUTPUT SECTION.
           FILE-CONTROL.
    
           DATA DIVISION.
    
           FILE SECTION.
    
           WORKING-STORAGE SECTION.
    
           EXEC SQL
            INCLUDE CUSTOMER
           END-EXEC.
    
               01 DATASRC PIC X(64).
               01 DBNAME  PIC X(64).
               01 DBUSR   PIC X(64).
               01 DBPWD   PIC X(64).
    
               01 T1      PIC 9(13) VALUE 0.
    
           EXEC SQL
                INCLUDE SQLCA
           END-EXEC.
    
           PROCEDURE DIVISION.
    
           000-CONNECT.
               move 'pgsql://localhost:5432/custdb'
                   to DATASRC
               move 'james.1234' to DBUSR
               move 'ustdb'   to DBNAME
    
               DISPLAY '***************************************'.
               DISPLAY " DATASRC  : " DATASRC.
               DISPLAY " DBUSR    : " DBUSR.
               DISPLAY '***************************************'.
    
               EXEC SQL
                CONNECT TO :DATASRC USER :DBUSR
               END-EXEC.
    
               display 'afterconnect'
               DISPLAY 'CONNECT SQLCODE: ' SQLCODE.
               DISPLAY 'ERROR LENGTH: ' SQLERRML.
               DISPLAY 'ERROR MESSAGE: ' SQLERRMC(1:SQLERRML).
               DISPLAY 'SQLSTATE: ' SQLSTATE.
    
               DISPLAY 'CONNECT SQLCODE: ' SQLCODE
    
               IF SQLCODE <> 0 THEN
                  GO TO 100-EXIT
               END-IF.
    
           100-MAIN.
    
          *     EXEC SQL
          *        START TRANSACTION
          *     END-EXEC.
    
               EXEC SQL
                     SELECT COUNT(*) INTO :T1 FROM customer
               END-EXEC.
    
               DISPLAY 'SELECT  SQLCODE: ' SQLCODE.
               DISPLAY 'ERROR LENGTH: ' SQLERRML.
               DISPLAY 'ERROR MESSAGE: ' SQLERRMC(1:SQLERRML).
               DISPLAY 'SQLSTATE: ' SQLSTATE.
    
               DISPLAY 'SELECT SQLCODE: ' SQLCODE
    
    
               DISPLAY 'RECORD COUNT RESPONSE FROM SELECT COUNT = ' T1.
    
               DISPLAY 'SELECT SQLCODE : ' SQLCODE.
    
               IF SQLCODE <> 0 THEN
                  GO TO 100-EXIT
               END-IF.
    
               DISPLAY 'RES: ' T1.
    
               EXEC SQL CONNECT RESET END-EXEC.
    
           100-EXIT.
                  STOP RUN.
    

    Here is the output of the test002 program

    mickeyw@mickeyw-Meerkat:~/cbl$ test002
    ***************************************
     DATASRC  : pgsql://localhost:5432/custdb
     DBUSR    : james.1234
    ***************************************
    afterconnect
    CONNECT SQLCODE: +0000000000
    ERROR LENGTH: +00069
    ERROR MESSAGE:
    SQLSTATE: 00
    CONNECT SQLCODE: +0000000000
    SELECT  SQLCODE: +0000000000
    ERROR LENGTH: +00069
    ERROR MESSAGE:
    SQLSTATE: 00
    SELECT SQLCODE: +0000000000
    RECORD COUNT RESPONSE FROM SELECT COUNT = 0000000001001
    SELECT SQLCODE : +0000000000
    RES: 0000000001001
    

    Note: when I run my cobol sql program PostgreSQL creates a log file, if there were SQL errors, that was Very helpful when trying to analyze connection or SQL issues:
    gixsql.log
    It is in the same directory that I ran my program in...

    BELOW is the information I have on my database and table. I have one db and it has one table. I manually created them. I have a test file with 1001 records that I manually loaded to the table.

    Also you can see that I created a user ( james ) to access the tables as Linux and PostgreSQL may have issues with my mickeyw user name as it is a superuser.

    And

    mickeyw@mickeyw-Meerkat:~/Extra/Data$ psql -d custdb
    psql (16.10 (Ubuntu 16.10-0ubuntu0.24.04.1))
    Type "help" for help.
    
    custdb=# \d
              List of relations
     Schema |   Name   | Type  |  Owner
    --------+----------+-------+---------
     public | customer | table | mickeyw
    (1 row)
    
    custdb=# \d customer
                        Table "public.customer"
        Column     |     Type      | Collation | Nullable | Default
    ---------------+---------------+-----------+----------+---------
     cust_acct_no  | character(9)  |           | not null |
     cust_fname    | character(15) |           |          |
     cust_lname    | character(13) |           |          |
     cust_house_no | character(8)  |           |          |
     cust_street   | character(30) |           |          |
     cust_city     | character(30) |           |          |
     cust_state    | character(2)  |           |          |
     cust_zip      | character(5)  |           |          |
     cust_income   | character(9)  |           |          |
    Indexes:
        "customer_pkey" PRIMARY KEY, btree (cust_acct_no)
    
    custdb=# \l
                                                            List of databases
        Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges
    ------------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------
     custdb     | mickeyw  | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           | =Tc/mickeyw          +
                |          |          |                 |             |             |            |           | mickeyw=CTc/mickeyw  +
                |          |          |                 |             |             |            |           | james=c/mickeyw
     mickeyw    | mickeyw  | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           |
     postgres   | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           |
     template0  | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           | =c/postgres          +
                |          |          |                 |             |             |            |           | postgres=CTc/postgres
     template1  | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           | =c/postgres          +
                |          |          |                 |             |             |            |           | postgres=CTc/postgres
     testaccess | mickeyw  | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           |
    (6 rows)
    
    custdb=#
    
    custdb=# SELECT rolname, rolcreatedb, rolsuper FROM pg_roles WHERE rolcanlogin = TRUE;
     rolname  | rolcreatedb | rolsuper
    ----------+-------------+----------
     postgres | t           | t
     mickeyw  | t           | t
     james    | f           | f
    (3 rows)
    

    Hope this helps.

     
    ❤️
    3

    Last edit: Simon Sobisch 2025-10-26
  • compiletaro

    compiletaro - 2025-10-27

    HI.! Mickey White

    Thanks for the advice!

    I tried running it with a new user, but nothing changed :(

    Then I realized something — I’m using PostgreSQL version 18, the latest one.
    Could it be that GixSQL doesn’t support version 18 yet?

    What version of PostgreSQL is everyone else using?

     
    • Mickey White

      Mickey White - 7 days ago

      I guess that you did assign the new user permissions , GRANT CONNECT TO newuser ;
      and GRANT SELECT ON your_table TO newuser;
      Note I have PostgreSQL version 16 ( and ver 14 on an older OS) both work.
      Have you tried compiling outside of the IDE ?
      I also had issues with the TEST001.sqb program that was on the site.
      I got it to work in this example:

             IDENTIFICATION DIVISION.
      
             PROGRAM-ID. test000.
            * gixsql test000.sqb test000.cbl -I "$HOME/cpy/"  &&  cobc -x test000.cbl
      
             ENVIRONMENT DIVISION.
      
             CONFIGURATION SECTION.
             SOURCE-COMPUTER. IBM-AT.
             OBJECT-COMPUTER. IBM-AT.
      
             INPUT-OUTPUT SECTION.
             FILE-CONTROL.
      
             DATA DIVISION.
      
             FILE SECTION.
      
             WORKING-STORAGE SECTION.
      
             EXEC SQL
              INCLUDE CUSTOMER
             END-EXEC.
      
                 01 DATASRC PIC X(64).
                 01 DBNAME  PIC X(64).
                 01 DBUSR   PIC X(64).
                 01 DBPWD   PIC X(64).
      
             EXEC SQL
                  INCLUDE SQLCA
             END-EXEC.
      
             PROCEDURE DIVISION.
      
             000-CONNECT.
                 move 'pgsql://localhost:5432/custdb'
                     to DATASRC
                 move 'james.1234' to DBUSR
                 move 'custdb'     to DBNAME
      
                 DISPLAY '***************************************'.
                 DISPLAY " DATASRC  : " DATASRC.
                 DISPLAY " DBUSR    : " DBUSR.
                 DISPLAY '***************************************'.
      
                 EXEC SQL
                  CONNECT TO :DATASRC USER :DBUSR
                 END-EXEC.
      
                 display 'afterconnect'
                 DISPLAY 'CONNECT SQLCODE: ' SQLCODE.
                 DISPLAY 'ERROR LENGTH: ' SQLERRML.
                 DISPLAY 'ERROR MESSAGE: ' SQLERRMC(1:SQLERRML).
                 DISPLAY 'SQLSTATE: ' SQLSTATE.
      
                 DISPLAY 'CONNECT SQLCODE: ' SQLCODE
      
                 IF SQLCODE <> 0 THEN
                    GO TO 100-EXIT
                 END-IF.
      
             100-MAIN.
      
                 EXEC SQL CONNECT RESET END-EXEC.
      
             100-EXIT.
                    STOP RUN.
      

      Maybe you could try this example.
      Note it ran for me.
      If you have connection problems, did you find the gixsql.log file?
      Here is the log file if I run with invalid user id in the program after it abends.

      mickeyw@mickeyw-Meerkat:~/cbl$ cat gixsql.log
      [2025-10-27 08:58:19.534] [libgixsql-pgsql] [error] libpq: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user "mjames"
      connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user "mjames"
      
      mickeyw@mickeyw-Meerkat:~/cbl$
      
       
    • Michael Del Solio

      Hi, maybe you could edit the file pg_hba.conf of the PostgreSQL server like this:

      # TYPE  DATABASE        USER            ADDRESS                 METHOD
      
      # standard for local connections
      local   all             postgres                                peer
      
      # first this for database user cobol_user (local and TCP/IP)
      local   all             cobol_user                              md5
      host    all             cobol_user      127.0.0.1/32            md5
      host    all             cobol_user      ::1/128                 md5
      
      [...] then all the other stuff ...
      

      And then restart the postgresql-service...

      This was the last missing piece for me to get a connection of my user "cobol_user" on localhost via GixSQL ...

      The concrete PostgreSQL version (14 ... 18) doesn't matter I think.

       
      • Mickey White

        Mickey White - 7 days ago

        Yes, I forgot that. It was one of the fixes for me also!
        update: After reviewing my notes, I only had to do that one system, one has : Local All All Peer and the other: Local All All md5

         

        Last edit: Mickey White 6 days ago
  • compiletaro

    compiletaro - 7 days ago

    If anyone is running the GixIDE sample program “TEST001.gix” on Windows 11 with PostgreSQL, I’d really appreciate some advice.

    Also, it would be great if you could share your system setup and environment settings. Thanks in advance!

     
  • compiletaro

    compiletaro - 6 days ago

    Hi,! Michael Del Solio,
    It seems that the PostgreSQL version doesn’t really matter…
    I tried changing the pg_hba.conf settings!

    Mickey White, Thank you for the sample code.
    When I followed the README instructions in the command prompt, I was able to successfully verify the SQL connection :-).
    Now, I just need to make sure that building and running from GixIDE returns the correct results…

     
  • compiletaro

    compiletaro - 6 days ago

    I just remembered that I had installed MinGW during the initial setup, so I reinstalled it using MSVC instead. After that, I was able to successfully build and run the project. I apologize for the trouble I caused, and I truly appreciate everyone’s help in getting it to work!

     
    👍
    2

Log in to post a comment.

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.