Oracle Query - Doc1
Oracle Query - Doc1
Oracle Query - Doc1
1. Purpose
The purpose of this article is to demonstrate how, with the Webutil library, we
can upload local documents into the database, edit those stored documents on
the client machine, save modified documents to the database, and use the
MSWord CheckSpell function.
The goal is to have, with Webutil, the same functionality as an “OLE CONTAINER”
C/S component.
FUNCTION WEBUTIL_FILE.FILE_OPEN_DIALOG
(
directory_name,
file_name,
file_filter,
title
) return VARCHAR2;
directory_name is the name of the starting directory (let empty to start at the root)
file_name is the name of the searching file
file_filter is the list of file types to display (e.g. '|All files|*.*|' or
'|Word Files|*.doc|Excel Files|*.xls|')
title is the title of the dialog box
FUNCTION Webutil_File_Transfer.Client_To_DB
(
clientFile in VARCHAR2,
tableName in VARCHAR2,
columnName in VARCHAR2,
whereClause in VARCHAR2,
asynchronous in BOOLEAN default FALSE,
callbackTrigger in VARCHAR2 default NULL
) return BOOLEAN;
Assume you want to store the c:\docs\doc.xls in the DOC column of the
DOCUMENTS table where DOC_ID = 10, use the following instruction:
Declare
LB$Result BOOLEAN ;
Begin
LB$Result := Webutil_File_Transfer.Client_To_DB
(
‘c:\docs\doc.xls’,
‘DOCUMENTS’,
‘DOC’,
‘DOC_ID = 10’
) ;
End ;
Attention:
The Client_To_DB() function use an UPDATE statement to store the document
in an existing BLOB column, so the corresponding raw must exists in the table
before calling the function.
FUNCTION DB_To_Client
(
clientFile in VARCHAR2,
tableName in VARCHAR2,
columnName in VARCHAR2,
whereClause in VARCHAR2
) return BOOLEAN;
Example:
Declare
LC$Cmd Varchar2(256) ;
Ret WEBUTIL_HOST.PROCESS_ID ;
LN$Result Pls_Integer ;
LC$FicName Varchar2(128) := Name_In(
‘BLOB_TABLE.DOC_NAME’ ) ;
Begin
LC$Cmd := 'cmd /c start "" /WAIT "' || LC$FicName ||
'"' ;
Ret := WEBUTIL_HOST.blocking( LC$Cmd ) ;
LN$Result := WEBUTIL_HOST.Get_return_Code( Ret ) ;
End ;
Note the /WAIT parameter that wait the return of calling function before
returning to Forms
The following code allows to call the MSWord CheckSpell function and pass as an
argument the content of a TEXT item
PROCEDURE CheckSpell
(
PC$Item in Varchar2
) 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');
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');
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 );
Exception
When others then
Null ;
End;
CheckSpell( :system.cursor_item ) ;
5. Sample dialog
Click the Store local doc to database button to store the selected file in the database
The name of the new stored file is now displayed in the list of stored files
Double-click on the file name or click the Edit and save button to edit the document.
Run the CheckSpell function...
This basic sample could be the starting point of a most elaborated documentation
application.
You could add some columns to the BIN_DOCS table to implement a check-in/check-out
functionality that
allows every user to see a doc but only one could modify at the same time.