Oracle8(TM) ConText(R) Cartridge Application Developer's Guide
Release 2.0
A54630-01

Library

Product

Contents

Index


Prev Next

D
Input/Output Utility

This appendix describes how to use the ConText input/output utility. You use this utility in Windows 32-bit environments such as Windows NT and Windows 95.

Note:

The components described in this chapter are not distributed on the Oracle8 ConText Cartridge CD; they are distributed as part of the Oracle8 ConText Cartridge Workbench, which is available on a separate CD.  

Using the CTXIO32 Utility

The CTXIO32 utility enables you to move text from database to client-side files in a Windows 32-bit environment and vice-versa.

The CTXIO32 utility can be used to perform the following operations:

In addition, you can use the I/O utility to spawn an operating system command and to execute any PL/SQL or SQL*Plus that can be executed in an anonymous PL/SQL block.

These operations are performed in a sequence defined by a parameter file that you specify on the command line.

Command-Line Syntax

The CTXIO32 utility has the following command-line syntax:

ctxio32 [-w] [-p file] [-l file] [-d connect_string]

Parameter   Description  

-w  

Display status window. Messages in the parameter file are displayed in this window during processing.  

-p file  

Name of parameter file.

For more information about the format of the file, see "Parameter File Format" in this appendix.  

-l file  

Name of log file. Error and debug messages, as well as any messages in the parameter file, are output to this file. No messages are reported directly to the user.  

-d connect_string  

Database connect string.  

Parameter File Format

Start Tag   End Tag   Text   Description  

<SQL>  

</SQL>  

Up to 32k of SQL split over many lines. Keep lines below 2k.  

Encloses SQL commands.  

<GET>  

</GET>  

Line 1: Destination filename

Line 2: Table containing source document

Line 3: Column containing source document

Line 4: WHERE clause (excluding WHERE keyword)

 

Writes a document from database table to operating system.  

<PUT>  

</PUT>  

Line 1: Source filename

Line 2: Destination table name

Line 3: Destination column name

Line 4: WHERE clause (excluding WHERE keyword)

 

Puts a file-system document into a database table.

 

<REG>  

</REG>  

Reg_key, Reg_name [, Trunc_string]  

Registration entries can be used within <EXE> </EXE> pairs. Reg_key is the registration key, as it appears in the LHS pane of Registry Editor window. 'Reg_value is the registry entry name as it appears in the RHS pane of the Registry Editor window. An empty string ("") signifies "(Default)". Trunc_string is optional and will cause truncation of the fetched registry value from the given string. Many useful registry entries have '%1' or similar placeholders. Therefore, by passing a Trunc_string of "" causes the registry entry to be truncated and the required filename to be given after the marker. See the example below.  

<LOAD>  

</LOAD>  

Line 1: Table_name [TAB_OPTIONS]

Line2: Column_name[COL_OPTIONS],

Column_name[COL_OPTIONS]...

Line 3+:Column_data, column_data  

Line 1: TAB_OPTIONS := (Replace)

Replace: Data will be updated rather than inserted into the database.

Line2:

COL_OPTIONS := (COL_OPTION, COL_OPTION...) COL_OPTION := ReadFromFile | Replace "X" "Y" | Ignore "X" "Y" ["Z"] | SaveDir "X" | TempFile "X" | Where

ReadFromFile Read the contents of the given file into the database.

Replace After reading the file replace all occurrences of X with Y. There can be more than Replace call per column. X and Y are case sensitive

Ignore After reading the file remove all text between X and Y inclusive of X and Y. If Z is given the only remove the text if Z occurs between X and Y. X, Y and Z are case sensitive.

Savedir This will copy the post-filtered versions of the input files into directory X.

Where This defines the columns to be used to define the where clause. This is used to insert the file data into the database and to perform the updates during REPLACE mode.

Line 3: Column_data = Strings, dates etc should be quoted as if they were entered in an INSERT SQL statement. Note: only ASCII files can be filtered with Replace and Ignore.  

<EXE>  

</EXE>  

OS command.  

Operating system command. This can be split over many lines. If so, carriage returns will be removed and replaced by spaces.  

<QU>  

</QU>  

Line 1: Question

Line 2: Yes_label

Line 3: No_label  

This prompts the user with the given question and resumes execution after the line starting 'Yes_label' if the user responds 'yes'. If the user responds 'no' execution is continued after the line starting no_label.  

<GOTO>  

label  

None.  

Resumes execution after the line starting label.  

<MESS>  

end of line  

Message  

Displays message in log file and, if -w option is chosen, diplays in status window.  

#  

end of line  

None.  

Comment line.  

Example

The file below is an example CTXIO32 parameter file.

The command to execute this parameter file is:

ctxio32 -v notepad -s -w -p pfile.txt -l log.txt -d ctxdemo/ctxdemo 

#
# CTXIO sample script
# File : pfile.txt

#
# Script split into 2
#
# 1) First  section (#ReplaceAll)  replaces all  employees.
# 2) Second section (#ReplaceSome) replaces some employees.
#
# The <QU> .. </QU> section asks a question and jumps to the relevant tag
#

<QU>
Do you wish to replace ALL employees?
#ReplaceAll
#ReplaceSome
</QU>

#
# -----------   This section replaces all current employees -----------

#
#ReplaceAll


<MESS>Drop employee table
<SQL>
DROP TABLE CTXIO_EMP
</SQL>

<MESS>Create employee table
<SQL>
CREATE TABLE CTXIO_EMP (EMPNO NUMBER, EMPNAME VARCHAR2(100), RESUME LONG)
</SQL>
<SQL>
alter table ctxio_emp add constraint unique_ctxioemp unique(empno)
</SQL>

<MESS>Truncate employee table
<SQL>
truncate table CTXIO_EMP
</SQL>

<MESS>Loading ALL employees into database...
# Use SaveDir so we can check search and replace has required affect
<LOAD>
CTXIO_EMP
EMPNO(WHERE), EMPNAME, RESUME(ReadFromFile, Ignore "<Confidential>" "</Confidential>", Replace 
"brewing" "chemistry", Replace "Brewing" "Chemistry", SaveDir "temp")
1,"Joe Bloggs","jbloggs.htm"
2,"Ray Smith","rsmith.htm"
3,"Lisa Turner","lturner.htm"
</LOAD>

# Skip next bit which is for single update only

<GOTO> #Common

#
# --------------   This section updates the resumes of some employees --------------
#
#ReplaceSome

<MESS>Replacing resumes in database...
# Use SaveDir so we can check search and replace has required affect
<LOAD>
CTXIO_EMP (REPLACE)
EMPNO(WHERE), EMPNAME, RESUME(ReadFromFile, Ignore "<Confidential>" "</Confidential>", Replace 
"brewing" "chemistry", Replace "Brewing" "Chemistry", SaveDir "temp")
2,"Ray Smith","rsmith.htm"
</LOAD>

# Load this resume without search and replace
<PUT>
jbloggs.htm
ctxio_emp
resume
EMPNO=1
</PUT>

#
# ----------- This section common to both -----------

#
#Common

# Check Smith's CV was filtered and stored OK
<GET>
temp\rsmith.htm
ctxio_emp
resume
EMPNO=2
</GET>


#
# ----------- Create OCO index -----------
#
<MESS>Dropping policy and index (may produce errors but this is OK)...
<SQL>
begin 
ctxsys.ctx_ddl.drop_index('CTXIO_EMPRES');
end;
</SQL>
<SQL>
begin 
ctxsys.ctx_ddl.drop_policy('CTXIO_EMPRES');
end;
</SQL>

<MESS>Creating policy on test table and creating index...
<SQL>
begin 
ctxsys.ctx_ddl.create_policy(policy_name=>'CTXIO_EMPRES',
colspec=>'CTXIO_EMP.RESUME',
textkey=>'EMPNO'); 
end;
</SQL>
<SQL>
begin
ctxsys.ctx_ddl.create_index('CTXIO_EMPRES');
end;
</SQL>

#
# ----------- Do some OCO querying -----------
#

<MESS>Create marked up table
<SQL>
drop table mutab
</SQL>
<SQL>
create table mutab (id number, document long)
</SQL>

<MESS>Get highlights...
<SQL>
begin 
  ctxsys.ctx_query.highlight(CSPEC=>'CTXIO_EMPRES', TEXTKEY=>2,
   query=>'chemistry,Chemistry', mutab=>'MUTAB', ID=>999,starttag=>'<EM>',
   endtag=>'</EM>');
end;
</SQL>

<MESS>Write marked up text to file...
<GET>
mudoc.htm
mutab
document
id=999
</GET>

# This views the marked-up resume in notepad
#<EXE>
#notepad mudoc.htm
#</EXE>

# This views the HTML resume in Netscape
<EXE>
<REG>HKEY_CLASSES_ROOT\NetscapeMarkup\shell\open\command,,"</REG> file:///mudoc.htm
</EXE>

#Finished
                                                                                                                                                                      




Prev

Next
Oracle
Copyright © 1997 Oracle Corporation.
All Rights Reserved.

Library

Product

Contents

Index