After an extended period of intense software development, we are pleased to announce the release of Recital 10 which is a milestone in our development efforts.
The Recital 10 release notes can be found here.
- Recital
A powerful scripting language with an embedded database used for developing desktop database applications on Linux and Unix.
- Recital Server
A cross-platform SQL database and application server.
- Recital Web
A server-side scripting language with an embedded SQL database for creating web 2.0 web applications.
When you start the loadbalancer.org appliance you will see the following:
Default login:
Username: root
Password: loadbalancer
Access to webclient from an external client is:
http://192.168.1.129:9080
http://192.168.1.129:9443
You can access the web administrator using the IP and ports described onscreen.
For the sri lanka porject we are looking for performance and the network diagram indicates we are happy to have the cluster on the same subnet as the rest of the network.
Direct routing is the fasted performance possible, it has the advantage over NAT that the Loadbalancer does not become a bottleneck for incoming and outgoing packets. With DR the loadbalancer simply examines incoming packets and the servers to route the packets directly back to the requesting user.
The web interfaceis the only way to fully configure the loadbalancer vm. The console tool lbwizard will get it initiallised and any further configurations can then be done via the webinterface.
Using lbwizard for the Sri lanka configuration follow these steps.
On the first Loadbalancer:
//Start
Is this unit part for a HA Pair?
YES
Have you already setup the Slave?
NO
Is this a one-armed configuration?
YES
Enter the IP Address for the interface eth0?
Enter IP address you wish to be assigned to the SLAVE loadbalancer.
Enter the netmask for interface eth0?
Enter netmask for the subnet.
Enter the Floating IP adrress?
Enter the IP address that will be IP assosiacted the the HA-pair of loadbalancers.
//Finish
On the 2nd loadbalancer VM, run the lbwizard.
//Start
Is this unit part of an HA-Pair?
YES
Have you already set up the Slave?
YES
What is the slave units UP address?
Enter the IP which you entered when configuring the other loadbalancer VM.
Is this a one-armed configuration?
YES
Enter the IP Address for the interface eth0?
Enter the IP that will be assigned to the MASTER loadbalancer
Enter the netmask for interface eth0?
Enter the subnet netmask.
Enter the Floating IP address?
Enter the IP address that will be IP assosiacted the the HA-pair of loadbalancers.
Enter the address of the default gateway?
Enter the deafult gateway for the subnet.
Enter the IP of the nameserver?
Enter the dns server.
Enter the port for the first Virtual server?
Enter 22 for ssh
Enter the IP address of the first real server?
Enter the real IP of the first appserver
//Finish
Now this is complete we need to go to the web admin interface to configure the 2nd Real Server. As the lbwizard program will only allow you to configure 1 real server.
Now login to the web admin using the default password:
username: loadbalancer
password: loadbalancer
Note: Connect to the IP you have now set for your master loadbalancer
Goto the edit configuration tab
Now click add a real server:
Enter a label
IP address of the server plus the port of the service i.e. 192.168.1.125:22
Edit Configuration -> Virtual Servers
persistancte -> NO
Scheduler-> LC
LC - Least-Connection: assign more jobs to real servers with
fewer active jobs.
Service to check -> custom1
Check port -> 22
Forwarding Method -> DR
Feedback Method -> Agent
Arp Problem when using DR
Every real server must be configured to respond to the VIP address as well as the RIP
address.
You can use iptables (netfilter) on the real server to re-direct incoming packets destined for the virtual
server IP address.
This is a simple case of adding the following command to your start up script (rc.local):
//replace 10.0.0.21 with the Virtual Server IP
iptables -t nat -A PREROUTING -p tcp -d 10.0.0.21 -j REDIRECT
chkconfig iptables on
DirectoryIndex default.rsp index.html
In this article Yvonne Milne looks at the use of the Recital Remote Data Connectivity Functions with Recital Database Gateways.
[data] oplocks = False level2 oplocks = False
veto oplock files = /*.dbf/*.DBF/*.ndx/*.NDX/*.dbx/*.DBX/*.dbt/*.DBT/
You can further tune samba by following this guide.
mount -t cifs {mount-point} -o username=name,pass=pass,directioThe directio option is used to not do inode data caching on files opened on this mount. This precludes mmaping files on this mount. In some cases with fast networks and little or no caching benefits on the client (e.g. when the application is doing large sequential reads bigger than page size without rereading the same data) this can provide better performance than the default behavior which caches reads (readahead) and writes (writebehind) through the local Linux client pagecache if oplock (caching token) is granted and held. Note that direct allows write operations larger than page size to be sent to the server.
Apr 22 16:57:39 bailey kernel: Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE Apr 22 16:57:39 bailey kernel: CIFS VFS: Send error in SessSetup = -13 Apr 22 16:57:39 bailey kernel: CIFS VFS: cifs_mount failed w/return code = -13The you need to create the Samba user specified on the mount command
smbpasswd -a usernameFYI - Make sure you umount all the Samba {mount-point(s)} before shutting down Samba.
Overview
file which contains information, including full path details, about all the files that belong to that particular database. Opening a database gives an application access to all that database's files - operating system and data dictionary protection and security permitting - in whichever directory on the system they reside and database commands can target the files as a single unit.NOTE: The word 'database' has often been used in Xbase products to refer to an individual '.dbf' file. In this article these are referred to as 'tables' and a database may contain many tables.
Advantages
Recital has always offered developers the maximum in flexibility in the design and deployment of their applications. The SET DEFAULT and SET PATH commands along with the ability to access files via their full Operating System path name has allowed data and code to be created and stored in any required location. Such flexibility does however put the onus on the developer to manage all elements of the application and ensure that maintenance tasks cover all files. The introduction of the database commands retains the established developer-driven design, but provides functionality to facilitate the access and maintenance of the components of that design. The functionality offered is in three main areas:- Facilitate data access
- Facilitate the storage and extraction of information about the files in an application
- Facilitate the maintenance of the files in an application
These three areas are looked at in more detail in the sections below.
Data Access
The immediate effect of using a database is that all the database's tables and associated files (indexes, dictionaries, memo files) are accessible with the issue of a single command, the OPEN DATABASE command.// Open the database
> open database southwind
// List the database tables
> list tables
Tables in Database southwind:
Name Source
categories /usr/recital/data/southwind/categories.dbf
customers /usr/recital/data/southwind/customers.dbf
employees /usr/recital/data/southwind/employees.dbf
example /usr/recital/data/southwind/example.dbf
order_details /usr/recital/data/southwind/order_details.dbf
orders /usr/recital/data/southwind/orders.dbf
productsbyname /usr/recital/data/southwind/productsbyname.dbf
products /usr/recital/data/southwind/products.dbf
shippers /usr/recital/data/southwind/shippers.dbf
suppliers /usr/recital/data/southwind/suppliers.dbf
cisamdemo /usr/recital/data/southwind/cisamdemo.dbf
/ Open a tableIn the case of the sample southwind database that ships with Recital products on all platforms and is shown above, this effect can be achieved in other ways (SET PATH or SET DEFAULT), since its files all reside in the southwind directory. The database advantage comes when the database catalog contains files from multiple directories, e.g.
> use example
// Open the database
> open database myapp
// List the database tables
> list tables
Tables in Database myapp:
Name Source
zipcodes /usr/myapp/data/lookups/zipcodes.dbf
customers /usr/myapp/data/current/customers.dbf
archive03 /usr/myapp/data/archive/archive03.dbf
archive04 /usr/myapp/data/archive/archive04.dbf
users /usr/allapps/data/users.dbf
menus /usr/myapp/data/system/menus.dbf
// Open a tableThe OPEN DATABASE command requires only the database name to be specified, not the complete path of a directory as with SET PATH or SET DEFAULT. Databases are searched for in the sub-directories of the directory defined in the DB_DATADIR environment variable or symbol. DB_DATADIR is set in the system wide configuration file.
> use users
#---------------------------------------------------NOTE: DB_DATADIR is read from these files at startup to determine the home directory for databases. Updates to DB_DATADIR once a Recital process is running do not change this setting. The OPEN DATABASE command and certain other database commands allow a '?' to be specified in place of a database name. In this case the 'Select a file' dialog is displayed, listing the available files in the DB_DATADIR directory.
# location of directories and important files
#---------------------------------------------------
DB_DATADIR="${ROI_ROOT}data/" ;export DB_DATADIR

Fig 1: Recital Terminal Developer OPEN DATABASE ? command.
This functionality is also supported by the PACK DATABASE, REBUILD DATABASE and REINDEX DATABASE commands.
Databases can also simplify data access for Recital Client Drivers using the Recital Database Server: instead of specifying a starting directory, only a database name is required. The database can handle files from multiple directories and associate tables with their single index files.
Recital Universal .NET Data Provider
/////////////////////////////////////////
// include the references below
using System.Data;
using Recital.Data;
/////////////////////////////////////////
// sample code to call a Stored Procedure
public int CallStoredProcedure()
{
string source = "Data Source=localhost;" +
"Database=southwind;" +
"uid=?;"+
"pwd=?";
RecitalConnection conn = new RecitalConnection(source);
...
Recital Universal JDBC Driver
import java.sql.*;
import java.io.*;
import java.net.URL;
import java.math.BigDecimal;
import Recital.sql.*;
public class jdbc_test {
public static void main(String argv[]) {
int i;
ResultSet rs;
ResultSetMetaData rsmd;
System.out.println("Recital JDBC driver verification.");
for (int ii=0; ii<1; ++ii) {
try {
//----------------------------------------------------------
//-- Load the Client Driver for the
//-- Recital Universal Application Server
//----------------------------------------------------------
System.out.println("Loading Recital JDBC driver.");
new RecitalDriver();
//-----------------------------------------------------------
//-- The standard format of the connection URL is as follows:
//-----------------------------------------------------------
String url = "jdbc:Recital:" +
"SERVERNAME=?;" +
"DATABASE=jdbc_test;" +
"USERNAME=?;" +
"PASSWORD=?;" +
"ENCRYPTION=false";
...
Windows Recital Universal ODBC Driver

Fig 2: Recital Universal ODBC Driver DSN setup using a database.
Database Procedure Libraries
A database can have an associated procedure library, which is automatically opened when the database is opened. This way, any procedures required by the database's data files are always available. The procedure library should reside in the database's directory and be named dbc_xxx_library.prg, where 'xxx' is the name of the database. When the OPEN DATABASE command is issued, a check is made for the database procedure library and a SET PROCEDURE TO dbc_xxx_library.prg ADDITIVE issued automatically. The procedure library is in turn closed when the CLOSE DATABASES command is issued. This is particularly convenient for client/server database access.Database Events
Issuing the OPEN DATABASE or CLOSE DATABASES command also fires a database event. Database events, like triggers for tables and forms, can have programs associated with them. The OPEN DATABASE command fires the DBC_OPENDATA event and will run a program called db_opendata.prg if one exists in the database's directory. Similarly, the CLOSE DATABASES command fires the DBC_CLOSEDATA event and runs the db_closedata.prg program. Both of these events also allow the current open or close operation to be abandoned if the associated program returns a logical false (.F.).Information
Databases, specifically database catalogs, are an excellent place to store information about the files required by a particular application. Instead of having to search through application code to determine which tables are being used and what index keys they have, this information can be viewed in the database catalog. Database catalogs are themselves Recital tables and can be viewed and/or updated in the same way as any other Recital table. There is also a series of commands to provide information about the currently open database. DISPLAY/LIST DATABASE The DISPLAY DATABASE and LIST DATABASE commands display the database name and path, followed by the equivalent of LIST STRUCTURE INDEX and LIST DICTIONARY for each table in the database, e.g.> open database southwind
> display database
Database Name: southwindDISPLAY DATABASE shows the data one screen at a time, whereas LIST DATABASE is ideal for output to a file.
Database Path: /usr/recital-9.0/data/southwind/
Structure for database : categories.dbf
Number of data records : 8
Date of creation : 05/12/2004
Date of last update : 05/12/2004
Database encrypted : False
Field Field Name Type Width Dec Description 1 CATEGORYID Numeric 10 Category ID 2 CATEGORYNAME Character 15 Category Name 3 DESCRIPTION Memo 8 Description 4 PICTURE Memo 8 Picture ** Total ** 42
Production DBX file: categories.dbx
Master Index TAG: CATEGORYID
Key: categoryid
Type: Binary
Len: 8
...
> open database southwind
> list database to file info.txt
DISPLAY/LIST TABLES
LIST TABLES, as we have seen above, lists all the tables from the database, giving each table's name and path. DISPLAY TABLES shows the information one screen at a time.Maintenance
Using a database can simplify the maintenance of an application's programs, tables and indexes. Multiple files, possibly in different directories, can be targeted by a single database command.COMPILE DATABASE
The COMPILE DATABASE command can be used to issue a COMPILE command for all program files listed in the database catalog.// Open the databaseNOTE: Program files are added to a database using the SQL CREATE PROCEDURE command.
open database myapp
// Compile all the database's programs
compile database
PACK DATABASE
The PACK DATABASE command issues a PACK command for every table in the database catalog. The PACK command is used to permanently remove any records that have been marked for deletion using the DELETE command.// Open the database
open database southwind
// Pack all the database's tables
pack database
REINDEX DATABASE
The REINDEX DATABASE command rebuilds all the tag and single indexes in the catalog. This is the equivalent of an INDEX ON <key> TO | TAG <index> for each catalogued index key.// Open the databaseNOTE: Using a database helps protect against a table being opened without its associated single index files also being opened. Any single index files that are included in the database catalog will automatically be opened when their table is opened via the database. If a single index appears in the database catalog, but the physical file no longer exists, it will be removed from the catalog when its associated table is next opened. All indexes, tagged indexes or single indexes, created while the database is open, are added automatically to the database catalog.
open database southwind
// Rebuild all the database's indexes
reindex database
REBUILD DATABASE
The REBUILD DATABASE command is used to PACK, rebuild the index tags and refresh the contents of the database catalog file.// Rebuild the database
rebuild database southwind
Creating and populating a database
Databases are created using the CREATE DATABASE command.// Create new databaseThe CREATE DATABASE creates a sub-directory in the DB_DATADIR and initializes the new database's catalog file. The catalog file is given the same basename as the database and is a Recital table with a '.cat' file extension. It has a production index file with a '.cax' file extension and a memo file with a '.cam' file extension.
create database newdb
// Open the databaseWith the database open, the catalog file table is opened in the highest available workarea and is given an alias name of its basename preceded by an underscore, e.g. '_newdb'. Any new tables or indexes that are created will be automatically added into the catalog and form part of the database. 'Free' tables can also be manually added into a database using the SQL ADD TABLE command.
open database newdb
// config.dbAs the application runs, 'myapp' in the example above, each table that is opened is added to the database catalog. Indexes that are opened are added in the same way. Using SET AUTOCATALOG OFF, inclusion in the catalog can be restricted. Once all required areas of the application have been catalogued, the application can be updated to make use of the database commands.
set sql on
set sql to vfp
// end of config.db
// Create a 'free' table, with no database open
create table free1 (field1 char(10), field2 date)
// Open the database
open database newdb
add table free1
Converting an existing application
The AUTOCATALOG commands can be used to automatically create a database catalog based on an existing application. The SET AUTOCATALOG TO >database< command will create the database if it does not already exist.// Database must be closed during autocatalog process
close databases
// Specify the database
set autocatalog to myappdb
// Start the autocatalog process
set autocatalog on
do myapp
// The autocatalog process can be toggled off to exclude
// certain parts of the application if required
// set autocatalog off
Exporting a database
The BACKUP DATABASE and RESTORE DATABASE commands have been added to simplify the process of moving applications between binary incompatible platforms. Binary files such as tables, memo files and data dictionaries must be exported to ASCII format to allow them to be transferred from one platform to another where the platforms have different binary ordering. For example, this is the case when moving files between a SUN Sparc Solaris machine and an Intel Linux machine. The BACKUP DATABASE and RESTORE DATABASE commands are extensions of the BUILD and INSTALL commands: where BUILD and INSTALL operate on a specified list of tables, BACKUP DATABASE and RESTORE DATABASE automatically handle an entire database.// Open the databaseThe BACKUP DATABASE command goes through the database catalog, exporting each file into an ASCII format that can be handled by the RESTORE DATABASE command. The files are created in a directory with the same name as the database. This directory is a sub-directory of the directory specified in the environment variable DB_BACKUPDIR and is created automatically. By default, DB_BACKUPDIR is the 'backup' sub-directory of the Recital home directory.
open database southwind
// Export the database to ASCII format
backup database
// Query the DB_BACKUPDIR environment variable settingLike DB_DATADIR, DB_BACKUPDIR is set in the system-wide configuration file and is read at startup to determine the home directory for database backups. Updates to DB_BACKUPDIR once a Recital process is running do not change this setting.
> ? getenv([DB_BACKUPDIR])
/usr/recital/backup
# profile.db/uas extractOnce the BACKUP DATABASE command has completed, the files can be transferred to another platform, for example from Intel SCO OpenServer to IBM AIX and the RESTORE DATABASE command used to recreate the database.
#---------------------------------------------------
# location of directories and important files
#---------------------------------------------------
DB_BACKUPDIR="${ROI_ROOT}backup/" ;export DB_BACKUPDIR
// Export the database to ASCII format
// Note: the BACKUP DATABASE command operates
// on the active or specified database
$ db
> backup database southwind
> quit
// 'tar' up the files for transfer
$ cd /usr/recital/backup
$ tar cvf southwind.tar ./southwind
// Transfer the tar archive to DB_BAKUPDIR on the
// target machine, then extract the files
$ pwd
/usr/recital/backup
$ tar xvf southwind.tar
// Rebuild the database on the target platform
// The database is automatically created
// as a sub-directory of DB_DATADIR
$ db
> restore database southwind
If you have 4 GB or more RAM use the Linux kernel compiled for PAE capable machines. Your machine may not show up total 4GB ram. All you have to do is install PAE kernel package.
This package includes a version of the Linux kernel with support for up to 64GB of high memory. It requires a CPU with Physical Address Extensions (PAE).
The non-PAE kernel can only address up to 4GB of memory. Install the kernel-PAE package if your machine has more than 4GB of memory (>=4GB).
# yum install kernel-PAE
If you want to know how much memory centos is using type this in a terminal:
# cat /proc/meminfo
This is a good primer for getting familiar with using Infiniband with Redhat/Centos Linux.
http://people.redhat.com/dledford/infiniband_get_started.html
Getting Started with InfiniBand
The first step to using a new infiniband based network is to get the right packages installed. These are the infiniband related packages we ship and what they are there for (Note, the Fedora packages have not all been built or pushed to the repos yet, so their mention here is as a "Coming soon" variety, not an already done variety):
This article discusses the features in Recital that allow data to be imported and exported between platforms in Microsoft® ADO XML Format.
Overview
Extensible Markup Language, XML, is widely regarded as a lingua franca for the interchange of data. XML's text-based, platform-independent format and its integration of data and the schema to define and describe that data, make it the ideal import/export medium. Recital software provides the functionality to output the data from Recital - and other supported table formats such as FoxPro and FoxBASE - into XML file format and to import XML data into those tables' formats. Such import/export operations provide the means to exchange data with third-party applications and can also facilitate the transfer of data between Recital installations on binary-incompatible platforms.
The features examined in this article are available in Recital Terminal Developer and in the Recital Mirage and Recital Database Servers on all Recital supported platforms. Both the Recital/4GL and Recital/SQL provide XML import and export capabilities. The XML files discussed are in Microsoft® ADO XML format.
Microsoft® ActiveX® Data Objects XML Format
The ADO XML format is primarily designed for ADO Recordset persistence and ADO XML files created by Recital can be used in this way and loaded directly into ADO Recordsets. The format can, though also be used for more generic data transfer. An ADO XML file is self-contained, consisting of two sections: a schema section followed by a data section. The schema conforms to the W3C XML-Data specification and defines the data structure.
For additional information on the Microsoft® ActiveX® Data Objects XML Format, please see Appendix 1.
NOTE: The Recital XMLFORMAT setting should always be in its default setting of ADO for ADO XML Format operations.
set xmlformat to ADO
SQL
Recital/SQL offers the ability to export data into XML files using the SELECT and FETCH statements and import from XML using the CREATE TABLE and INSERT statements.
SQL: Exporting
The SELECT...SAVE AS XML statement allows the complete result set from a SELECT statement to be saved as an XML file. This could be a complete table:
open database southwind SELECT * from orders SAVE AS XML orders.xml
or a more complex multi-table query:
open database southwind SELECT orders.orderid, orders.customerid,; employees.employeeid, employees.lastname, employees.firstname,; orders.orderdate, orders.freight, orders.requireddate,; orders.shippeddate, orders.shipvia, orders.shipname,; orders.shipaddress, orders.shipcity,; orders.shipregion, orders.shippostalcode, orders.shipcountry,; customers.companyname, customers.address, customers.city,; customers.region, customers.postalcode, customers.country; FROM orders INNER JOIN customers; ON customers.customerid = orders.customerid,; orders INNER JOIN employees; ON orders.employeeid = employees.employeeid; SAVE AS XML orderinfo
The resulting XML file can then be further processed within the same or a different Recital environment or transferred to a third party product.
<x-ml xmlns:z="#RowsetSchema" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3- 00AA00C14882"> <s:schema id="RowsetSchema"> <s:elementtype rs:updatable="true" content="eltOnly" name="row"> <s:attributetype rs:basecolumn="orderid" rs:basetable="orders.dbf" rs:write="true" rs:nullable="true" rs:number="1" name="orderid"> <s:datatype rs:fixedlength="true" rs:precision="14" rs:scale="0" dt:maxlength="10" rs:dbtype="numeric" dt:type="number"> </s:datatype></s:attributetype> <s:attributetype rs:basecolumn="customerid" rs:basetable="orders.dbf" rs:write="true" rs:nullable="true" rs:number="2" name="customerid"> <s:datatype rs:fixedlength="true" dt:maxlength="5" rs:dbtype="str" dt:type="string"> </s:datatype></s:attributetype> <s:attributetype rs:basecolumn="employeeid" rs:basetable="orders.dbf" rs:write="true" rs:nullable="false" rs:number="3" name="employeeid"> <s:datatype rs:fixedlength="true" rs:precision="20" rs:scale="0" dt:maxlength="10" rs:dbtype="numeric" dt:type="number"> </s:datatype></s:attributetype> <s:attributetype rs:basecolumn="lastname" rs:basetable="orders.dbf" rs:write="true" rs:nullable="false" rs:number="4" name="lastname"> <s:datatype rs:fixedlength="true" dt:maxlength="20" rs:dbtype="str" dt:type="string"> </s:datatype></s:attributetype> <s:attributetype rs:basecolumn="firstname" rs:basetable="orders.dbf" rs:write="true" rs:nullable="false" rs:number="5" name="firstname"> <s:datatype rs:fixedlength="true" dt:maxlength="10" rs:dbtype="str" dt:type="string"> </s:datatype></s:attributetype> <s:attributetype rs:basecolumn="orderdate" rs:basetable="orders.dbf" rs:write="true" rs:nullable="true" rs:number="6" name="orderdate"> <s:datatype rs:fixedlength="true" dt:maxlength="10" rs:dbtype="Date" dt:type="Date"> </s:datatype></s:attributetype> <s:attributetype name="freight" ...
Click image to display full size
Fig 1: Microsoft® Office Excel 2003: orderinfo.xml.
For data accessed through a Recital Database Gateway, such as Oracle, MySQL or PostgreSQL, the FETCH command can be used to save a cursor results set into an XML file:
// Connect to MySQL Database 'mydata' via Recital Database Gateway nStatHand=SQLSTRINGCONNECT("mys@mysql1:user1/pass1-mydata",.T.) if nStatHand < 1 dialog box [Could not connect] else DECLARE cursor1 CURSOR FOR; SELECT account_no, last_name, first_name FROM example OPEN cursor1 FETCH cursor1 INTO XML exa1.xml SQLDISCONNECT(nStatHand) endif
SQL: Importing
The CREATE TABLE statement allows a new table to be created based on the structure defined in an XML file. The data from the XML file can optionally be loaded into this new table if the LOAD keyword is included. For example, a new 'orderinfo' table can be created and populated with data from the orderinfo.xml file created by the SELECT...SAVE AS XML statement shown earlier:
open database southwind SELECT orders.orderid, orders.customerid,; employees.employeeid, employees.lastname, employees.firstname,; orders.orderdate, orders.freight, orders.requireddate,; orders.shippeddate, orders.shipvia, orders.shipname,; orders.shipaddress, orders.shipcity,; orders.shipregion, orders.shippostalcode, orders.shipcountry,; customers.companyname, customers.address, customers.city,; customers.region, customers.postalcode, customers.country; FROM orders INNER JOIN customers; ON customers.customerid = orders.customerid,; orders INNER JOIN employees; ON orders.employeeid = employees.employeeid; SAVE AS XML orderinfo CREATE TABLE orderinfo FROM XML orderinfo LOAD
The INSERT statement can be used to load data when the table structure already exists. Taking our earlier orderinfo.xml file again, the data can be loaded using INSERT:
open database southwind; SELECT orders.orderid, orders.customerid,; employees.employeeid, employees.lastname, employees.firstname,; orders.orderdate, orders.freight, orders.requireddate,; orders.shippeddate, orders.shipvia, orders.shipname,; orders.shipaddress, orders.shipcity,;; orders.shipregion, orders.shippostalcode, orders.shipcountry,; customers.companyname, customers.address, customers.city,; customers.region, customers.postalcode, customers.country; FROM orders INNER JOIN customers; ON customers.customerid = orders.customerid,; orders INNER JOIN employees; ON orders.employeeid = employees.employeeid; SAVE AS XML orderinfo CREATE TABLE orderinfo FROM XML orderinfo INSERT INTO orderinfo FROM XML orderinfo
The examples above show the export and import in a single piece of code. To transfer data between binary-incompatible platforms, the export phase using SELECT...SAVE AS XML would be carried out on the source platform, the resulting XML file would be transferred to the target platform, then the import phase using CREATE TABLE...LOAD or CREATE TABLE + INSERT would be run on the target platform.
Recital/4GL
The Recital/4GL offers the ability to export data into XML files using the COPY TO ... TYPE XML command and import from XML using the XMLFIRST() and XMLNEXT() functions.
Recital/4GL: Exporting
The COPY TO command can be used to export data from Recital and other natively supported tables out to a wide range of formats. This includes exporting to an XML file. The '.xml' file extension is added automatically. The COPY TO command can be used to export an entire table:
open database southwind use orders copy to orders type xml
or, using the FIELDS clause and the FOR or WHILE clauses, restrict the field list and export only those records which match a particular condition:
open database southwind use orders copy to orders type xml fields orderid for year(orderdate) = 1996
Only the orderid field from those records which match the condition is exported:
<x-ml xmlns:z="#RowsetSchema" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3- 00AA00C14882"> <s:schema id="RowsetSchema"> <s:elementtype rs:updatable="true" content="eltOnly" name="row"> <s:attributetype rs:basecolumn="ORDERID" rs:basetable="ORDERS" rs:write="true" rs:nullable="true" rs:number="1" name="ORDERID"> <s:datatype rs:fixedlength="true" rs:precision="10" rs:scale="0" dt:maxlength="10" rs:dbtype="numeric" dt:type="number"> </s:datatype></s:attributetype> </s:elementtype> </s:schema> <rs:data> <z:row orderid="10248"> <z:row orderid="10249"> <z:row orderid="10250"> <z:row ...
Recital/4GL: Importing
Data from an XML file can be extracted one record at a time using the XMLFIRST() and XMLNEXT() functions. XMLFIRST() reads the first record from an XML file and loads information from the file into a series of memory variables and arrays. The record data is loaded into a one-dimensional array which is created automatically. Each element in the array contains the data for its corresponding field in string format. The field names are loaded into another automatically-created array. The XMLNEXT() function works in a similar way to deal with all the subsequent records in the XML file. The XMLCOUNT() function can be used, as in the example below, to determine how many data records the XML file has.
The Recital/4GL includes a vast range of functions for manipulation and conversion of arrays and their individual elements. In the example program below, the XMLFIRST() and XMLNEXT() functions are used to sequentially extract each record from an XML file, whose name is passed to the program as a parameter. Once loaded into an array, the data is converted to the correct Recital data type then appended into a table. The table name is also passed as a parameter.
procedure replaceit append blank for i = 1 to numfields if type(field(i)) = "N" replace &(field(i)) with val(data[&i]) elseif type(field(i)) = "D" replace &(field(i)) with stod(data[&i]) elseif type(field(i)) = "T" replace &(field(i)) with ctot(data[&i]) elseif type(field(i)) = "L" replace &(field(i)) with iif(data[&i]="T",.T.,.F.) elseif type(field(i)) = "Y" replace &(field(i)) with val(data[&i]) else replace &(field(i)) with data[&i] endif next return procedure starthere parameters cTable, cFile numfields=xmlfirst(cFile,targ,trans,where,fldnames,data) if numfields < 1 dialog box [No records in XML file] else use &cTable replaceit() endif numrecs = xmlcount(cFile) if numrecs > 1 numleft = numrecs -1 for i = 1 to numleft xmlnext(trans,where,fldnames,data) replaceit() next endif return
Alternative Import/Export Methods
Other features exist in Recital to facilitate the import and export of data:
RDDs
The RDDs, Replaceable Database Drivers, are available on Windows, Linux and all supported 32-bit UNIX platforms. They allow for the use and creation of database tables and indexes in FoxPro, dBase and Clipper formats. The file format is the same across all the platforms that support the RDDs, allowing the tables and indexes to be transferred as required. The formats are also supported by a wide range of third-party products as well as their originating database systems. For more information on the RDDs, please see the online documentation on Xbase migration and the SET FILETYPE command.
BUILD/INSTALL
These are Recital/4GL commands for the export (BUILD) and import (INSTALL) of Recital tables and their associated memo, dictionary and multiple index files in ASCII format to allow them to be transferred across binary incompatible platforms. For more information, please see the online documentation on Recital/4GL commands.
COPY Commands
The COPY TO, COPY STRUCTURE, COPY STRUCTURE EXTENDED and CREATE FROM commands can all be used to enable data to be transferred between different formats and different platforms. For more information, please see the online documentation on Recital/4GL commands.
Appendix 1: Microsoft® ActiveX® Data Objects XML Format
For detailed information on the Microsoft® ActiveX® Data Objects XML Format, please consult the following Microsoft documentation:
Link |