mridoni / gixsql

GixSQL is an ESQL preprocessor and a series of runtime libraries to enable GnuCOBOL to access PostgreSQL, ODBC, MySQL, Oracle and SQLite databases.
GNU General Public License v3.0
16 stars 8 forks source link

add db-connecting options to preprocessor (for internal `describe table`) #56

Open GitMensch opened 2 years ago

GitMensch commented 2 years ago

It would be good to be able to let the preprocessor (via existing calls to GixSQL) connect to the DB for the following purposes:

Sample for the last one:

         01  WORKAREA.
           05  NUM-RECS                        PICTURE 9(3).
           INVOKE TABLE MYTAB OF MYCON SCHEMA FROM REPOSITORY.

then gixsql woul connect to "MYCON" with connection data passed either via command line option or via environment, execute a DESCRIBE TABLE and convert the SQL columns back into COBOL, applying name transformation like underscore becoming dash:

       01  WORKAREA.
           05  NUM-RECS                        PICTURE 9(3).
GIXSQL*    INVOKE TABLE MYTAB OF MYCON SCHEMA FROM REPOSITORY.
GIXSQL     05  TSPFL-RECORD.
GIXSQL       10  CM-NUMBER                 PIC XXXXX.
GIXSQL       10  CM-STATUS                 PIC X.
GIXSQL       10  CM-COMPANY                PIC X(25).
GIXSQL       10  CM-ADDRESS-1              PIC X(25).
GIXSQL       10  CM-ADDRESS-2              PIC X(25).
GIXSQL       10  CM-ADDRESS-3              PIC X(25).
GIXSQL       10  CM-POSTAL                 PIC X(7).
GIXSQL       10  CM-TELEPHONE              PIC X(10).
GIXSQL       10  CM-TELEX                  PIC X(8).
GIXSQL       10  CM-PO-NUMBER              PIC X(16).
GIXSQL       10  CM-ATTN                   PIC X(25).
mridoni commented 2 years ago

This is partly done, but for now it works from Gix-IDE only, I suppose it can be moved to GixSQL/gixpp. Though it surely needs to be extended and improved, and I haven't looked at it in a while, it should be functional: it's part of the "DB manager" classes, look here as a starting point.