Home » Developer & Programmer » Forms » Spell Check from Forms - Not working for data over 4000 bytes (merged 2) (Forms 10g with ole2 and webutil)
Spell Check from Forms - Not working for data over 4000 bytes (merged 2) [message #407147] Mon, 08 June 2009 12:50 Go to next message
irahman21
Messages: 2
Registered: June 2009
Location: Canada
Junior Member
I am trying to spell check a form field with clob data type. When I pass the value into Spellcheck Function, it is able to buffer data upto 32760 bytes but when the OLE2 tries to invoke the Spell Check on this value, if the data size is greater than 4000 bytes, it gives a non-oracle error ora-305500, but if it is less than 4000 bytes, the spell check from word is invoked and processing completes successfully.
Code is given below and where the error occurs is highlited...
PROCEDURE CheckSpell 
( 
PC$Item in Varchar2 --pass the name of the Form Field to be spell checked. 
) IS 
------------------------------------------- 
-- Call the MSWord CheckSpell function -- 
------------------------------------------- 
MyApplication client_ole2.OBJ_TYPE; 
MyDocuments client_ole2.OBJ_TYPE; 
MyDocument client_ole2.OBJ_TYPE; 
MySelection client_ole2.OBJ_TYPE; 
args client_ole2.LIST_TYPE; 

Begin 

MyApplication:=client_ole2.CREATE_OBJ('Word.Application'); 
client_ole2.SET_PROPERTY(MyApplication, 'Visible', 0); 
MyDocuments:=client_ole2.GET_OBJ_PROPERTY(MyApplication, 'Documents'); 
MyDocument := CLIENT_OLE2.INVOKE_OBJ(MyDocuments,'add'); 
Myselection := CLIENT_OLE2.GET_OBJ_PROPERTY(MyApplication,'Selection'); 

--This below line causes the error exception when value of PC$Item is more than 4000 bytes 
client_ole2.SET_PROPERTY(Myselection,'Text',Name_in(PC$item)); 
-- 

client_ole2.INVOKE(MyDocument,'CheckSpelling'); 
MySelection:=client_ole2.GET_OBJ_PROPERTY(MyApplication, 'Selection'); 
client_ole2.INVOKE(MySelection,'WholeStory'); 
client_ole2.INVOKE(MySelection,'Copy'); 
COPY( CLIENT_OLE2.GET_CHAR_PROPERTY(MyApplication,'Selection'), PC$Item ) ; 
args := CLIENT_OLE2.CREATE_ARGLIST; 
client_ole2.ADD_ARG(args,0); 
client_ole2.INVOKE(MyDocument,'Close',args); 
client_ole2.DESTROY_ARGLIST(args); 
client_ole2.INVOKE(MyApplication,'Quit'); 
client_ole2.RELEASE_OBJ(MySelection); 
client_ole2.RELEASE_OBJ(MyDocument); 
client_ole2.RELEASE_OBJ(MyDocuments); 
client_ole2.RELEASE_OBJ(MyApplication); 
copy(Substr(Replace(Name_in(PC$Item),CHR(13),CHR(10)),1,Length(Name_in(PC$Item))-1), PC$item ); 
Message('SpellCheck Completed'); 
Exception 
When others then 
Message(to_char(sqlcode)||'-'||sqlerrm); 
End;


Is there a way for the ms word buffer to hold more than 4000 bytes of data when invoking the ms word spell check?

Thanks,
Imran

[Updated on: Mon, 08 June 2009 13:04] by Moderator

Report message to a moderator

Re: Spell Check from Forms - Not working for data over 4000 bytes (merged 2) [message #407246 is a reply to message #407147] Tue, 09 June 2009 04:42 Go to previous messageGo to next message
TonyJaa
Messages: 50
Registered: May 2009
Member
Hello,

NAME_IN built-in returns varchar2 and i think that varchar2 value can contain up to 4000 characters.

Re: Spell Check from Forms - Not working for data over 4000 bytes (merged 2) [message #407318 is a reply to message #407147] Tue, 09 June 2009 10:09 Go to previous messageGo to next message
owais_baba
Messages: 289
Registered: March 2008
Location: MUSCAT
Senior Member
try this


PROCEDURE SpellCheck(text in long) IS
-- Declare the OLE objects
MyApplication OLE2.OBJ_TYPE;
MyDocuments OLE2.OBJ_TYPE;
MyDocument OLE2.OBJ_TYPE;
MySelection OLE2.OBJ_TYPE;
VITEM VARCHAR2(50):=:SYSTEM.CURsor_ITEM;
-- Declare handle to the OLE argument list
args OLE2.LIST_TYPE;
text_item long;
BEGIN

-- Create the Word.Application object and make Word visible
-- by setting the 'Visible' property to true
MyApplication := OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(MyApplication, 'Visible', 1);

-- get a handle on Documents collection
MyDocuments:= OLE2.GET_OBJ_PROPERTY(MyApplication, 'Documents');

-- Add a new document to the Documents collection
Mydocument := OLE2.INVOKE_OBJ(MyDocuments, 'Add');

-- Get a handle on Selection object
MySelection:=OLE2.GET_OBJ_PROPERTY(MyApplication, 'Selection');

-- Insert the text into word document

OLE2.SET_PROPERTY(MySelection, 'Text', text);

-- Save the document to the filesystem as EXAMPLE.DOC
args := OLE2.CREATE_ARGLIST;
-- OLE2.ADD_ARG(args, 'C:\DOCS\EXAMPLE.DOC');
-- OLE2.INVOKE(MyDocument, 'SaveAs', args);
ole2.INVOKE(MyDocument,'CheckSpelling');

OLE2.DESTROY_ARGLIST(args);
ole2.INVOKE(mYSelection,'WholeStory');

ole2.INVOKE(MYSelection,'Copy');
go_item(VITEM);
Select_All;
clear_item;
paste_region;
ole2.INVOKE(MyApplication,'Quit');
END;


and on block level trigger"key-entqry" write this code
SpellCheck(:Txt1);

thanks
owais baba



Re: Spell Check from Forms - Not working for data over 4000 bytes (merged 2) [message #407625 is a reply to message #407147] Wed, 10 June 2009 15:58 Go to previous message
irahman21
Messages: 2
Registered: June 2009
Location: Canada
Junior Member
Thanks for the quick response. For once ORACLE was really helpful to resolve this issue.

Before I give the solution, two things I want to mention based on the above answers....

The limit of a VARCHAR2 variable is 32767 bytes and not 4000 bytes. The 4000 byte limitation is only when inserting data into a VARCHAR2 dataype field in the databse.

Secondly, the Long datatype variable can also only hold 32767 bytes as it is implicitly converted to VARCHAR2 within PL/SQL.

Now the Solution:
-----------------

Issue:
The data with length of more than 4000 bytes and less than 32767 bytes is sent to the Spell Check function without issues. Within the Spell Check function, the CLIENT_OLE2 package from Webutil was not able to pass more than 4000 bytes to the ms word buffer for invoking the spelling dictionary.

Cause:
This was due to the code in the WEBUTIL library CLIENT_OLE2 package body where the Set_Property procedure and the Get_Char_Property procedures had defined the string variables within them to a VARCHAR2 of 4000 bytes.

Fix:
In order to fix the issue, the following procedures in CLIENT_OLE2 package were updated to redifine the string variables. Replace them for all occurances of the procedures in the Package body.

In Set_Property procedure, replace VARCHAR2 (4000 char) to VARCHAR2(32750).

In Get_Char_Property procedure, replace VARCHAR2 (4000 char) to VARCHAR2(32760).

After this, recompile the WEBUTIL library and re-attach the Webutil.pll to the form.

This will fix the invoking of word spell check for data fields with more than 4000 bytes of data (ofcourse to the upper limit of 32750 bytes)

Regards,
Imran
Previous Topic: Oracle Forms
Next Topic: Hi, I am unable to run form in internet explorer or mozilla
Goto Forum:
  


Current Time: Fri Dec 09 07:42:39 CST 2016

Total time taken to generate the page: 0.10990 seconds