Home » Developer & Programmer » Forms » ORA-305500 Exception on When-Button-Pressed Trigger
ORA-305500 Exception on When-Button-Pressed Trigger [message #124560] |
Mon, 20 June 2005 03:57 |
hsinghalmrt
Messages: 51 Registered: March 2005
|
Member |
|
|
Hi All,
Would u pls tell me why this exception is occuring .pls help.
my code is below.
thanks in advance.
Procedure Edit_File
(v_linked_file in out file_link.linked_file%type,
v_copy_status in out file_link.copy_status%type,
i_ext in varchar2) is
args ole2.list_type;
v_linked_file1 file_link.linked_file%type;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
lv_temp number(10);
v_FileId Text_IO.File_Type;
Begin
change_attrib(v_linked_file,'0');
if v_copy_status = 'N' then
application := ole2.create_obj('Excel.Application');
ole2.set_property(application,'visible',1);
workbooks := ole2.get_obj_property(application,'workbooks');
args := ole2.create_arglist;
ole2.add_arg(args,v_linked_file);
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist(args);
ole2.release_obj(workbooks);
ole2.release_obj(workbook);
ole2.release_obj(application);
elsif v_copy_status = 'Y' Then
application := ole2.create_obj('Excel.Application');
ole2.set_property(application,'visible',1);
workbooks := ole2.get_obj_property(application,'workbooks');
args := ole2.create_arglist;
BEGIN
SELECT count(*)
INTO lv_temp
FROM file_link
WHERE upper(linked_file) = upper(v_linked_file);
IF lv_temp > 1 THEN
v_linked_file := new_filename(i_ext);
ole2.add_arg(args,filelocation||v_linked_file);
ole2.invoke(workbook,'SaveAs',args); ELSE
workbooks := ole2.get_obj_property(application,'workbooks');
args := ole2.create_arglist;
ole2.add_arg(args,filelocation||v_linked_file);
workbook := ole2.get_obj_property(workbooks,'Open',args);
END IF;
END;
ole2.destroy_arglist(args);
ole2.release_obj(workbooks);
ole2.release_obj(workbook);
ole2.release_obj(application);
end if;
End Edit_File;
in above procedure Excel Saveas is not working .
|
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #252630 is a reply to message #124560] |
Thu, 19 July 2007 08:29 |
the_wickedman
Messages: 4 Registered: July 2007
|
Junior Member |
|
|
Hi,
I try to open new OpenOffice document (in writer),
but I am getting the exception
FRM 40735:WHEN-BUTTON-PRESSED Trigger Raised unhandled Exception ORA - 305500
Please help me to resolve this exception.
my code is as follows in when-button-pressed trigger:
declare
App ole2.obj_type;
oDocument ole2.obj_type;
oDesktop ole2.obj_type;
args1 ole2.list_type;
args2 ole2.list_type;
Args ole2.list_type;
begin
App := ole2.create_obj('com.sun.star.ServiceManager');
args1 := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args1,'com.sun.star.frame.Desktop');
oDesktop := OLE2.INVOKE_OBJ(App,'createInstance',args1);
args2 := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args2,'private:factory/swriter');
OLE2.ADD_ARG(args2,'_blank');
OLE2.ADD_ARG(args2,'0');
OLE2.ADD_ARG(args2,Args);
oDocument := OLE2.INVOKE_OBJ(oDesktop,'loadComponentFromURL',ar gs2);
end;
Maybe i need some components from OpenOffice o be installed at forms?
I am running this on winXP, forms v 6i, OpenOffice 2.2.
I can start Writer using VB Script like this:
'The service manager is always the starting point
'If there is no office running then an office is started up
Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")
'Create the Desktop
Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
'Open a new empty writer document
Dim args()
Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter",_
"_blank", 0, args)
'Create a text object
Set objText= objDocument.getText
'Create a cursor object
Set objCursor= objText.createTextCursor
'Inserting some Text
objText.insertString objCursor, "The first line in the newly created text document."&_
vbLf, false
and I can start MS Word, MS Excel using:
DECLARE
app OLE2.OBJ_TYPE;
docs OLE2.OBJ_TYPE;
doc OLE2.OBJ_TYPE;
selection OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
BEGIN
-- create a new document
app := OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(app,'Visible',1);
docs := OLE2.GET_OBJ_PROPERTY(app, 'Documents');
doc := OLE2.INVOKE_OBJ(docs, 'add');
selection := OLE2.GET_OBJ_PROPERTY(app, 'Selection');
-- insert data into new document from long item
OLE2.SET_PROPERTY(selection, 'Text', :POLE_TEKSTOWE5);
-- save document as example.doc
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'd:\example.doc');
OLE2.INVOKE(doc, 'SaveAs', args);
OLE2.DESTROY_ARGLIST(args);
-- close example.doc
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 0);
OLE2.INVOKE(doc, 'Close', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.RELEASE_OBJ(selection);
OLE2.RELEASE_OBJ(doc);
OLE2.RELEASE_OBJ(docs);
-- exit MSWord
OLE2.INVOKE(app,'Quit');
end;
But I can't start Writer from Forms
Konrad
|
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #261643 is a reply to message #253181] |
Thu, 23 August 2007 03:35 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
Did anyone find the Solution for this? I am getting the same exception at line:
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
My code is as follows:
DECLARE
-- Declare handles to OLE objects
application OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
workbook OLE2.OBJ_TYPE;
worksheets OLE2.OBJ_TYPE;
worksheet OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
args OLE2.OBJ_TYPE;
Check_file text_io.file_type;
no_file exception;
PRAGMA exception_INIT (no_file, -302000);
cell_value varchar2(2000);
BEGIN
-- Check the file can be found, if not exception no_file will be raised
Check_file := TEXT_IO.FOPEN('C:\test.XLS','R');
TEXT_IO.FCLOSE(Check_file);
Message('hellllllllllooo');
application := OLE2.CREATE_OBJ('Excel.Application');
ole2.set_property(application,'Visible','true');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'c:\test.xls');
workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);
ole2.destroy_arglist(args);
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'Sheet1');
Message('hello 2_1');
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
ole2.destroy_arglist(args);
Message('hello 3');
-- Get value of cell A1 of worksheet Sheet1
args:= ole2.create_arglist;
ole2.add_arg(args, 1);
ole2.add_arg(args, 1);
cell:= ole2.get_obj_property(worksheet, 'Cells', args);
ole2.destroy_arglist(args);
cell_value :=ole2.get_char_property(cell, 'Value');
message(cell_value);
ole2.invoke(application,'Quit');
-- Release the OLE2 object handles
ole2.release_obj(cell);
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.release_obj(application);
message('Hi am in safer side');
-- ASSIGN RETURN VALUE FROM EXCEL TO Text Field
:Block2.RETURN_VAL := cell_value;
exception
WHEN no_file THEN
MESSAGE('file not found.');
WHEN OTHERS THEN
MESSAGE(sqlerrm);
PAUSE;
FOR i IN 1 .. tool_err.nerrors LOOP
MESSAGE(tool_err.message);
PAUSE;
tool_err.pop;
END LOOP;
END;
I went through the links Maaher posted, and I tried both INVOKE_OBJ and GET_OBJ_PROPERTY, same exception raised.
Thanks,
Baz
|
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #262217 is a reply to message #261885] |
Sat, 25 August 2007 03:55 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
Hi David,
The code is already starting excel.
When I run it, Excel opens in a different window and the test.xls file displays normally, but again it is failing or Raising the Exception at:
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
Thanks,
Baz
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #262235 is a reply to message #262217] |
Sat, 25 August 2007 09:23 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
I managed to overcome the exception by using the following Code for the "worksheet" section:
worksheet := OLE2.GET_OBJ_PROPERTY(application,'activesheet');
OLE2.SET_PROPERTY(worksheet , 'Value','Sheet1');
instead of:
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'Sheet1');
Message('hell 2_1');
worksheet := ole2.GET_OBJ_PROPERTY(workbook,'Worksheets',args);
ole2.destroy_arglist(args);
Now it is working fine but I still have one issue . When I write to the Excel Sheet (Update, make changes) it is Prompting me "TO CONFIRM SAVE CHANGES" before Closing the Workbook. How can I apply the Changes without getting the PROMPT?
The current CLOSING code is (some changes have been applied to Code in Previous Post):
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'C:\test.xls');
OLE2.INVOKE(workbook, 'Save', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.INVOKE(workbook,'CLOSE');
ole2.release_obj(cell);
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.invoke(application,'Quit');
ole2.release_obj(application);
I want to apply the changes in Excel, Save the Sheet/Workbook, and close it without interrupting my work on the Oracle Forms side, as now it is Waiting for the User's Manual Response to Apply/Not Apply the Changes...
Thanks in advance,
Baz
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #262299 is a reply to message #262235] |
Sun, 26 August 2007 01:29 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
DONE
To Automatically Close EXCEL without getting the Prompt Pop-up, I did the following:
OLE2.INVOKE(worksheet, 'Save');
OLE2.INVOKE(workbook, 'Save');
OLE2.INVOKE(workbook,'CLOSE');
FINAL CODE, below:
DECLARE
-- Declare handles to OLE objects
application OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
workbook OLE2.OBJ_TYPE;
worksheets OLE2.OBJ_TYPE;
worksheet OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
args OLE2.OBJ_TYPE;
Check_file text_io.file_type;
no_file exception;
PRAGMA exception_INIT (no_file, -302000);
cell_value varchar2(2000);
BEGIN
-- Check the file can be found, if not exception no_file will be raised
Check_file := TEXT_IO.FOPEN('C:\test.XLS','R');
TEXT_IO.FCLOSE(Check_file);
Message('hellllllllllooo');
-- ***********************************
application := OLE2.CREATE_OBJ('Excel.Application');
--ole2.set_property(application,'Visible','true');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
args := OLE2.CREATE_ARGLIST;
ole2.add_arg(args,'c:\test.xls');
workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);
ole2.destroy_arglist(args);
worksheets := ole2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
worksheet := OLE2.GET_OBJ_PROPERTY(application,'activesheet');
OLE2.SET_PROPERTY(worksheet , 'Value','Sheet1');
-- ***********************************
-- PASS VALUE INTO Excel CELL (ROW 371, COL 3)
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 371);
OLE2.ADD_ARG(args, 3);
cell := OLE2.GET_OBJ_PROPERTY(worksheet,'Cells', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(cell, 'Value', '97FI01');
-- Get value of cell (372,3) of worksheet Sheet1
args:= ole2.create_arglist;
ole2.add_arg(args, 372);
ole2.add_arg(args, 3);
cell:= ole2.get_obj_property(worksheet, 'Cells', args);
ole2.destroy_arglist(args);
cell_value :=ole2.get_char_property(cell, 'Value');
message(cell_value);
-- save document as test.xls
OLE2.INVOKE(worksheet, 'Save');
OLE2.INVOKE(workbook, 'Save');
OLE2.INVOKE(workbook,'CLOSE');
-- Release the OLE2 object handles
ole2.release_obj(cell);
ole2.release_obj(worksheet);
ole2.release_obj(worksheets);
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.invoke(application,'Quit');
ole2.release_obj(application);
-- ASSIGN RETURN VALUE FROM EXCEL TO Text Field
:Block2.RETURN_VAL := cell_value;
exception
WHEN no_file THEN
MESSAGE('file not found.');
WHEN OTHERS THEN
MESSAGE(sqlerrm);
PAUSE;
FOR i IN 1 .. tool_err.nerrors LOOP
MESSAGE(tool_err.message);
PAUSE;
tool_err.pop;
END LOOP;
END;
Hope this helps others in the future.
Baz
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #271025 is a reply to message #262299] |
Fri, 28 September 2007 14:19 |
bavinash05
Messages: 2 Registered: September 2007
|
Junior Member |
|
|
Hi,
I have same code, but bit different requirement.
All i want to do is "OPEN" the excel file which is on Application server, this excel file has a macro inside it which creates another excel file an populates data from some other excel file which is present in same directory.
So my final code looks like -
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;
args ole2.list_type;
BEGIN
/*Test OLE2 for Opening Excel File*/
application:= ole2.create_obj('Excel.Application');
ole2.set_property(application,'Visible','true');
--workbooks := ole2.invoke_obj(application, 'Workbooks');
workbooks := OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
-- Open the required workbook
args:= ole2.create_arglist;
ole2.add_arg(args, 'c:\temp_dir\Book2.xls');
--workbook := ole2.invoke_obj(workbooks, 'Open', args);
workbook := ole2.GET_OBJ_PROPERTY(workbooks,'Open',args);
ole2.destroy_arglist(args);
worksheets := ole2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
worksheet := OLE2.GET_OBJ_PROPERTY(application,'activesheet');
OLE2.SET_PROPERTY(worksheet , 'Value','Sheet1');
OLE2.INVOKE(workbook,'CLOSE');
-- Release the OLE2 object handles
ole2.release_obj(workbook);
ole2.release_obj(workbooks);
ole2.invoke(application,'Quit');
ole2.release_obj(application);
End;
But all i can see is that there is no error raised, form executes till end. But then no result EXCEL file is created as it should have been after execution of macro.
I did open the EXCEL file with macro on application server by double clicking it, this way result excel file is created, but not from form? - Any suggestions?
Secondly i can see, EXCEL process created in Task Manager of Application Server, but that process hangs there itself, i cant end that process.
Any help is more than welcome!
Thanks & Regards,
Avinash.
Pune- India.
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #271304 is a reply to message #271025] |
Mon, 01 October 2007 03:51 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
hi Avinash,
I am replying to your post as I have faced further complications with the Same issue again, after I had thought that everything was working fine on my Development Environment (Launching Excel, Enabling Addins Programatically, getting Values populated into the Excel Sheet and then sent back into my Form) running the Form and Excel on my Machine, when moved to Production Environment on the Application Server, then the Macro's for Loading the Addins Failed and thus the Data was not being retrieved to be sent back to Oracle Forms from Excel.
In response to your issues:
Quote: |
I did open the EXCEL file with macro on application server by double clicking it, this way result excel file is created, but not from form? - Any suggestions?
|
Same thing happended to me, I believe that the Excel MACRO's when the Excel Sheet is triggered Programatically are NOT WORKING PROPERLY. I agree that when you trigger the Sheet manually, it does the job. In my case, the WORKBOOK_OPEN macro routines are throwing the EXCEPTION.
Quote: |
Secondly i can see, EXCEL process created in Task Manager of Application Server, but that process hangs there itself, i cant end that process.
|
For this, COMMENT OUT worksheets:
--worksheets := ole2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
worksheet := OLE2.GET_OBJ_PROPERTY(application,'activesheet');
OLE2.SET_PROPERTY(worksheet , 'Value','Sheet1');
ALL the OLE2 objects created must be Destroyed before closing the application otherwise you will keep having the Excel.exe process in the background. (Refer to another POST "How to kill EXCEL.exe from Task Manager from Oracle Forms" in this Forum for more info on this Problem)
Hope that the above helps, please let me know if you can get the FIRST one working as I haven't been able to resolve it yet on the Application Server.
Regards,
Baz
|
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #271642 is a reply to message #271638] |
Tue, 02 October 2007 05:22 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
HI Avinash,
I gave you the solution for the SECOND Issue that you have (EXCEL.EXE).
As for the MACRO Part, I still don't have a solution to have the Excel Macro's Run when the Excel File is opened Programatically from my Oracle Form. Again this Only worked on my Client Machine and not on the Application server (Have you tried that on your Machine???)
I might have to go with another alternative and NOT Excel when I need to Pull Data from my Data Source which in my case is a NOT a relational Database Historian; and feeding into Oracle Form. That is, Not to use Excel as a Mid-Layer.
My other option is to Create a DLL library and create an External Procedure to Connect to Oracle? I am not sure if this would work. I will let you know
If anyone has a solution/explanation for the Excel Macro's, we would really appreciate his/her assistance.
Regards,
Baz
|
|
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #320144 is a reply to message #262299] |
Wed, 14 May 2008 03:13 |
jale
Messages: 15 Registered: May 2008 Location: TURKEY
|
Junior Member |
|
|
hello Baz,
I tried your code on my PC, it works, but at appserver, it raises
no file exception
I use
Forms [32 Bit] Version 10.1.2.0.2 (Production)
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
EXCEL 2003
I have no info about version of webutil,
can you give versions of your system or any tip?
How can I make it work this code at appserver?
[Updated on: Wed, 14 May 2008 03:32] Report message to a moderator
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #320233 is a reply to message #320144] |
Wed, 14 May 2008 06:59 |
bbaz
Messages: 138 Registered: April 2007
|
Senior Member |
|
|
Hi Jale,
Unfortunately I couldn't get my Excel Macro to Run Programmatically when called from Oracle FORMS on the APPLICATION SERVER.
I was using Oracle DB 9i and Oracle Forms 9i (Forms [32 Bit] Version 9.0.2.9.0)
No File Exception seems to be a different problem related to the File Location.
Hope you can get your Code working fine.
Regards,
Baz
|
|
|
Re: ORA-305500 Exception on When-Button-Pressed Trigger [message #320239 is a reply to message #320233] |
Wed, 14 May 2008 07:16 |
jale
Messages: 15 Registered: May 2008 Location: TURKEY
|
Junior Member |
|
|
baz, hi again,
I called it no file exception.
Check_file text_io.file_type;
no_file exception;
PRAGMA exception_INIT (no_file, -302000);
cell_value varchar2(2000);
BEGIN
-- Check the file can be found, if not exception no_file will be raised
Check_file := TEXT_IO.FOPEN('C:\test.XLS','R');
TEXT_IO.FCLOSE(Check_file);
Message('hellllllllllooo');
exception
WHEN no_file THEN
MESSAGE('file not found.');
WHEN OTHERS THEN
MESSAGE(sqlerrm);
I found this in form help:
"Some OLE commands work fine in a client/server environment,
as well as in Web deployed applications (on the server),
but when you use WebUtil to enable client side functions,
they do not work.
For example, the following code will work by running OLE as client/server,
in a 3-tier environment, or on the application server: "
In here, ole2 word export code from oracle is written.
"However, when you change this code to use CLIENT_OLE2 (using search-and-replace) it doesn't work.
The following example is code which will convert to CLIENT_OLE2: "
What does it mean?
Thanks for replies..
Jal
|
|
|
|
Goto Forum:
Current Time: Thu Dec 26 15:21:47 CST 2024
|