问题
What we would like to do is to export data from Oracle Forms into XLS file (server-side). We found out that Perl has superb SpreadSheet::WriteExcel and SpreadSheet::WriteExcelXML modules for this. The best thing with this is we don't have to have any other apps (like MS Excel, OpenOffice) installed.
One way is to connect to my database, execute query and generate XLS file - everything from a Perl script. But, because it would be easier to maintain all the code in one place, is there a way to call these Perl modules from a PL/SQL code from the Oracle Forms??
Thanks
回答1:
I don't know oracle forms since 4.5 back in the 90s, I assume its moved on a bit since then.
If you PL/SQL is running server side, then you could look at extproc_perl http://www.smashing.org/extproc_perl/userguide.html But I reckon that could be a bit of hassle - I have only written C++ exptprocs, never perl. Expect some dynaimic linking teething problems. Also the code is not directly in the PL/SQL. You have to write a PL/SQL wrapper around the perl (actually around the C which invokes the perl - but you shouldn't have to worry about the C).
The simpler solution (which I think you have already alluded to) is to have the form invoke a perl CGI script which makes its own connection to the DB, and then outputs the excel as the result.
回答2:
Running external programs from PL/SQL or Oracle forms is very difficult:
http://www.orafaq.com/wiki/PL/SQL_FAQ#Can_one_execute_an_operating_system_command_from_PL.2FSQL.3F
As @Sodved mentions using a Perl CGI script to create and download the file to the user is probably the easiest way. You will want to use the forms WEB.SHOW_DOCUMENT function.
回答3:
One solution is to create a job queue table and have your Oracle Forms code insert records into that table for the tasks they need done. Then have a daemon process that watches the table for new records and executes processed to handle the requests.
You can also use the packages dbms_alert
or dbms_pipe
to send messages to the daemon along with or instead of using a table.
来源:https://stackoverflow.com/questions/6583602/how-do-i-call-perl-modules-from-pl-sql-oracle-forms