Using the combine features of Ax.rs.Reader and Ax.rs.Writer function we will show how to write a tiny database export and import application using Excel as intermediata storage system.

1 Exporting (writing)

1.1 SQL

We will use the Ax.rs.Writer to create a series of SQL statements from a database tables.

Copy
<script>
    var dict = Ax.db.of("dbsrv1", "wic_icon");
    var tables = dict.executeQuery("SELECT tab_name FROM wic_table_object WHERE tab_label = 'MASTER'");
    for (var row of tables) {
        var tableName = row.get("tab_name");
        var rs = Ax.db.executeQuery("SELECT * FROM " + tableName);
        
        var blob = new Ax.sql.Blob("tmp");
        new Ax.rs.Writer(rs).sql(options => {
                options.setTableName(tableName);
                options.setResource(blob);
            }
        );
        rs.close();
        
        console.log(blob.getText());
    }
</script>

1.2 Excel

We will use the Ax.rs.Writer to create generate a Workbook with database data, placing each table in a worksheet and adding a first sheet with TOC (table of contents).

TO DO

This section is incomplete and will be concluded as soon as possible.

2 Importing (reading)

We will use the Ax.rs.Reader to load the Excel file and update or insert each table according its sheets.

TO DO

This section is incomplete and will be concluded as soon as possible.