A design file such as an .fmb holds everything about a module, including the source of its PL/SQL. Before users can run it, the Form Compiler has to turn it into a runnable file that holds what the Forms runtime needs: the objects, their properties, and the compiled code.
This guide shows how to compile Oracle Forms 14.1.2 modules in Forms Builder and from the command line with frmcmp_batch, how to read its output and errors, and which parameters matter in a build script.
Sample Form for This Guide
The examples and screenshots use the sample form CH06_MODULE from the Oracle Forms code repository on GitHub. Download it, open it in Forms Builder, and connect as CAREWELL to follow along.
| Form | File | What it shows |
|---|---|---|
| CH06_MODULE | forms/ch06/ch06_module.fmb | The form compiled in the examples |
The forms run against the CareWell Clinic sample schema, which you install first.
Design Files and Runnable Files
| Module | Design file | Runnable file | module_type |
|---|---|---|---|
| Form | .fmb | .fmx | form |
| Menu | .mmb | .mmx | menu |
| PL/SQL library | .pll | .plx | library |
Runnable files are specific to the platform and the Forms release they were compiled for. An .fmx made on Windows does not run on Linux, so compile on the server that runs the forms, or on a machine of the same platform. For more on the kinds of modules, see how to create modules in Oracle Forms.
Compile in Forms Builder
Forms Builder has several compile commands, all on the Program menu:
| Command | Shortcut | What it compiles |
|---|---|---|
| Compile Module | Ctrl+T | The current module, writing the runnable file next to the design file. |
| Compile PL/SQL, Incremental | Ctrl+K | Only the code changed since the last compilation, without writing a file. |
| Compile PL/SQL, All | Shift+Ctrl+K | Every trigger and program unit, without writing a file. |
| Compile Selection | Ctrl+M | The code of the selected objects. |
| Run Form | Ctrl+R | Compiles the form, then runs it. |
Use Compile PL/SQL while you write code to catch errors quickly, and Compile Module when you need the .fmx file.
Compile from the Command Line with frmcmp_batch
Applications with dozens or hundreds of modules compile them from the command line, in a script. The compiler is frmcmp, and frmcmp_batch runs it without opening any window, which is what a script needs.
On Linux, run them through frmcmp.sh and frmcmp_batch.sh in the bin directory of the Forms instance, which set up the environment. On Windows, run frmcmp_batch.cmd from the same place.
Syntax:
frmcmp_batch module=file userid=user/password@database
[module_type={form | menu | library}]
[compile_all={yes | no}] [batch={yes | no}] [output_file=file]
[logon={yes | no}] [script={yes | no}] [parse={yes | no}]
[forms_doc={yes | no}] [debug={yes | no}] [statistics={yes | no}]Example:
frmcmp_batch.sh module=ch06_module.fmb userid=carewell@formspdb module_type=form compile_all=yes
Output:
Compiling WHEN-NEW-FORM-INSTANCE trigger on form... No compilation errors. Compiling WHEN-BUTTON-PRESSED trigger on CLOSE item in CONTROL data block... No compilation errors. Created form file ch06_module.fmx
The compiler also prints its version and the versions of the libraries it uses, which the output above leaves out.
When the Code Has Errors
When the code has errors, the compiler lists each one with its trigger or program unit, its line and column, and the PL/SQL error, and writes no runnable file. Here is the result for a trigger that refers to an item that does not exist.
Output:
Compiling WHEN-NEW-FORM-INSTANCE trigger on form... Compilation error on WHEN-NEW-FORM-INSTANCE trigger on form: PL/SQL ERROR 49 at line 2, column 3 bad bind variable 'props.nosuch' Compilation errors have occurred. Form not created
PL/SQL error 49, bad bind variable, is the error you will see most often. It means the code refers to a block or item, here PROPS.NOSUCH, that the form does not have.
Check the Exit Status in Scripts
frmcmp_batch ends with exit status 0 when it created the file and 1 when it did not. A build script should check that status and stop, rather than deploy an old .fmx.
Form Compiler Parameters
| Parameter | Default | Meaning |
|---|---|---|
| module | None | The design file to compile. |
| userid | None | The database connection. The compiler needs it to check the code against the tables and stored program units it uses. |
| module_type | form | form, menu, or library. |
| compile_all | no | yes compiles all the code of the module, not only what changed. Use it in build scripts. |
| batch | no | yes suppresses the messages on the screen. |
| output_file | None | The runnable file to write, if not the default name and folder. |
| logon | yes | no works without a database connection, which is enough for script and forms_doc but not for compiling code. |
| script, parse | no | Convert the module to a text file (.fmt, .mmt, .pld), or a text file back to a module. |
| forms_doc | no | Write a text file that lists every object of the module with its properties. |
| debug | no | Include the information the debugger needs. |
| statistics | no | Print the number of objects of each type. |
For a build script, the combination to remember is module, userid, module_type, and compile_all=yes, with the exit status checked after each call. For compiling and running a single form from Forms Builder, see also how to run and compile an Oracle Form.
Conclusion
The Form Compiler turns .fmb, .mmb, and .pll design files into .fmx, .mmx, and .plx runnable files for one platform and release, so compile on the platform that runs the forms. In Forms Builder, use Compile Module (Ctrl+T) for the runnable file and Compile PL/SQL while you write code. In scripts, run frmcmp_batch with module, userid, module_type, and compile_all=yes, read the errors it lists by trigger, line, and column, and check its exit status before deploying.
