Processing AOP files - dbFlux (8/9)

published on

This is the eighth part of my series about dbFlux. Last time it was about running unit tests. This time I will show you how to use dbFlux to get your files, for example AOP report files, into your database.

dbFlux does not only offer the upload of static application files. Additionally we have the possibility to upload files into our own tables, or to process the files with our own logic. Such files are stored in the smartFS within the reports folder. Here, one folder is expected per file type to be handled.

So if we want to store AOP (APEX Office Print) files in our database, a folder is stored here named accordingly. In case of AOP all Word files are stored here for example. To create a report type, execute the command dbFlux: Add REPORT type.

After entering the appropriate report type name, dbFlux creates the directory of the same name including a template.sql file. 

This file will later be included in the actual upload processing. Two variables are available here, the file name as l_file_name and the file content with l_bin. In the template created by dbFlux, these are only used for the output. But here would be the place to include them in your own processing. For example like this:

    -------     TEMPLATE START            -------
    l_bin         >>> file content as blob
    l_file_name   >>> filename

    l_dkt_typ varchar2(100);
    l_dkt_typ := substr(l_file_name, instr(l_file_name, '_', 1, 1)+1);
    l_dkt_typ := substr(l_dkt_typ, 1, instr(l_dkt_typ, '.', 1, 1)-1);

    update v_dokumenttypen
       set dkt_template = l_bin
     where dkt_typ = upper(l_dkt_typ);

    dbms_output.put_line(gc_green||' ... Document uploaded to type: ' || upper(l_dkt_typ) ||gc_reset);

    -------     TEMPLATE END              -------

If you have now selected the Word file in the Explorer, you can trigger the generation of the actual DML file by executing the command dbFlux: Compile current file or with the shortcut Ctrl+Alt+B. First dbFlux asks for the target directory and afterwards for the filename. The appropriate place, in the context of smartFS and the ambition to CI/CD, is the folder db/schema/dml/(init || post). Since dbFlux opens the just created file, you can now execute it as usual with the command dbFlux: Compile current file or with the shortcut Ctrl+Alt+B and this leads to the upload of the file into the database.

The process does not only have to be done with AOP files, dbFlux does not care about that in the end, here only one file is processed by SQL. It doesn't matter what type it is. If you use dbFlow as deployment tool, you also have the possibility to handle the changelog from the commit messages as markdown file here and to display it in the application.

List of the single articles of this series

1. Initialize Workspace
2. Create Database Objects
3. Configure Custom Trigger Runs
4. Modify Table
5. Compile Source Code
6. Upload JavaScript and CSS
7. Execute utPLSQL Unittests
8. Processing AOP files