Products Support Documentation Download
Processing Files with rdm-sql

The rdm-sql tool allows the user to process files that contain valid SQL statements (called "SQL files") in a non-interactive way. This feature is useful when embedding rdm-sql as part of a larger script file, for instance.

You can specify an SQL file as the last command-line argument to rdm-sql. Let's try recreating the bicycle_db database using this method.

Navigate to your working directory and type in the following command from the command-line terminal, replacing <rdm_install_dir> with your own RDM installation directory.

$ rdm-sql <rdm_install_dir>/GettingStarted/examples/sql_bicycle/create.sql

You will see an output like this.

Raima Database Manager SQL command processor Utility
Raima Database Manager 14.1.2 Build 3053 [7-11-2018] http://www.raima.com/
Copyright (c) 2018 Raima Inc., All rights reserved.
Creating the BICYCLE_DB database
Importing data into the BICYCLE_DB database
manufacturer...
bicycle...
done.

When an SQL file is specified as the last command-line argument, rdm-sql processes the file in a non-interactive manner. The operation completes without displaying the interactive prompt. Errors detected during the file processing will be displayed.

This is the content of create.sql.

1 .m
2 .m Creating the BICYCLE_DB database
3 DROP DATABASE IF EXISTS BICYCLE_DB;
4 COMMIT;
5 
6 CREATE DATABASE BICYCLE_DB EXCLUSIVE;
7 .r bicycle_db.sdl
8 COMMIT;
9 
10 .r import.sql
11 COMMIT;
12 
13 CLOSE DATABASE BICYCLE_DB;

The SQL file uses two interface command options, ".m" and ".r". The ".m" option lets rdm-sql display the line that begins with it.

The ".r" option lets you specify an SQL file to be read and processed by rdm-sql. This is the other way to process an SQL file, in addition to specifying the file name as the last command-line argument.

If used directly in the rdm-sql prompt, the ".r" option echoes the statements in the SQL file that were executed. Start rdm-sql in your working directory and type in the following command at the prompt.

rdm-sql --database BICYCLE_DB
...
rdm-sql: .r <rdm_install_dir>/GettingStarted/examples/sql_bicycle/join_query.sql

The query stored in the SQL file is displayed, with the prompt showing the file name.

join_query.sql(1): SELECT m.name, b.model, b.type FROM manufacturer m
join_query.sql(2): LEFT JOIN bicycle b
join_query.sql(3): ON m.name = b.make;
NAME | MODEL | TYPE
--------------------+---------------------+-----------
Cannondale | Synapse | Road
Specialized | *NULL* | *NULL*
Trek | Domane | Road
Trek | FX | Hybrid
*** 4 row(s) returned
rdm-sql: