Using Cloudscape’s Java Extensions,
Page 12 of 12


[top]
[prev]
[next]
Documentation Top
Global Index
Reference Manual
TOC Index
Grammar index
Developer's Guide
TOC Index
Tuning Cloudscape
TOC Index

Getting External Data: Using the Cloudscape Virtual Table Interface

Cloudscape comes with a powerful interface to external data. Called the Virtual Table Interface, or VTI, it provides a way for you to access data from some external data source within an SQL-J statement as if it were a real table.

To access the data, you first must create a Java class that fulfills the VTI requirements (see “Requirements and Options for VTI Classes”). To summarize, the class must implement the java.sql.ResultSet interface. The idea is that when you construct a new instance of your class, given some parameter or parameters, the instance of the class accesses some kind of external data. For example, it could call a routine to access another vendor’s database, it could open some Web pages, or it could open some kind of proprietary files. After accessing the data, it instantiates the data in such a way as to make it look like a ResultSet, and it provides the appropriate ResultSetMetaData that tells Cloudscape what the data looks like.

Within the SQL-J language, you do not need to declare a VTI or create it as a database object. Instead, you construct a VTI on the fly in a FROM clause using the NEW keyword, providing any parameters, and providing a correlation name for the virtual table.

For example, the class COM.cloudscape.tools.FileImport is a class provided by Cloudscape for an import/export utility that fulfills the VTI requirements. (Cloudscape has also provided a built-in class alias for this class). Within an SQL-J statement, you use the NEW keyword to create a virtual table from data in a flat file (from which you can SELECT).

INSERT INTO emptyTable
SELECT a, b,c
FROM NEW FileImport('c:/export/dump.txt')
AS tableFromFile (a, b, c)

You can write your own classes to access any kind of external data, such as news feeds, data from other database vendors, etc. See “Programming VTIs” for more information.

[top]
[prev]
[next]


Cloudscape Version 3.0
For technical support, go to: www.cloudscape.com and click Support.
Copyright © 1998 and 1999 Cloudscape, Inc. All rights reserved.