How to open PDF File From oracle forms 11g? - oracle

I am using Oracle Database 11gR2 with Oracle Forms 11gR2. I have PDF File Saved on Server Machine. I created button with Name "HELP" Manual PDF File. Now i want when user click on button on their local machine then PDF File open from server machine.
I found this code:
host('rundll32 url.dll,FileProtocolHandler c:\file_name.pdf');
Is this code run correctly? Oracle Forms 11g

You can create such a Procedure within your form :
Procedure Pr_Print( i_document varchar2 ) Is
pl_id paramlist;
pl_list paramlist;
my_rep_server varchar2(500);
Begin
pl_list := Get_Parameter_List('tmpdata');
if not Id_Null(pl_list) then
Destroy_Parameter_List(pl_list);
end if;
pl_list := Create_Parameter_List('tmpdata');
set_report_object_property('RP2RRO', report_filename, i_document );
set_report_object_property('RP2RRO', report_server, my_rep_server);
add_parameter(pl_id, 'column1', text_parameter, :col1 );
add_parameter(pl_id, 'column2', text_parameter, :col2 );
rp2rro.rp2rro_run_product(reports, i_document, synchronous, runtime,
filesystem, pl_id, null);
End;
where rp2rro.rp2rro_run_product is a method coming from rp2rro.pll ( a binary library module supplied by Oracle ),
assuming you have col1 and col2 text fields in it.
And call it from a button's WHEN-BUTTON-PRESSED trigger with the code :
Pr_Print('myDocument');
P.S. the library rp2rro.pll should be installed and configured within the application server, too. Since Reports 11g runs on app. server as a web-based application.

I think you can use WEB.SHOW_DOCUMENT(url,’_blank’); in your WHEN-BUTTON-PRESSED trigger

Related

Limiting file size before submit through Dynamic Acrton in Oracle Apex

I want to create a Dynamic Action to check file size of File Browser field. I can not put validation I have to implement this through Dynamic Action. Please help here.
I guess you want to check the size of a file before a user upload it inside an apex application. That does not look to me like a dynamic action. Why you cannot use validations ?
Anyway, I would have a look at this interesting plugin : apex file size plugin
If you are interested, I know how to do it by using PL/SQL against apex_application_temp_files. In my case the user uploads the file using a file browser, then press upload, which triggers a PL/SQL process. The PLSQL program returns an error if the size is greater than 10M. Let me know if this suits you.
Correction: Actually the plugin I mentioned before can be used in a dynamic action.
Continuation
As I said before, I would use a piece of PL/SQL code over the apex_application_temp_files table. That table is maintained automatically by Apex. In my application I have the following code associated to the button which Upload the files. Once the user selects the file he/she wants to upload, the process triggers the procedure to check several aspects ( in my case I check that is a csv file and also the size )
procedure ValidateFiles (p_file_name in varchar2, p_file_type in varchar2) is
v_blob blob;
blob_length integer;
v_mime_type varchar2(2000);
vlimitsize pls_integer := XXXXXXX -- your limit here
--
begin
SELECT BLOB_CONTENT,
DBMS_LOB.GETLENGTH(blob_content),
mime_type,
INTO v_blob,blob_length,v_mime_type
FROM apex_application_temp_files
WHERE name = p_file_name;
if upper(v_mime_type) <> 'TEXT/COMMA-SEPARATED-VALUES' then
raise_application_error(-20000, 'Wrong extension file, expected:
text/comma-separated-values.');
end if;
-- debug apex messages
apex_debug.message('blob length: %s', blob_length);
--
if blob_length > vlimitsize
then
raise_application_error(-20000, 'File is greater than the limit allowed');
end if;
end;
end ValidateFiles;

How to declare Windows path in Oracle PLSQL

I need to burn a blob column from an image that is saved in windows.
How do I declare the image path in Oracle PLSQL?
Ex:
DECLARE
dest_lob BLOB;
-- this line report ORA22285 "non-existent directory or file for %s operation"
src_lob BFILE := BFILENAME('MY_DIR', 'C:\Users\gus\Desktop\image.jpg');
BEGIN
INSERT INTO teste_gustavo_blob VALUES(2, EMPTY_BLOB())
RETURNING imagem INTO dest_lob;
DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LoadFromFile( DEST_LOB => dest_lob,
SRC_LOB => src_lob,
AMOUNT => DBMS_LOB.GETLENGTH(src_lob) );
DBMS_LOB.CLOSE(src_lob);
COMMIT;
END;
Note: I'm trying to insert a record into a table through a Windows machine using SQLDeveloper. The database is on a remote server.
the path needs to be part of the directory object definition, and the file name is just that - just the file name. Example;
CREATE DIRECTORY MY_DIR AS 'C:\Users\gus\Desktop';
..
BFILENAME('MY_DIR', 'image.jpg');
Note that the directory is created on the server not your local machine. So if you are trying to create a file on a local machine, this will not work in pl/sql. PL/sql runs on the server, not the client. In that case, you need to code a client.
The database can only see directories which are local to it. It cannot see files on your PC (unless the database is running on that PC). So you cannot load your file through PL/SQL.
However, you say you are using SQL Developer. You can load a BLOB by editing the table's data in the Table Navigator. Click on the Data tab then edit the cell (the BLOB column of the row you want to load the file into). Use the Local Data > Load option to upload your file. That Jeff Smith has publish a detailed step-by-step guide on his blog.
I had a similar problem recently. I needed to dev test a feature and I needed a PDF file in my DB. I read few questions here and formulated an answer. I inserted a row manually with SQL and changed the file manually after that.
The SQL:
insert into ATTACHMENT_TABLE (id, file_content) values
(1, utl_raw.cast_to_raw('some dummy text'));
Using DBeaver, I edited the row and loaded the file from my windows PC. The end result is a row which contains the PDF file I wanted.

How to select only folder not files using FBean oracle forms

I have sample oracle form AWTFileDialog in which open dialog box and select files but I want user select only folder and get all files inside folder.
Code:
:BL.FILE := FBean.Invoke_Char('CTRL.BEAN', 1, 'openFile' ,'Open a file...,C:\');
I am using oracle forms 11g
How to achieve this target
Thanks
One option would be using webutil_file package of webutil.pll which should be attached, and the object library webutil.olb should be imported by subclassing to the forms before proceeding with the program. After all, consider to write the following code :
Declare
v_dir varchar2(500);
Begin
Client_Tool_Env.Getvar('WINDIR',v_dir);
:BL.FILE := webutil_file.file_open_dialog(v_dir,'myblock','*.*','Open a file...');
End;

40735: when-button-pressed trigger raised unhandled exception ORA-305500

I want to generate report in Excel File using oracle forms 10g and implement trigger when-button-pressed. When button press then getting following error:
40735: when-button-pressed trigger raised unhandled exception ORA-305500
Code:
declare
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
arglist ole2.list_type;
row_num number;
col_num number;
fontObj ole2.obj_type;
cursor rec is SELECT so.descr saleorgdescr,ih.invdate invdatemaster, ih.docNUM docnum,
TO_CHAR(ih.invdate,'mon-yyyy') invmonth
FROM ARMINVHEAD ih, SDMSALEORG so
WHERE
ih.status='69'
AND TO_DATE(ih.INVDATE,'DD-MM-RRRR')
BETWEEN
TO_DATE('01-01-2008','DD-MM-RRRR')
AND
TO_DATE('01-01-2009','DD-MM-RRRR')
order by IH.INVDATE, ih.docnum;
procedure SetCellValue(rowid number,colid number,cellValue varchar) is
begin
arglist := ole2.create_arglist;
ole2.add_arg(arglist,rowid);
ole2.add_arg(arglist,colid);
cell:= ole2.get_obj_property(worksheet,'Cells',arglist);
fontObj := ole2.get_obj_property(cell,'Font');
ole2.destroy_arglist(arglist);
ole2.set_property(cell,'value',cellValue);
ole2.set_property(fontObj,'Size',16);
ole2.set_property(fontObj,'BOLD',1);
ole2.set_property(fontObj,'ColorIndex',7);
ole2.release_obj(cell);
end SetCellValue;
procedure app_init is
begin
application := ole2.create_obj('Excel.Application');
ole2.set_property(application,'Visible',true);
workbooks := ole2.get_obj_property(application,'workbooks');
workbook := ole2.Get_Obj_Property(workbooks,'add');
worksheets := ole2.get_obj_property(application,'worksheets');
worksheet := ole2.Get_Obj_Property(worksheets,'add');
ole2.set_property(worksheet,'Name','Emp Sheet');
end app_init;
procedure save_excel(path varchar,filename varchar) is
begin
OLE2.Release_Obj(worksheet);
OLE2.Release_Obj(worksheets);
-- Save the Excel file created
If path is not null then
Arglist := OLE2.Create_Arglist;
OLE2.Add_Arg(Arglist,path||'\'||file_name||'.xls');
OLE2.Invoke(workbook, 'SaveAs', Arglist);
OLE2.Destroy_Arglist(Arglist);
end if;
end save_excel;
begin
app_init;
row_num:=1;
col_num:=1;
SetCellValue(row_num,col_num,'saleorgdescr');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'invdatemaster');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'docnum');
col_num:=col_num + 1;
SetCellValue(row_num,col_num,'invmonth');
for i in rec loop
row_num:=row_num + 1;
col_num:=1;
SetCellValue(row_num,col_num,i.saleorgdescr);
col_num:=2;
SetCellValue(row_num,col_num,i.invdatemaster);
col_num:=3;
SetCellValue(row_num,col_num,i.docnum);
col_num:=4;
SetCellValue(row_num,col_num,i.invmonth);
end loop;
save_excel('C:\excel_export','emp_data');
OLE2.Release_Obj(workbook);
OLE2.Release_Obj(workbooks);
OLE2.Release_Obj(application);
end;
How to solve this problem in oracle forms 10g?
I am using oracle forms 10g with Oracle Apps ERP Module
ORA-305500 is a generic OLE2 error, indicating some problem between Forms and a non-Oracle resource, in this case Excel.
The following error raise at line application := ole2.create_obj('Excel.Application');
The basic problem is you are using Forms 10g, which uses an n-tier architecture. This is a massive change from client-server of Forms 6i or earlier. It means Forms OLE runs applications like Excel locally to the Forms application i.e. on the Forms app server not your desktop. So OLE won't work, unless your Forms app server runs on Windows OS and has Excel installed, and even then it will generate the file on the server.
Forms 10g comes with the Webutils library to support client-server style functionally in a multi-tier system. You need to use CLIENT_OLE2() functions to wrangle Excel in Forms 10g and WebUtil_File.File_Save_Dialog() to save the file to a local directory.
There is a good example on the OTN Forum here (link).
Webutil Error: Oracle.forms.webutil.ole.OleFunctions bean not found
Sounds like you haven't configured Forms to use Webutil properly (or at all). There's some stuff in the Forms Help document or you can follow this article (link).

Oracle 11g - sys_refcursor

I am working on a system where Oracle 11g is the back end database.
I have very limited permissions on the database and as such all I can do is call procedures that reside in packages.
Gerally, these procedure return their result set via an OUT parameter of type sys_refcursor.
I can call them fine in C# and get data from the cursor via the C# OracleDataset type.
Here is my question.
I want to be able to run these procedures and see the results via SQL Developer.
I can execute the procedure fine, but seeing the contents of the sys_refcursor OUT parameter is boggling me.
I've done some gooling and people ar saying about creating type and other solutions I simply do not have the permissions to persue.
So, how can I possibly see the result set contained in a sys_refcursor?
So say I have a procedure with this signature....
procedure an_oracle_Proc(p_ref IN varchar2,
p_result_set OUT sys_refcursor);
I call it like this....
DECLARE
l_ref VARCHAR2(10);
l_result_set sys_refcursor;
BEGIN
oracle_pkg.an_oracle_Proc(p_ref => l_ref,
p_result_set => l_result_set);
--How to select from l_result_set with limited permissions
END
How can I look at the contents of l_result_Set?
This is repeating the answer I linked to before really but specifically for your code:
VARIABLE result_set refcursor;
DECLARE
l_ref VARCHAR2(10);
BEGIN
l_ref := 'whatever';
oracle_pkg.an_oracle_Proc(p_ref => l_ref,
p_result_set => :result_set);
END;
/
PRINT result_set
... and run all of that as a script from an SQL Worksheet. The contents of the ref cursor will be shown in the script output window.
Thought I'd have another look and found this - amazing what stepping away from the computer can do. ;)
I just have to select the appropriate variable on the left pane.
http://www.thatjeffsmith.com/archive/2011/12/sql-developer-tip-viewing-refcursor-output/
Still - it would be nice to write my own SQL to do this rather than using the execute window.
Sys_refcursor form an anonymous block is bit tricky. Use the sql-developer, explore the package or procedure , right click and execute the procedure/package.
Sql-developer will open an input/output UI where you can key in values. And you can see the output on the same UI as well. Let me know if you need more details. I was actually debugging the same a couple of weeks back successfully.

Resources