The Symphony.dB namespace provide powerful relational database capabilities to your existing business applications. Using the Symphony.dB namespace you can easily migrate your existing ISAM file based data access routines to powerful relational database management capabilities. The Symphony.dB namespace also provides you with powerful data-replication capabilities.
Symphony.dB supports PostgreSQL, Microsoft SQL Server, MySQL and Oracle databases. Symphony.dB is also royalty free.
To easily replace your ISAM file based access with Symphny.dB to manage your data in one of the supported relational databases you can use the following as a guide. RCP Consultants can assist with your migration from ISAM to relational database data management.
The Symphony.dB environment uses code-generated structure specific database management routines to map the data from your application "record" area to column based structured data. Once these have been created you can utilise them to enable your application to manage the data in your chosen database.
The first step is to create an instance of the Symphony.dB DBAccess class.
database = new DBAccess("example", "DBMANAGER:DatabaseManager")
To open the "data table" as you would an ISAM file, use the OpenUpdate() or OpenInput() methods;
error_flag = database.OpenUpdate(channel)
for update mode, or;
error_flag = database.OpenInput(channel)
For input mode. Once the "table" has been opened then you can manage the data within the table. To read the data you can perform various functions, for example;
error_flag = database.Find(keyValue, D_PRIMARY)
error_flag = database.ReadFirst(keyOfRef, dataArea)
error_flag = database.Read(keyValue, keyOfRef, dataArea)
You can store and update data in the table;
error_flag = database.Store(dataArea)
error_flag = database.Write(dataArea)
And to delete data from the table;
error_flag = database.Delete()
The same rules apply as when processing data in an ISAM file - you must, for example, read a record from the table before you can update (Write()) or delete (Delete()) it. The same "No-Current-Record" errors will be returned if not.
In addition to the standard ISAM style operations you can also query the database using Select style operations. To perform a "select" query you could use the following example;
itemDatabase = new dbAccess("item", "DBMANAGER:DatabaseManager")
itemWhereClause = new WheredB()
itemWhereClause.Add("code", WheredBConditions.StartsWith, %atrim(code_filters.code_filter))
itemOrderBy = new OrderBydB("code")
foreach itemAsString in itemDatabase.Select("code, description, status, def_source_type", itemWhereClause, itemOrderBy)
begin
item_list = itemAsString
end
If your application uses generic file handling routines to access your flat ISAM data files the Symphony.dB framework provides a number of methods that can be used to easily migrate that code to accessing data in a relational database. You can also migrate files one at a time without the need to convert the entire application database.
For example you can modify your generic "file open" routine to check for a specific fie and manage the data in the database for the file;
if (%instr(1, internalFileName, "USERID.ISM"))
begin
;;we are using PostgreSQL so let's open the table on the the file!
error = Symphony.dB.DBAccess.GenericFileOpen(chan, file, mode)
xreturn
end
Now your "channel" references a database table and not a flat ISAM file you can perform the required operations on the data. The generic routine used to read data, for example, could be changed as such;
;;Check if we are accessing data from a database
if (Symphony.dB.DBAccess.GenericDBCheck(channel))
begin
keyNumber = 0
if (^passed(key_no)) then
;;use the passed key number
keyNumber = key_no
else
;;find the key number given the key value
keyNumber = Symphony.dB.DBAccess.GenericFileKeyCheck(channel, ^argtype(key), ^size(key))
;;read the "row" from the database
err = Symphony.dB.DBAccess.GenericFileRead(channel, key, keyNumber, record)
xreturn
end
To store data, use;
;;Check if we are accessing data from a database
if (Symphony.dB.DBAccess.GenericDBCheck(channel))
begin
;;store the record data to the database table.
error = Symphony.dB.DBAccess.GenericFileStore(channel, record)
xreturn
end
To update data use;
;;Check if we are accessing data from a database
if (Symphony.dB.DBAccess.GenericDBCheck(channel))
begin
if(%passed(err))clear err
error_no = Symphony.dB.DBAccess.GenericFileWrite(channel, record)
if(%passed(err)) err = error_no
xreturn
end
and to delete data from the database table use;
;;check to see if this "Channel" is a database channel and not an ISAM channel
if (Symphony.dB.DBAccess.GenericDBCheck(channel))
begin
err = Symphony.dB.DBAccess.GenericFileDelete(channel)
xreturn
end
The application code which uses your generic file processing routines does not need to change and continues to process the data in the same way.