views:

3838

answers:

4

Oracle Forms10g provides a tool to convert the Oracle Forms modules, from the binary format (.FMB) that Oracle Forms Builder works with, to text format (.FMT).

For example, if you create a module called mymodule.fmb with Oracle Forms Builder, and then invoke

frmcmp module=mymodule.fmb script=yes batch=yes logon=no

from the command line, the Oracle Forms Convert utility will create a file named mymodule.fmt from the file mymodule.fmb. This text file is supposed to be "readable" by humans, except for the PL/SQL code of triggers and program units, which is codified.

For example, this is a snippet of a .FMT file with a chunk of codified PL/SQL code

DEFINE  F50P
BEGIN
   PP = 10
   PI = 3
   PN = 464
   PL = 1138
   PV = (BLONG)
<<"
00000049 00800000 00440000 00000000 00000031 0000000d 00000002 a0011519 
00002420 0000045e 001f0000 00165030 5f32335f 4f43545f 32303038 31365f33 
375f3039 00000006 42454749 4e0a0000 0042676f 5f626c6f 636b2820 27504149 
53455327 20293b0a 69662066 6f726d5f 73756363 65737320 7468656e 0a096578 
65637574 655f7175 6572793b 0a656e64 2069663b 00000005 0a454e44 3b000000 
1d574845 4e2d4e45 572d464f 524d2d49 4e535441 4e434520 28466f72 6d290000

Have you ever tried to decode this kind of files, to be able to extract the PL/SQL code of a form ?

It would be very useful to be able to search a string in the PL/SQL code of a lot of .FMT files, instead of using Oracle Forms Builder to manually open each of the corresponding .FMB files, and search the string in each one of them.

Thanks!

A: 

According to this page the author has a perl script to convert the hex back to ascii text (he says to send him an email and he will send it)

hamishmcn
+1  A: 

The bytes are just hex values of the characters. for example: taking the 4th line and putting it into the following python code:

[chr(x) for x in [0x53,0x45,0x53,0x27 ,0x20,0x29,0x3b,0x0a ,0x69,0x66,0x20,0x66 ,0x6f,0x72,0x6d,0x5f ,0x73,0x75,0x63,0x63 ,0x65,0x73,0x73,0x20 ,0x74,0x68,0x65,0x6e ,0x0a,0x09,0x65,0x78]]

gives the following output:

['S', 'E', 'S', "'", ' ', ')', ';', '\n', 'i', 'f', ' ', 'f', 'o', 'r', 'm', '_', 's', 'u', 'c', 'c', 'e', 's', 's', ' ', 't', 'h', 'e', 'n', '\n', '\t', 'e', 'x']

which is recognisable forms pl/sql. So it looks like it wouldn't be too much work to create a script that would take a directory of FMT files and produce corresponding files with text that could be searched.
Have fun!

hamishmcn
For the purpose of search, I will remove all the non-printable characters (such as 0x00) from the output. Thanks!
Aurelio Martin
+1  A: 

The Oracle Forms 9i and later has an Programming API to allow you to do exactly what you describe. You will need to review your Forms documentation to do this, but it may be faster than trying to extract binary strings.

If you are willing to pay for an existing tool, use the following:

http://www.orcl-toolbox.com/

Their formsAPI and FormsTools let you do extractions, diffs, changes and updates to your forms.

Thomas Jones-Low
+1  A: 

Along with the API, note that if you're working at the start of this process you'll probably be better off generating the XML version than the FMT version. The FMT is an older format kept for backward compatibility, and tools like the recently announced Forms -> Oracle APEX converter will want the XML. It's also easier to read.

In "Forms 10g release 1" (9.0.4) the XML converter is a separate command line program. forms2xml. I think that's still true for 10.1

Plus, the XML is easier to read and interpret.

Jim Hudson
Thanks! The PL/SQL is stored in plain text in the XML, and it's a much better format to search
Aurelio Martin