(#207) Running Queries with DBISQL

The following instructions are specifically for SOS Release 2010 and later.

  1. First, it is necessary to configure your user ID in the Admin Module (Users and Passwords) to allow access from 3rd party products (Access tab option “Grant read-only access from non-SOS products”). If you are not cleared for this type of access, you will have to ask a user with full access to run the query for you. You cannot run queries with the “SUPER” ID; it must be another ID that has the “Grant read-only access” option enabled.
  2. Launch the ISQL utility by doing Start > Programs > SOS Applications > DBISQL. (An alternate, somewhat less user-friendly version can be launched by Start > Programs > SOS Applications > DBISQLC.)
  3. When prompted, type your SOS ID and password (you may find that your password will work only if typed all UPPERCASE) in the appropriate fields on the LOGIN tab, then next to ODBC Data Source select or type “SOSDATA” and click OK.
  4. A screen with multiple windows will open. Type your query in the Command (DBISQLC) or SQL Statements (DBISQL) window and click the Execute button (or press <F9> in either version).

Using the DBISQL version, use Data > Export to save your results in a file. In either version you can add a line to query to do the same. Add a semicolon, then an OUTPUT statement to the query. The following simple query creates a list of patients along with their email addresses and saves it in a “web page” file in the SOS folder called “pt-emails.html”. This HTML file can be viewed in your web browser, or opened, manipulated, and printed using Microsoft Excel:

SELECT lastname, firstname, email
FROM rv_patients
ORDER BY lastname, firstname
; OUTPUT TO c:sospt-emails.html FORMAT HTML

You are not limited to HTML output, by the way. In the example above, the results are output in spreadsheet format because of the keyword LOTUS after FORMAT. By changing the keyword, you can choose from an assortment of output file formats. Among the formats available for your query results are the following:

Format Suggested filename extension (type)

Keyword

Comments

Plain text

TXT

TEXT

The output is a TEXT format file with one row per line in the file. All values are separated by commas, and strings are enclosed in apostrophes (single quotes).
The delimiter and quote strings can be changed using the DELIMITED BY and QUOTE clauses. If ALL is specified in the QUOTE clause, all values (not just strings) are quoted.
TEXT is the default output type. This output format used to be called ASCII in previous versions of DBISQL.

Fixed width columns

TXT

FIXED

The output is fixed format with each column having a fixed width. The width for each
column can be specified using the COLUMN WIDTHS clause. No column headings are output in this format.

Web page

HTM or HTML

HTML

Open with your web browser. Also can be loaded in Excel and some other spreadsheet applications.

XML web browser format

XML

XML

Some programs and systems can import and/or process data in XML format.

You can save this query with a name by clicking File > Save and run it whenever you want by opening DBISQLC or DBISQL and clicking File > Open to recall it. By convention, queries like this are given names ending in SQL, like EMAILS.SQL, for example. I would suggest that you save it in your SOS folder so you don’t lose it. If you really want to get fancy, you can create a shortcut on your desktop to run your query with one double click (plus typing in your ID, etc. when prompted):

C:SOSSAbin32DBISQLC
C:SOSEMAILS.SQL
, or “C:SOSSAbin32DBISQL
C:SOSEMAILS.SQL

Documents you may find helpful include the rather dated, but still relevant, annotated data dictionary: http://www.sosoft.com/files/downloads/sosddct.pdf

and a set of entity diagrams showing links among tables for the most commonly used data: http://www.sosoft.com/files/downloads/sosdpics.pdf

It is most important that you review the final chapter (Accessing SOS Data from Other Programs) in sostech.pdf, located in your SOS folder. This chapter explains the basics of the database organization. You will be lost in doing anything beyond the simplest queries without that foundation.

(#200) Upgrading from SOS 2009 to SOS 2010

The upgrade to SOS 2010 is quite similar to previous SOS upgrades that you may have done. It does, however, replace your older Sybase database components with newer versions. In some cases that change will require a couple of post-installation steps, which are detailed below.

All Installations, Including Network Workstations

You may find that one or two obsolete shortcuts remain in your Windows Start > Programs > SOS Applications menu.


The DBISQLG query utility has been replaced by the new DBISQL (no G at the end). The old program shortcut will no longer work and should be removed from the SOS Applications menu. Similarly, the shortcut to bring up the Sybase documentation now has a slightly different name, Sybase SA Manuals. The old Sybase ASA Manuals shortcuts will no longer work, so that shortcut should also be deleted, to avoid confusion.

To delete a menu shortcut, just right-click the shortcut and then click Delete on the pop-up menu. The two menu entries to be deleted are circled in the figure to the left.

Standalone Computer Installations

In most cases, the installation will make all necessary changes for you, except, possibly, the removal of the now obsolete menu items in the Start > SOS Applications menu.

64 Bit Windows Option

If you are running your software on a 64-bit version of Windows, you can choose to run the 64-bit version of the database engine rather than the default 32-bit version. Although either one will work fine in your environment, if you have more than three GB of RAM in your system, you may experience better performance with the 64-bit engine. Changing from one to the other is quite easy:

  1. Select Start > Programs (or All Programs) > SOS Applications > ODBC Administrator.
  2. Click the System DSN tab.
  3. Double-click SOSDATA.
  4. Click the Database tab.
  5. In the Start line, scroll to the left, so you can see the beginning of the command.
  6. Replace the number 32 with 64. The command will now start with c:\sos\sa\bin64\dbeng11.exe
  7. Click OK to save, then OK again to close the ODBC Administrator applet.

The next time you start SOS, the database will start using the 64-bit engine!

Database Servers

Edit the SERVER.PRM File

In the old version of the Sybase database engine, the recommended network packet size was 1480 bytes. With the new engine, the default and recommended size is 7300 bytes. For best performance, therefore, SOS recommends that you remove the “-p 1480” parameter from your SERVER.PRM file, or change the “1480” to “7300”. In addition, to close a potential security threat, SOS strongly recommends that you add the parameter “TDS=NO”, in parentheses, after “tcpip”. Here is an example:

server_prm

Modify all Database Startup Shortcuts

Prior to the 2010 release, the database engine was called DBSRV9.EXE and was located in \SOS\ASA\Win32. The new database engine is named DBSRV11.EXE and is located in \SOS\SA\BIN32, with the 64-bit version located in \SOS\SA\BIN64. As a result, old shortcuts will no longer work and should be deleted. There is a shortcut in Start > All
Programs > SOS Applications to start the new database server, using the 32-bit engine (Start SOSDATA Server). You should delete any left-over shortcuts and create new ones by copying the one in the Start menu:

If you are running the database on a 64-bit Windows machine with more than 2 GB of RAM, you will probably see better performance by using the 64 bit engine, so after creating the 32-bit shortcut, just edit its properties as shown below, modifying the Target location from BIN32 to BIN64:

Delete and Re-create the Database Service

You may have been running your database as a windows background service, or perhaps you want to start doing so. The main advantage to running as a service is that the database will start and run whether or not anyone is logged into the server computer’s console. Services created in versions prior to SOS 2010 appear in the Windows Service Manager in the form:

Adaptive Server Anywhere – mysos

where “mysos” is the name you gave to the service when you created it. You must first remove the existing service, if there is one, then create a new one. The new one will appear in the list of services with a name in the form:

SQL Anywhere – mysos

To delete the existing service:

  1. Open a command window, being careful to use the Run as administrator option if you are working on Windows 7. Windows 8 and newer, type CMD in the Start menu Search field, then right-click CMD.EXE in the search results and select “Run as administrator”.
  2. Even if you plan to run the 64 bit database engine, change to the \SOS\SA\BIN32 directory:
    CD \SOS\SA\BIN32 <enter>
  3. Assuming that the name of your existing service is “mysos”, delete it with this command:
    dbsvc –y –d mysos

To create the new service:

  1. If you are not already in a command window running with Administrator rights, follow steps one and two above.
  2. Now create the new service with the following command. The options in this example will set the service to run under the system account (-sa), as a network service (-t network), to start automatically (-s auto), to display the database icon in the system tray (-i), and to be named “mysos” (-w mysos). It will appear in the Windows Services Manager as “SQL Anywhere – mysos”. If you are running the database in 64-bit Windows, using the 64-bit option is recommended, but either version of the engine will work. The 64-bit engine often provides better performance, especially for larger databases. If you are running in 32-bit Windows, you MUST use the 32-bit command. These commands would be typed on a single line, of course. Note that the -i option to display the icon in the system tray won’t work on Windows 7, or Server 2008 R2 and later, so omit that option if using one of those. Service configuration commands are case sensitive. Type your options exactly as shown (eg: “automatic” will fail but “Automatic” will work). If you still have trouble getting the service created, leave out the “-s Automatic”. You can change the properties to “automatic” from the Windows Services list after it is created.
    32-bit Windows:
    dbsvc -as -t Network -s Automatic -i -w mysos c:\sos\sa\bin32\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
    64-bit Windows:

    dbsvc -as -t Network -s Automatic -i -w mysos c:\sos\sa\bin64\dbsrv11.exe @c:\sos\server.prm c:\sos\data\sosdata.db
  3. After executing the command, you will find a new Windows service listed in Windows’ Administrative Tools > Services applet: SQL Anywhere – mysos. You can adjust the properties for the service just as you would for any other service.

For more detailed discussion and instruction for running SQL Anywhere as a Windows service, see:

https://sos-resources.info/g4/running-the-sos-sql-anywhere-11-database-as-a-windows-service/

Adjust Scheduled Tasks

You may be using one or more Scheduled Tasks in Windows to control starting or stopping your database. Normally stopping the database is handled with a –tq parameter in the SERVER.PRM file, such as:

-tq 22:00

to automatically shut down the database at 10:00 pm, but if running as a service, it is possible that you are using a scheduled NET STOP command to do so. More likely, however, if you check your Windows Scheduled Tasks, you will find a task that starts your database server engine each morning, whether you run it as a foreground task, or as a Windows service.

If you have a task to execute a CMD or BAT file that launches the database, find and edit the batch file, replacing the old c:\sos\asa\win32\dbsrv9.exe with the new c:\sos\sa\bin32\dbsrv11.exe (or c:\sos\sa\bin64\dbsrv11.exe) command.

If you are restarting a service, that service no longer exists, so change the command to start the correct service. For example, you might have scheduled the command:

NET START “Adaptive Server Anywhere – mysos”

which now should be:

NET START “SQLANYs_mysos”

This name, of course, should match the name of the service you created above. Check the properties of the new service in your Control Panel > Administrative Tools > Services to be sure of the name. Once you open the Properties dialog for the service, you will see the service name at the top of the first tab:

Windows 7 –

6-15-2012 5-05-43 PM

Windows Server 2008 R2 –

6-15-2012 5-08-20 PM

Network Workstations

After installing the new version of the software on a network workstation, including a terminal server, check the ODBC settings to be sure that the Buffer Size setting on the Network tab is set to 7300 bytes to match the packet size setting on the server. While on this tab, note that specifying the IP address of your database server in the form HOST=123.123.123.123 (using your own server’s address) is sometimes necessary if the workstation cannot otherwise locate and connect to the database server. Unless you are having a problem, do not specify this parameter. Also on the Network tab is an option to Compress network packets. Using this option can make a significant performance improvement on some networks, but can slow things down on others. If your servers and workstations are relatively speedy, but your network is slow, this option should help. On the other hand, if your server and/or workstations are already working pretty hard, and you have abundant network capacity, checking this option may actually slow things down. You will have to experiment to know for sure. Test by timing the generation of large reports.

SNAGHTML178e068

Updated 2/26/2009

(#210) System Recommendations for SOS 2010 through 2016

The following recommendations should deliver adequate performance in each indicated category. If your implementation is particularly demanding, you want better than just “adequate” performance, or your database is large, you should increase both RAM and processor speed to compensate. Simultaneous usage of resource-hungry applications such as Microsoft Office also demand more RAM.

Windows 32 bit Software
(Compatible with Windows 64 bit)

At present, SOS applications are distributed as 32-bit software. They will, however, install and run in a Windows 64 environment and both 32 and 64-bit database engines are provided. The minimum version of Windows supported by SOS is Windows 11 Pro, Windows Server 2016, Windows Server 2019, and Windows Server 2022.

Windows 8.1 and Windows Server 2012 will no longer receive security updates as of January 10th, 2023 and October 10th, 2023, respectively, and therefore will not be supported. Windows 10 will no longer receive security updates as of October 14th, 2025. SOS users are strongly encouraged to upgrade operating systems to assure compatibility with the next generation of SOS products.

Standalone Computer or Network Workstation

  • A 1.6 GHz or faster (recommended) computer with at least 4 GB of RAM, running Windows 11 Pro. For satisfactory performance, SOS recommends at least 8 GB of RAM.
  • A faster, multi-core processor and more RAM is even better, especially if you will be running two or more applications at the same time, or if your SOS database will be large. The ideal is to have enough RAM to match the size of the database running on it.
  • A minimum of six GB of free hard disk space for a small practice; much more for large groups and agencies.
  • A high speed internet connection for installation. On networks, a shared drive may be used. Software is only available for download.
  • A 19″ or larger flat panel display, running 1440 x 900 resolution or higher. Multiple monitor configurations are supported and encouraged.
  • TWAIN compatible scanner to scan documents from within SOS applications. WIA compatible scanners can be used, but do not provide either multipage or duplex capabilities. Scanners used by SOS customers include: Docketport 687 card scanner, Canon N670, Xerox Documate 252, and Fujitsu FI-6130. TWAIN is the industry standard scanner interface, so most scanner manufacturers, including Microtek, Umax, VistaScan, HP, Fujitsu have TWAIN models. Note, however, that certain scanner models, even from these manufacturers, do not support the TWAIN standard. For example, HP’s Officejet multi-function printers support WIA, but not TWAIN. Likewise, the popular Fujitsu ScanSnap 500 series uses a proprietary interface and software package that supports neither WIA or TWAIN. If purchasing a new scanner, confirm that TWAIN drivers are included or are available for the desired model and the version of Windows that you are using. Scanners that are not compatible with SOS’s scanner interface can, of course, be used to capture documents as computer files, and those files can be incorporated as attachments to patient records in SOS. Although not quite as convenient, it is still a workable solution.
  • Tape backup or a similar robust removable backup system such as external drive or USB that permits easy media rotation and off-site storage of archival backups. Supplemental internet-based backups are strongly encouraged for redundancy and disaster-recovery purposes, but be sure that the backup vendor conforms to HIPAA requirements, including execution of a Business Associate Agreement. Your backups, whether local or online, must be encrypted.

Network Server

A note concerning the next generation of SOS software: The SOS software currently in development, G5,  will be run on web and database servers located on a local network, in a data center, or on a cloud service like Amazon Web Services and Microsoft Azure. If you host the software on your own server or servers, you may need more server resources than with SOS’s current client/server deployment model. If purchasing new hardware these considerations should be factored into your equipment selection. Please see: System Requirements for SOS G5 Products

  • A 3.5 GHz or faster server running 64 bit, Windows Server 2016 or newer are recommended. It is also possible to use Windows 11 Pro as your database server. For best performance and data security, SOS recommends that the designated server computer not be used simultaneously as a workstation and as a server. Performance, database security, and integrity may be compromised when the server doubles as a workstation.
  • Many SOS customers use virtual server environments such as VMWare and Microsoft Hyper-V, but SOS cannot provide anything beyond the most basic assistance for these environments. If you install on a virtual server and unusual issues should arise, SOS may require that the installation be moved to a traditional non-virtual platform before providing additional assistance. That said, we intend to have a deployment option for our next generation software in the form of a per-configured, ready-to-run, virtual server package for Microsoft’s Hyper-V and, possibly, for VMWare.
  • Servers should have no less than 8 GB of RAM. In general, additional memory is more important than a faster processor, but processor speed and multiple cores/CPU’s are also important, particularly on larger networks. The amount of RAM recommended is directly proportional to the expected size of your database. Large transaction volume organizations should think in terms of a 64-bit platform with at least 16 GB of RAM and the ability to easily add more. The included database engine will use multiple processors or processor cores to improve performance, if present.
  • Hard drive space proportional to the size of the organization. Assuming that an average patient account includes about 20 journal entries (charges and credits), you should estimate at least 35K – 70K per patient, or 35 MB – 70 MB per 1,000 patient accounts, plus up to 1 GB for the program files. SOS would recommend that you double this figure to allow ample space for temporary tables, transaction logs, and other needs. Use of both SOS OM (receivables and billing) and CM (clinical records) will increase the amount of drive space required. Large groups and agencies can expect databases of several GB’s and up.
  • Performance and data safety can be enhanced on an active system through the use of multiple hard drives or SSD’s, with the transaction log stored on a second drive in the same server and perhaps the index files on a third drive. Moving the transaction log to a different drive is straightforward but relocating the index files requires unloading and reloading the database with a custom reload script. If you would like to implement a more complex installation of this sort, call SOS to discuss whether such a modification would be worthwhile. By default, all data and transaction log files will be installed in a DATA directory located within the SOS program directory on the designated server.
  • One or more high performance hard disks. Ideally, the database files should be located on a separate, dedicated partition on a drive other than the primary system drive.
  • If setting up a dedicated database server that will not also be used for file or printer sharing, you may use Windows 11 Pro to host the database. That is also a possibility if setting up a small “peer” network with 20 or fewer users. It is neither required nor recommended (for security reasons) to configure a network share for the database. All communication between the workstations and the database is done through TCP/IP messaging, without any need for users to log into the database server computer. As a result, the Windows 11 Pro limit of twenty concurrently connected users does not apply for SOS database access. Be sure to disable power saving options that will cause the system to go into sleep mode!
  • A high speed internet connection.
  • Tape backup or a similar robust removable backup system such as external drive or USB that permits easy media rotation and off-site storage of archival backups. Supplemental internet-based backups are strongly encouraged for redundancy and disaster-recovery purposes.
  • SOS products include SAP/Sybase SQL Anywhere as the back-end database engine. The next generation SOS product will permit the database to be run on your existing SQL Server back-end, if preferred.

Updated 11/12/2024

Backup and Recovery: Advanced Topics

The information in the Backing Up Your Data article is quite sufficient for most installations. The current document discusses advanced topics that will be of particular interest to those running the system in larger organizations with high data entry volume. The following topics include how to recover data entered since the most recent backup and how to backup up a running database. Much of this material is reprinted from the Backup and Data Recovery chapter of the SA Usage manual, with permission from Sybase, Inc. You can read this information directly in the online SA help, accessed from your Start > Programs > SOS Applications menu.

The material below explains how to use SA transaction log files to protect your data, how to make backup copies of your database and log files while the database is running, and how to recover after system and media failures.

Backing Up a Database While It Is Running

In some installations, it is desirable to keep the database running 24 hours a day. You cannot backup the running database using commercial backup software, so a special procedure must be used.

You can either:

1. Depend on Microsoft Volume Shadow Copy Services (VSS) to snapshot the database when using third party backup software after configuring your system to run the dbvss11 utility as a Windows service, or

2. (preferred) Use the included live backup utility to make a copy of the database in a separate directory, and backup that copy rather than the running production files in your backup set.

There is a downside to running the database non-stop. There are several maintenance/clean-up procedures that run automatically when the database is started. If you never restart the database, it is possible that you might run into minor issues, such as the inability to log into the system with a particular user ID after that user disconnected from the database in an unusual fashion. See Database Tools in the Admin Module to do the cleanup manually.

The recommended the following live backup procedure:

Create a CMD batch file containing the following commands:

(SOS 2015 and earlier)

C:\SOS\DBTOOLS /V
C:\SOS\DBTOOLS B=<target directory> -y

(SOS 2016 - Requires that you create a backup-only user account in SOS! See the SOSADMIN.PDF document in the \SOS folder of your system.)
c:
cd \sos\sa\bin32
DBBACKUP -c “uid=<account ID>;pwd=<account password>;dsn=SOSDATA” <target directory>

where <target directory> is an existing directory in which you want the copy of the database to be created. This directory must be located on the computer running the database. It should NOT be a shared folder on another computer! Make sure that this target directory is included in your backup configuration so that the database copy is backed up, and set the backup to skip the \SOS\DATA directory in which the running database files are located. Most backup software will fail to make usable backups of a running database!

Here is an example command line, including an optional -y parameter to create 
the directory if it doesn't exist, and to overwrite existing files:
DBBACKUP -y -c "uid=BU_BILL;pwd=PASSword#1;dsn=SOSDATA" C:\SOSBU

You can run a database validation or database copy interactively from the menus in the “DBA Utils” program in the Admin Module. Once the program has started, go to the Tools menu. Run the validation by selecting “Check Database”. You can run an ad-hoc live database copy by choosing “Copy Database” in the Tools menu. Generally, live backups are done as a Windows scheduled task that executes one or more times each day.

Note that for security reasons copying the database is only possible on the computer running the database software.

It is absolutely essential that you monitor your backups closely to be sure that the current database files are being copied to your backup media. If you are using commercial backup software, be sure to turn on the “verify” or “compare” operation and inspect your backup logs every day!

If you plan to backup the running database with Backup Exec, NovaBackup, or some other backup software that uses Microsoft Volume Shadow Copy Services (VSS) to backup open files, then create and run a Windows service for the SA VSS Writer component, DBVSS11.EXE, as follows:

  1. Open a command window.
  2. On 32-bit Windows type:
    CD \SOS\SA\BIN32 <enter>On 64-bit Windows type:
    CD \SOS\SA\BIN64 <enter>
  3. On 32-bit Windows type
    dbsvc -as -s Automatic -t vss -w VSSWriter “c:\SOS\SA\BIN32\dbvss11.exe” <enter>On 64-bit Windows type:
    dbsvc -as -s Automatic -t vss -w VSSWriter “c:\SOS\SA\BIN64\dbvss11.exe” <enter>

Once you have created the service, you should see it listed in your Windows Services as
“SQL Anywhere – VSSWriter”

It is absolutely essential that you test your backup during a period when the database is actively in use by restoring your backup, restarting your system, and validating the restored database as described in “Validating the Database”, above.

Live Backup and Database/Log Mirroring

SQL Anywhere also has the capability of running a continuous live backup of the transaction log on a separate computer, and even doing a failover database server running on a second computer. For discussion of these topics please see the appropriate topics in SQL Anywhere Database Administration manual located on your system. Go to Start > Programs > SOS Applications > Sybase SA Manuals. Open the Database Administration manual, then find “Backup and Data Recovery” in the “Maintaining Your Database” section.

System and Media Failures

SA has features to protect your data from two categories of computer failure: system failure and media failure.

System Failure: A system failure occurs when a power failure or some other failure causes the computer or operating system to go down while there are partially completed transactions. This could occur when the computer is inappropriately turned off or rebooted, or when another application causes the operating system to crash.

Media Failure: A media failure occurs when the database file, the file system, or the device storing the database file becomes unusable.

Recovery from Failure

When failures occur, the SA recovery mechanism treats transactions properly, as atomic units of work: any incomplete transaction is rolled back and any committed transaction is preserved. This ensures that even in the event of failure, the data in your database remains in a consistent state.

Make Regular Backups

You should make regular backups of your database files so that you can recover your database in the case of a media failure. SA uses the transaction log (which you should store on a separate device from the database for maximum data safety, or continuously backup using the transaction log mirroring feature of SA) to recover information put into the database since the last full backup. For information on management of the transaction log file, please see:

http://www.sosoft.com/fod/doc126-tranlog.pdf

The SA Logs

SA uses three logs to protect your data from system and media failure. These log files exist for each database running on a database engine or server.

All these logs play a role in data recovery. Each log exists for each database running on a database engine or server. Optionally, you can maintain a mirror of the transaction log for greater protection of vital data.

The Checkpoint Log

An SA database file is composed of pages. Before a page is updated (made dirty), a copy of the original is always made. The copied pages are the checkpoint log.

Dirty pages are not written immediately to the disk. For improved performance, they are cached in memory and written to disk when the cache is full or the server has no pending requests. A checkpoint is a point at which all dirty pages are written to disk. Once all dirty pages are written to disk, the checkpoint log is deleted.

Reasons for a Checkpoint

A checkpoint can occur for several reasons:

· The database engine is shut down

· The amount of time since the last checkpoint exceeds the database option CHECKPOINT_TIME

· The estimated time to do a recovery operation exceeds the database option RECOVERY_TIME

· The database engine is idle long enough to write all dirty pages

· A transaction issues a CHECKPOINT statement

· The database engine is running without a transaction log and a transaction is committed

The priority of writing dirty pages to the disk increases as the time and the amount of work since the last checkpoint grows. This is important when the database engine does not have enough idle time to write dirty pages. The database option CHECKPOINT_TIME controls the maximum desired time between checkpoints. The database option RECOVERY_TIME controls the maximum desired time for recovery in the event of system failure. Both times are specified in minutes.

When the database server is running with multiple databases, the CHECKPOINT_TIME and RECOVERY_TIME specified by the first database started is used, unless overridden by command line switches.

For a description of the command-line options, see “The database engine” in the on-line SA manual.

The Rollback Log

As changes are made to the contents of tables, a rollback log is kept for the purpose of canceling changes. It is used to process the ROLLBACK statement for recovering from system failure. There is a separate rollback log for each transaction. When a transaction is complete, its rollback log is deleted. (Note that the term transaction in this context refers to a related set of database operations, not a transaction in the sense of a single charge or credit entry in OM.)

The Transaction Log

For a condensed and SOS-specific discussion of transaction log management, see http://www.sosoft.com/fod/doc126-tranlog.pdf on the SOS web site.

All changes to the database are stored in the transaction log in the order in which they occur. If you should suffer a data loss, you could restore your most recent backup, then use the transaction log to restore all your changes since the last backup was done. In most cases, therefore, you can restore everything up to the time of your failure or loss, not just up to the time of your backup! The only price you pay for this additional security is the disk space taken by the transaction log. In the sections below you will learn how to move the log to another disk and how to clear it from time to time (after you have made and verified a full backup).

Although use of the transaction log is optional, by default it is enabled. If you run SA with no transaction log, a checkpoint is carried out whenever a transaction is committed. The checkpoint ensures that all committed transactions are written to the disk. Checkpoints can be time consuming, so you should run with a transaction log for improved performance as well as protection against media failure and corrupted databases.

For greater protection, SA allows you to maintain two identical transaction logs in tandem. This is called transaction log mirroring.

The transaction log is not kept in the main database file. The filename of the transaction log is set when the database is installed. For additional security against media failure, the transaction log may be written to a different device than the database file. Some machines with two or more hard drive letters only have one physical disk drive with several logical drives or partitions. If you want protection against media failure, make sure that you have a machine with two separate disk drives or use a storage device on another computer on the network. Note that by default, the transaction log is put on the same device and in the same directory as the database (\SOS\DATA). This default installation, although convenient, does not protect against media failure.

Placing the transaction log on a separate device can also result in improved performance by eliminating the need for disk head movement between the transaction log and the main database file.

Moving the Transaction Log

Use the SA DBLOG utility, located in the \SOS\SA\BIN32 folder, to move the transaction log to a different drive by setting a new transaction log name. Simply copying the file from one drive to another will not work because the location of the log is stored in the database.

Make sure that the database is not running.

From the \SOS\SA\BIN32 prompt, type, in lower case:

dblog -t <new log name> <database name>

The new log name should include the drive, path, and filename of the new log file, for example, d:\soslog\sostran.log .

The database name should include the drive, path, and filename of the main database file, for example, c:\sos\data\sosdata.db.

Once you have reset the location in the database using this procedure, physically move or copy the current transaction log to the new location and, optionally, name you have specified. You will then be able to restart the database engine normally. Remember to include the transaction log, in its new location in your daily backup!

Using a Transaction Log Mirror

A transaction log mirror is an identical copy of the transaction log, maintained at the same time as the transaction log. Every time a database change is written to the transaction log, it is also written to the transaction log mirror file. By default, SA does not use a mirrored transaction log, but you can readily add a transaction log mirror to your system. The procedure is described in the next section.

A mirrored transaction log is useful for extra protection of critical data. There is a performance penalty for using a mirrored log, as each database log write operation must be carried out twice. The performance penalty will depend on the nature and volume of database traffic and on the physical configuration of the database and logs, but in most cases will not be apparent to users of the system.

A transaction log mirror should be kept on a separate physical drive from the transaction log, so that if either drive fails, the other copy of the log keeps the data safe for recovery. Both drives should be on the same computer, however! Maximum protection of your data, therefore, would require three drives (physical drives, not just partitions on the same drive). The database files (the *.DB files) would be on one drive, the transaction log (sosdata.log) on a second, and the mirrored log (sosdata.mlg) on a third.

Creating a Transaction Log Mirror

Use the SA DBLOG utility, located in the \SOS\SA\BIN32 folder, to create a transaction log mirror file on another hard drive.

Make sure that the database is not running.

From the \SOS\SA\BIN32 prompt, type, in lower case:

dblog -m <new mirror log name> <database name>

The new mirror log name should include the drive, path, and filename of the new mirror log file, for example, d:\soslog\sosdata.mlg (mlg is the default mirror extension)

The database name should include the drive, path, and filename of the main database file, for example, c:\sos\data\sosdata.db

Removing a Transaction Log Mirror

If you have been using a log mirror and no longer want to do so, use DBLOG to discontinue mirroring:

Make sure that the database is not running.

From the \SOS\SA\BIN32 prompt, type, in lower case:

dblog -r <database name>

The database name should include the drive, path, and filename of the main database file, for example, c:\sos\data\sosdata.db

Erasing Transaction Log and Mirror Files

You can erase transaction logs and mirrors using the DBERASE command-line utility. Note that this command physically deletes the file from the disk, but does not terminate the use of either. As soon as you restart the database, the files will be recreated.

To delete a mirror log file only:

Make sure that the database is not running.

From the \SOS\SA\BIN32 prompt, type, in lower case:

dberase <mirror file name>

The mirror file name should include the drive, path, and filename of the mirror file that you want to erase, for example, e:\sos\data\sosdata.mlg

To delete a transaction log file but not its mirror:

Make sure that the database is not running.

From the \SOS\SA\BIN32 prompt, type, in lower case:

dberase <transaction log file name>

The transaction log file name should include the drive, path, and filename of the transaction log file that you want to erase, for example, d:\sos\data\sosdata.log

Validating the Transaction Log and Mirror

When a database that is using a mirror starts up, the database engine or server carries out a series of checks and automatic recovery operations to confirm that the transaction log and its mirror are not corrupted, and to correct some problems if corruption is detected.

On startup, the database engine checks that the transaction log and its mirror are identical by carrying out a full comparison of the two files; if they are identical, the database starts as usual.

The comparison of log and mirror adds to database startup time when you are maintaining a log mirror.

If the database stopped because of a system failure, it is possible that some operations were written into the transaction log but not into the mirror. If the database engine finds that the transaction log and the mirror are identical up to the end of the shorter of the two files, then the remainder of the longer file is copied over into the shorter file to produce identical log and mirror. After this automatic recovery step, the database engine starts as usual.

If the check finds that the log and the mirror are different in the body of the shorter of the two, one of the two files is corrupt. In this case, the database does not start, and an error message is generated saying that the transaction log or its mirror is invalid. If this situation should occur, consult “Recovering from media failure on a mirrored transaction log” in the on-line SA Database Administration Guide.

Validating the Database

From time to time prior to running a full backup, it is a good idea to verify that the database file is not corrupt. A small portion of the database could be corrupt without you ever knowing until it was too late to recover the data.

With the database engine (single user) or server (network) running, execute the Check Database tool in the database utility that comes with your SOS software. Enter a Security Administrator id and password, then click the Admin icon. Once at the administration console window, select Database Tools > DBA Utilities > Tools > Check Database.

If desired, you can run the same procedure from the command line or from within a batch file, using the following command, from the prompt in the SOS directory:

DBTOOLS /V

You may want to include this command in a desktop shortcut. It is an excellent idea to run this routine before or after your daily backup to be sure that you are backing up an intact database.

The validation procedure can take a little while to complete on a large database. It scans every record in every table and looks up each record in each index on the table. It can be run while the database is in use, but you may notice some performance impact while it is running.

Any messages produced by the utility are collected in a file on disk (\SOS\SOSVALID.LOG) and displayed when the procedure is complete. If the database file is corrupt, you must restore the DB files (but not the LOG file) from your previous intact backup. You may then be able to apply the current transaction log in order to bring the database up to date (see “Lost Database Files” on page 28).

Backing up Your Database
On-line Backups

In some organizations, operations continue around the clock and it is not possible to stop the database to perform a traditional backup. Under these circumstances, you can use the provided Copy Database utility to make a copy of the database, while it is running, in a different directory. Once the copy is complete, the duplicated files can be included in your regular backup even though the open production database files will be skipped by your backup software. (To avoid errors in your backup logs, configure your backup to skip over the production database files or folder.)

Run Copy Database interactively from the menus in the DBA Utilities program, which is located in the Admin Module. The Admin icon appears on the login window for users who are designated as Security Administrators. On the Admin menu, select Database Tools, then DBA Utilities.

Once the program has started, go to the Tools menu. Select Copy Database to make a live copy of the running database into a different directory. Note that for security reasons copying the database is only possible on the computer running the database software.

The Copy Database utility can be run against a standalone engine or network database server. The utility will not run from a network workstation for security reasons. Using the Copy Database utility on a running database is equivalent to copying the database files when the database is not running. In other words, it provides a snapshot of a consistent database, even while it is being modified by other users.

For a full description of the SA online backup facility, see “Use the Backup utility (dbbackup) to make a server-side backup” in the online SA Database Administration Guide, page 882 (pdf page 900). It is important to understand, however, that you will not be able to use the utility directly against the secure SOSDATA database. Rather, you must run it from within the DBA Utilities shell program provided by SOS as described above or using the DBTools command line explained below.

You also can copy the database from the command line, batch file, or desktop shortcut by executing DBTOOLS.EXE B=<target directory> from the SOS directory (but only on a standalone system or directly on the database server computer). For example, assuming that the SOS folder is located on the C: drive:

C:\SOS\DBTOOLS.EXE B=C:\SOS\BACKUP

would create a copy of the currently running database in the C:\SOS\BACKUP folder. Note that the folder must exist before you execute the command. SOS recommends that the destination for the copy operation be a different drive on the database computer than that on which the production database is located. That way, if your primary drive should fail, the most recent copy of the database on the secondary drive will be readily available to use in the restoration process.

Open File Backups Using Volume Shadow Copy Service

[SOS 2010 and later] SOS recommends the Copy Database procedure detailed above for best reliability. In addition, there is a side benefit that it leaves a backup copy of your database and log on a local hard disk as a redundant backup to the one you make on removable media, internet-based backup service, or both.

[SOS 2010 and later] That said, many commercial backup programs include the ability to backup files that are in use through the Volume Shadow Copy Service available on versions of Windows starting with XP. For best results, you should create and enable the SA VSS Writer service by executing the following command from the command prompt in the \SOS\SA\BIN32 directory:

dbsvc -as -s Automatic -t vss -w SAVSSWriter “c:\sos\sa\bin32\dbvss11.exe”

It is absolutely essential that you test your backup during a period when the database is actively in use by restoring your backup, restarting your system, and validating the restored database as described in “Validating the Database”, above .

Incremental Backups of the Transaction Log

You can carry out an off-line incremental backup by making a copy of the transaction log. Alternatively, you can carry out an online incremental backup by running the SOS Copy Database utility, and subsequently backing up the SOSDATA.LOG file in the normal fashion to tape or other removable media.

You should back up the transaction log daily. This is particularly important if you have the transaction log on the same device as the database file. If you have a media failure, you could lose both files. By doing daily backups of the transaction log, you will never lose more than one day of changes.

Daily backups of the transaction log are also recommended when the transaction log tends to grow to an unmanageable size between full backups and you do not want to get a larger storage device or do more frequent full backups. In this case, you can choose to archive and delete the transaction log by selecting the appropriate options in the SOS Copy Database utility.

There is a drawback to deleting the transaction log after a daily backup. If you have media failure on the database file, there will be several transaction logs since the last full backup. Each of the transaction logs needs to be applied in sequence to bring the database up to date, as described below. It is therefore extremely important to save all transactions logs that cover database activity after the most recent verified backup of the database files themselves!

SOS strongly recommends that Transaction logs be archived onto CD-R or other permanent media that will not be overwritten and that these media be stored in a safe location, such as a fireproof data safe, or even better, off-site in a bank vault.

Backing Up, Renaming and Restarting the Transaction Log

Use of the following command will do a live backup of the transaction log into the target directory, but will also rename the backup with the form YYMMDD##.LOG (where ## is a sequential number starting with 00, in case you execute the command more than once on a single date) and restart the log. The result will be a copy of the current SOSDATA.LOG in the backup directory, but renamed based on the date, and a brand new, small SOSDATA.LOG file in the \SOS\DATA folder.

C:\SOS\DBTOOLS B=C:\BACKUPS -t -r -n

You can specify any existing directory on the server instead of “C:\BACKUPS”, but be sure to type the -t -r and -n in lower case.

If you prefer to work within a graphical interface, you can do this process from Database Tools > DBAUtils in the Administration module. Select Copy Database on the Tools menu, select the desired backup directory and check the -t, -r, and -n options as shown below.

Use the Copy Database utility to backup and restart your transaction log file.

To create the renamed backup copy in the current data directory, just type a period (.) for the Backup directory. The dated copy of the old log will be created in the same directory as the database files and new log file.

Data Recovery
System Failure

After a power failure or other system failure you should run the Windows’ scandisk utility to correct simple errors in the file system structure that might have been caused by the system failure. This step should be done before running any other software.

After a system error occurs, SA automatically recovers when you restart the database. The results of each transaction committed (written to the database) before the system error are intact. All changes by transactions that were not committed before the system failure are canceled, and therefore lost. In most cases that means you will only lose those changes that had not been completely saved prior to the failure.

The database engine automatically takes three steps to recover from a system failure:

1. Restore all pages to the most recent checkpoint, using the checkpoint log.

2. Apply any changes made between the checkpoint and the system failure. These changes are in the transaction log.

3. Rollback all uncommitted transactions, using the rollback logs. There is a separate rollback log for every connection.

Step 3 may take a long time if there are long uncommitted transactions that have already done a great deal of work before the last checkpoint.

Media Failure

Perhaps the most frequent cause of data loss is the failure of a hard drive or failure of drive controller electronics, leading to corruption of the data on the drive.

If you have backups, you can always recover all transactions that were committed before the media failure. Recovery from media failure requires you to keep the transaction log on a separate device from the database file. The information in the two files is redundant. Regular backups of the database file and the transaction log reduce the time required to recover from media failures.

The first step in recovering from a media failure is to clean up, reformat, or replace the device that failed.

The steps to take in recovery depend on whether the media failure is on the device holding your database file or on the device holding your transaction log. These discussions assume that your system stores the transaction log (or mirror) on a separate drive from the database files.

Lost Database Files

When your transaction log is still usable, but you have lost your database file, the recovery process depends on whether you keep or delete the transaction log on incremental backup.

If you have not deleted or restarted the transaction log since the last full backup, the transaction log contains everything since the last backup. Recovery involves four steps:

1. If you do not already have one, make a backup of the current transaction log immediately. The database file is gone and the only record of the changes is in the transaction log.

2. Restore the most recent full backup (the database file).

3. Change to the \SOS\SA\BIN32 directory.

4. Use the database engine with the apply transaction log (-a) switch to apply the transaction log and bring the database up to date:

dbeng11 c:\sos\data\sosdata.db -a d:\soslogs\sosdata.log

Start the database in the normal way. The database engine will come up normally and any new activity will be appended to the current transaction log.

If you have archived and deleted the transaction log since the last full backup, each transaction log since the full backup needs to be applied in sequence to bring the database up to date.

Make a backup of all transaction logs immediately. The database file is gone and the only record of the changes is in the transaction logs.

Restore the most recent full backup (the database file).

Change to the \SOS\SA\BIN32 directory.

Starting with the first transaction log after the full backup, apply each archived transaction log by starting the database engine with the apply transaction log (-a) switch. For example, if the last full backup was on Sunday and the database file is lost during the day on Thursday:

dbeng11 c:\sos\data\sosdata.db -a d:\soslogs\mon.log

dbeng11 c:\sos\data\sosdata.db -a d:\soslogs\tue.log

dbeng11 c:\sos\data\sosdata.db -a d:\soslogs\wed.log

dbeng11 c:\sos\data\sosdata.db -a d:\soslogs\sosdata.log

SA does not allow you to apply the transaction logs in the wrong order or to skip a transaction log in the sequence.

An easier approach is to put all the log files in the same directory, then use this command:

dbeng11 c:\sos\data\sosdata.db -ad d:\soslogs

where “d:\soslogs” is the directory in which you have placed all the relevant log files. The database will inspect the files and automatically apply them in the correct sequence.

After applying the transaction logs, start the database in the normal way. The database engine will come up normally and any new activity will be appended to the current transaction log.

Lost Transaction File

When your database file is still usable but you have lost your transaction log, the recovery process is as follows:

1. Make a backup of the database file immediately. The transaction log is gone and the only record of the changes is in the database file.

2. Restart the database with the -f switch:

dbeng11 c:\sos\data\sosdata.db -f

Without the -f switch, the database engine will complain about the lack of a transaction log. With the switch, the database engine will restore the database to the most recent checkpoint and then roll back any transactions that were not committed at the time of the checkpoint. A new transaction log will be created and the database will do a clean shutdown, after which you should be able to restart it normally.

Media failure on the transaction log can have more serious consequences than media failure on the database file. When you lose the transaction log, all changes since the last checkpoint are lost. By default, database checkpoints are set at 30 minute intervals. This will be a problem when you have a system failure and a media failure at the same time (such as if a power failure causes a head crash that damages the disk). Frequent checkpoints minimize the potential for lost data but also create work for the database engine writing out dirty pages.

For running high-volume or extremely critical applications, you can protect against media failure on the transaction log by mirroring the transaction log or by using a special-purpose device, such as a storage device that mirrors the transaction log automatically.

Client/Server Computing with Sybase SQL Anywhere

Complete Sybase documentation for Sybase SQL Anywhere (SA) can be found by selecting Sybase Manuals on the Help menu in Office Manager (OM), Case Manager (CM), or Appointment Scheduler (AS). Alternatively, select Start > Programs > SOS Applications > Sybase Manuals. There are actually three SA guides:

SQL Anywhere Server SQL Usage, which includes an introduction to SA databases, queries, and other related topics. Many of these are not relevant to your “read only” access to the SOS database.

SQL Anywhere Server SQL Reference, which includes detailed information about SQL syntax.

SQL Anywhere Server Database Administration, which is perhaps the most useful in that it includes detail about management of the database and log files.

Another valuable source of SA information is the Sybase web site, http://www.sybase.com.

Specifications and Limits

The version of SA that comes with SOS Applications is locked to prevent changes to any SOS data by third party programs such as Microsoft Access. This restriction in no way limits your ability to view, read, report, or analyze SOS data with another program (assuming you have been granted access), but you will not be able to modify the data. Without a thorough knowledge of the intricacies of the SOS database and exactly how the many tables relate to one another, you could accidentally introduce data errors or inconsistencies by making a seemingly innocent change.

As you can see from the specifications below, you are extremely unlikely to run into any technical limitations of the database system.

Database size Operating system maximum file size
Number of tables per database Up to 4 billion
Number of tables referenced per transaction No limit
Table size Limited only by file size
Number of columns per table 45,000
Number of rows per table Limited only by file size
Row size Limited only by table size
Number of rows per database Limited only by file size
Field size 2 GB
Number of indexes 2,048 per table
Maximum index entry size No limit

Standalone Installations

When you run an SOS application in a standalone configuration, you are making use of three separate but related software systems: SOS’s application, Microsoft’s Open Database Connectivity (ODBC) system, and Sybase’s SA personal database server engine.

OM, CM and other SOS programs are called front-end or client applications. These applications do not directly manipulate the data stored in the database files. Rather they sends messages, commands, and requests to the Windows ODBC system. Using information stored in the SA driver installed on your system, ODBC translates these generic messages into the specific dialect that can be understood and acted upon by the SA database engine, also running on your system. The database engine then retrieves or modifies your data in accordance with the messages received through the ODBC interface and passes any requested data back to the client program through the ODBC layer.

Network Installations

Client/Server architecture was designed to make network computing more efficient. Work is divided between client workstations and a powerful server, thereby improving performance. Further, client/server applications create much less “traffic” on the network, also resulting in higher performance. Finally, because workstations do not directly control the physical data files, there is little chance of data corruption from power losses, reboots, and other disruptions at the workstation end of the system.

As with a standalone implementation, the operation of an SOS program involves several related software systems (the front-end program such as OM, CM, or the Appointment Scheduler, the Windows ODBC component, the SA client drivers) but also the network operating system on the workstation, the network operating system on the server computer and the SA server software. The network implementation also involves additional hardware components, including network interface cards, cables, other network devices, and, of course, the server computer itself. In a wide area network installation, there can also be routers, firewalls, and various other pieces of communications technology. If the SOS application has trouble reading or updating data in the database, any of these components could be to blame.

All of these potential points of failure could lead to challenging troubleshooting, but the presence or absence of the same problem at a different workstation can quickly isolate the problem to the server or workstation. See the Troubleshooting document in the SOS web site document library for pointers on problem-solving. The online user group (http://groups.google.com/group/sosoft) also can be a great resource. Another user may have had and solved a similar problem in the past.