Database concepts |
Data storage concepts |
Data consistency and concurrency management |
Transactions handling |
Defining database users |
Setting privileges |
SERIAL data type |
INFORMIX specific SQL statements in BDL |
INSERT cursors |
Cursors WITH HOLD |
SELECT FOR UPDATE |
The LOAD and UNLOAD instructions |
Install Sybase ASA and create a database
Install Sybase ASA software on your computer.
Create a Sybase database entity with dbinit tool. Go to a directory where the database files must be created and run the dbinit tool.
Warning: Create the database with case-sensitivity and blank padding for string comparisons:
$ cd <datadirectory>
$ dbinit -c -b <databasename>Make sure that the database option ALLOW_NULLS_BY_DEFAULT option is set to ON.
Warning: If this option is set to OFF, columns created without NULL or NOT NULL are NOT NULL by default.Try to connect to the new created database with the dbisql tool. The default database user is DBA/SQL.
Warning: User logins and passwords are case sensitive!Declare a database user dedicated to your application: the application administrator.
grant connect to <appadmin> identified by <password>
grant resource to <appadmin>
See documentation for more details about database users and privileges. You must create groups to make tables visible to all users.If you plan to use SERIAL emulation based on triggers using a registration table, create the SERIALREG table with the gsrl_asa tool provided in the Adaptation Kit:
$ gsrl_asa -grt
Execute the generated SQL command to create the table. See issue ODIASA005 for more details.Create the application tables. Do not forget to convert Informix data types to Sybase ASA data types. See issue ODIASA100 for more details.
Warning: In order to make application tables visible to all users, make sure that all users are members of the group of the owner of the application tables. For more details, see ASA documentation ("Database object names and prefixes").Prepare the runtime environment
Warning : No ODBC client environment is required. The Sybase ASA driver is designed to be linked with ESQL/C libs (libdblib8+libdbtools8).
If you want to connect to a remote database server, you must have the Sybase ASA Client Software installed on the computer running 4gl applications.
Test the Sybase ASA Client Software: Make sure Sybase ASA is started on the database server and try to connect to a database by using the Interactive SQL tool.
- Set up the fglprofile entries for database connections.
Define the connection timeout with the following fglprofile entry:
dbi.database.<dbname>.asa.logintime = <integer>
This entry defines the number of seconds to wait for a connection.
Default is 5 seconds.In order to connect to Sybase ASA, you must have a runner linked with a "libasa*" database library.
INFORMIX provides two data types to store dates and time information:
Sybase ASA provides two data type to store dates :
String representing date time information :
INFORMIX is able to convert quoted strings to DATE / DATETIME data if the string contents matches environment parameters (i.e. DBDATE, GL_DATETIME). As in INFORMIX, Sybase ASA can convert quoted strings representing datetime data in the ANSI format. The CONVERT( ) SQL function allows you to convert strings to dates.
Date time arithmetic:
Solution :
Sybase ASA has the same DATE data type as INFORMIX ( year, month, day ). So you can use Sybase ASA DATE data type for Informix DATE columns.
Sybase ASA TIME data type can be used to store INFORMIX DATETIME HOUR TO FRAC(3) values. The database interface makes the conversion automatically.
INFORMIX DATETIME values with any precision from YEAR to FRACTION(5) can be stored in Sybase ASA TIMESTAMP columns. The database interface makes the conversion automatically. Missing date or time parts default to 1900-01-01 00:00:00.0. For example, when using a DATETIME HOUR TO MINUTE with the value of "11:45", the ASA TIMESTAMP value will be "1900-01-01 11:45:00.0".
Warning : Using integers as a number of days in an expression with dates is not supported by Sybase ASA. Check your code to detect where you are using integers with DATE columns.
Warning : It is
strongly recommended to use BDL variables in dynamic SQL statements instead of quoted
strings representing DATEs. For example :
LET stmt = "SELECT ... FROM customer
WHERE creat_date >'", adate,"'"
is not portable;
use a question mark place holder instead and
OPEN the cursor USING adate :
LET stmt = "SELECT ... FROM customer WHERE creat_date > ?"
Even if ASA allows SQL reserved keywords as SQL object names if enclosed in double quotes ( "create table "table" ( col1 int )" ), you should take care of your existing database schema and check that you do not use Sybase ASA SQL words.
Solution :
Database objects having a name which is a Sybase ASA SQL reserved word must be renamed.
All BDL application sources must be verified. To check if a given keyword is used in a source, you can use UNIX 'grep' or 'awk' tools. Most modifications can be automatically done with UNIX tools like 'sed' or 'awk'.
When creating a table, INFORMIX automatically adds a "ROWID" column of type integer (applies to non-fragmented tables only). The ROWID column is auto-filled with a unique number and can be used like a primary key to access a given row.
Sybase ASA tables have no ROWIDs.
Solution :
If the BDL application uses ROWIDs, the program logic should be reviewed in order to use the real primary keys (usually, serials which can be supported).
All references to SQLCA.SQLERRD[6] must be removed because this variable will not hold the ROWID of the last INSERTed or UPDATEd row when using the Sybase ASA interface.
INFORMIX SERIAL data type and automatic number production :
INFORMIX allows you
to insert rows with a value different from zero for
a serial column. Using an explicit value will automatically increment the internal serial
counter, to avoid conflicts with future INSERTs that are using a zero value :
CREATE TABLE tab ( k SERIAL );
--> internal counter = 0
INSERT INTO tab VALUES ( 0 ); --> internal counter = 1
INSERT INTO tab VALUES ( 10 ); --> internal counter = 10
INSERT INTO tab VALUES ( 0 ); --> internal counter = 11
DELETE FROM tab;
-->
internal counter = 11
INSERT INTO tab VALUES ( 0 ); --> internal counter = 12
Sybase ASA IDENTITY columns :
INFORMIX SERIALs and MS Sybase ASA IDENTITY columns are quite similar; the main difference is that MS Sybase ASA does not generate a new serial when you specify a zero value for the identity column.
Solution :
You are free to use IDENTITY columns (1) or insert triggers based on the SERIALREG table (2). The first solution is faster, but does not allow explicit serial value specification in insert statements; the second solution is slower but allows explicit serial value specification. You can initially use the second solution to have unmodified 4gl programs working on Sybase ASA, but you should update your code to use native IDENTITY columns for performance.
With the following fglprofile entry, you define the technique to be used for SERIAL emulation :
dbi.database.<dbname>.ifxemul.datatype.serial.emulation = {native|regtable}
The 'native' value defines the IDENTITY column technique and the 'regtable' defines the trigger technique.
This entry must be used with :
dbi.database.<dbname>.ifxemul.datetype.serial = {true|false}
If this entry is set to false, the emulation method specification entry is ignored.
Warning : When no entry is specified, the default is SERIAL
emulation enabled with 'native' method (IDENTITY-based).
1. Using IDENTITY columns
In database creation scripts, all SERIAL data types must be converted by hand to INTEGER IDENTITY data types.
Warning : Start values SERIAL(n) cannot be converted, there is no INTEGER IDENTITY(n) in Sybase ASA.
Tables created from the BDL programs can use the SERIAL data type : When a BDL program executes a CREATE [TEMP] TABLE with a SERIAL column, the database interface automatically converts the "SERIAL[(n)]" data type to "INTEGER IDENTITY[(n,1)]".
In BDL, the new generated SERIAL value is available from the SQLCA.SQLERRD[2] variable. This is supported by the database interface which performs a "SELECT @@IDENTITY".
Warning : When you insert a row
with zero as serial value, the serial column gets the value zero.
INSERT INTO tab ( col_serial,
col_data, ... ) VALUES ( 0, <data|var>, ... )
Must be converted to :
INSERT INTO tab ( col_data, ... )
VALUES ( <data|var>, ... )
Warning : SELECT * FROM table INTO TEMP with original table having an IDENTITY column is not supported: The database driver must convert the Informix SELECT INTO TEMP statement into a SELECT INTO #tab + INSERT (see temporary tables) because ODBC does not allow SQL parameters in DDL statements. As MS Sybase ASA does not allow you to insert a row by giving the identity column, the INSERT statement fails.
2. Using triggers with the SERIALREG table
First, you must prepare the database and create the SERIALREG table. You can generate the CREATE TABLE instruction with the gsrl_asa tool provided in the adaptation kit.
In database creation scripts, all SERIAL[(n)] data types must be converted to INTEGER data types and you must create one trigger for each table by using the gsrl_asa tool.
Tables created from the BDL programs can use the SERIAL data type. When a BDL program executes a CREATE [TEMP] TABLE with a SERIAL column, the database interface automatically converts the "SERIAL[(n)]" data type to "INTEGER" and creates the insert triggers.
Warning : Sybase ASA does not allow you to create triggers on temporary tables. Therefore, you cannot create temp tables with a SERIAL column when using this solution.
Warning : SELECT ... INTO TEMP statements using a table created with a SERIAL column do not automatically create the SERIAL triggers in the temporary table. The type of the column in the new table is INTEGER.
Warning : Sybase ASA triggers are not automatically dropped when the corresponding table is dropped. Database administrators must be aware of this behavior when managing schemas.
Warning :
INSERT statements using NULL for the SERIAL column will produce a new serial
value, instead of a NULL like INFORMIX does :
INSERT INTO tab ( col_serial,
col_data ) VALUES ( NULL, 'data' )
This behavior is mandatory in order to support INSERT statements which do not
use the serial column :
INSERT INTO tab ( col_data ) VALUES
( 'data' )
Check if your application uses tables with a SERIAL
column that can contain a NULL value.
Warning : The serial production is based on the SERIALREG table which registers the last generated number for each table. If you delete rows of this table, sequences will restart at 1 and you will get unexpected data.
The syntax of OUTER joins is quite different in INFORMIX and Sybase ASA :
In INFORMIX SQL, outer tables are defined in the FROM clause with the OUTER keyword :
SELECT ... FROM cust, OUTER(order) WHERE cust.key = order.custnoSELECT ... FROM cust, OUTER(order,OUTER(item)) WHERE cust.key = order.custno AND order.key = item.ordno AND order.accepted = 1
Sybase ASA Version 7 supports the ANSI outer join syntax :
SELECT ... FROM cust LEFT OUTER JOIN order ON cust.key = order.custnoSELECT ... FROM cust LEFT OUTER JOIN order LEFT OUTER JOIN item ON order.key = item.ordno ON cust.key = order.custno WHERE order.accepted = 1
Remark: The old way to define outers in Sybase ASA looks like the following :
SELECT ... FROM a, b WHERE a.key *= b.key
See the Sybase ASA reference manual for a complete description of the syntax.
Solution :
The Sybase ASA interface can convert simple INFORMIX OUTER specifications to Sybase ASA ANSI outer joins.
Prerequisites :
Remarks :
As in INFORMIX, an Sybase ASA engine can manage multiple database entities. When creating a database object like a table, Sybase ASA allows you to use the same object name in different databases.
Data consistency involves readers which want to access data currently modified by writers and concurrency data access involves several writers accessing the same data for modification. Locking granularity defines the amount of data concerned when a lock is set (row, page, table, ...).
INFORMIX
INFORMIX uses a locking mechanism to manage data consistency and concurrency. When a process modifies data with UPDATE, INSERT or DELETE, an exclusive lock is set on the affected rows. The lock is held until the end of the transaction. Statements performed outside a transaction are treated as a transaction containing a single operation and therefore release the locks immediately after execution. SELECT statements can set shared locks according to the isolation level. In case of locking conflicts (for example, when two processes want to acquire an exclusive lock on the same row for modification or when a writer is trying to modify data protected by a shared lock), the behavior of a process can be changed by setting the lock wait mode.
Control :
Defaults :
Sybase ASA
As in INFORMIX, Sybase ASA uses locks to manage data consistency and concurrency. The database manager sets exclusive locks on the modified rows and shared locks when data is read, according to the isolation level. The locks are held until the end of the transaction. When multiple processes want to access the same data, the latest processes must wait until the first finishes its transaction or the lock timeout occurred. The lock granularity is at the row or table level. For more details, see Sybase ASA's Documentation, "Accessing and Changing Data", "Locking".
Control :
Defaults :
Solution :
For portability, it is recommended that you work with INFORMIX in the read committed isolation level, to make processes wait for each other (lock mode wait) and to create tables with the "lock mode row" option.
See INFORMIX and Sybase ASA documentation for more details about data consistency, concurrency and locking mechanisms.
When using SET LOCK MODE and SET ISOLATION LEVEL instructions, the database interface sets automatically the native database session options.
A lot of BDL programs use pessimistic locking in order to avoid several users editing the same rows at the same time.
DECLARE cc CURSOR FOR
SELECT ... FOR UPDATE
OPEN cc
FETCH cc <-- lock is acquired
CLOSE cc <-- lock is released
Sybase ASA allows individual and exclusive row locking by using the FOR UPDATE clause, as Informix.
Sybase ASA's locking granularity is at the row level, page level or table level (the level is automatically selected by the engine for optimization).
To control the behavior of the program when locking rows, INFORMIX provides a specific instruction to set the wait mode:
SET LOCK MODE TO { WAIT | NOT WAIT | WAIT seconds }
The default mode is WAIT. This as an INFORMIX specific SQL statement.
Solution :
SELECT FOR UPDATE statements are well supported.
Warning : Sybase ASA locks the rows when you open the cursor. You will have to test SQLCA.SQLCODE after doing an OPEN.
Warning : The database interface is based on an emulation of an Informix engine using transaction logging. Therefore, opening a SELECT ... FOR UPDATE cursor declared outside a transaction will raise an SQL error -255 (not in transaction).
Warning : The SELECT FOR UPDATE statement cannot contain an ORDER BY clause if you want to perform positioned updates/deletes with WHERE CURRENT OF.
You must review the program logic if you use pessimistic locking because it is based on the NOT WAIT mode which is not supported by Sybase ASA.
INFORMIX and Sybase ASA handle transactions in a similar manner.
INFORMIX native mode (non ANSI) :
Sybase ASA :
Transactions in stored procedures : avoid using transactions in stored procedure to allow the client applications to handle transactions, according to the transaction model.
Solution :
INFORMIX transaction handling commands are automatically converted to Sybase ASA instructions to start, validate or cancel transactions.
The database driver sets the "CHAINED" option to OFF when connecting to the server.
Regarding the transaction control instructions, the BDL applications do not have to be modified in order to work with Sybase ASA.
As in INFORMIX, Sybase ASA provides the CHAR and VARCHAR data types to store character data.
INFORMIX CHAR type can store up to 32767 characters and the VARCHAR data type is limited to 255 characters.
Sybase ASA CHAR and VARCHAR both have a limit of 32767 characters.
Sybase ASA provides the LONG VARCHAR data type to store large character strings. Only the LIKE operator can be used for searches. LONG VARCHAR columns cannot be used in classic comparison expressions (as col = 'value').
Solution :
The database interface supports character string variables in SQL statements for input (BDL USING) and output (BDL INTO) for CHAR and VARCHAR data types.
Warning : Check that your database schema does not use CHAR or VARCHAR types with a length exceeding the Sybase ASA limit.
Warning : TEXT values cannot be used as input or output parameters in SQL statements and therefore are not supported.
Constraint naming syntax :
Both INFORMIX and Sybase ASA support primary key, unique, foreign key, default and check constraints. But Sybase ASA does not support constraint naming syntax:
UNIQUE constraint example :
INFORMIX | Sybase ASA |
CREATE TABLE scott.emp ( ... empcode CHAR(10) UNIQUE [CONSTRAINT pk_emp], ... |
CREATE TABLE scott.emp ( ... empcode CHAR(10)UNIQUE, ... |
Solution :
Constraint naming syntax :
The database interface does not convert constraint naming expressions when creating tables from BDL programs. Review the database creation scripts to adapt the constraint naming clauses for Sybase ASA.
INFORMIX and Sybase ASA provide triggers with similar features, but the programming languages are totally different.
Warning : Sybase ASA does not support triggers on temporary tables.
Solution :
INFORMIX triggers must be converted to Sybase ASA triggers "by hand".
Both INFORMIX and Sybase ASA support stored procedures, but the programming languages are totally different :
Solution :
INFORMIX stored procedures must be converted to Sybase ASA "by hand".
INFORMIX users are defined at the operating system level, they must be members of the 'informix' group, and the database administrator must grant CONNECT, RESOURCE or DBA privileges to those users.
Before a user can access an Sybase ASA database, the system administrator (DBA) must declare the application users in the database with the GRANT statement. You may also need to define groups in order to make tables visible to other users.
Solution :
See Sybase ASA documentation for more details on database logins and users.
INFORMIX and Sybase ASA user privileges management are quite similar.
Sybase ASA provides user groups to grant or revoke permissions to more than one user at the same time.
INFORMIX temporary tables are created through the CREATE TEMP TABLE DDL instruction or through a SELECT ... INTO TEMP statement. Temporary tables are automatically dropped when the SQL session ends, but they can also be dropped with the DROP TABLE command. There is no name conflict when several users create temporary tables with the same name.
Remark : BDL reports create a temporary table when the rows are not sorted externally (by the source SQL statement).
INFORMIX allows you to create indexes on temporary tables. No name conflict occurs when several users create an index on a temporary table by using the same index identifier.
Sybase ASA provides local (SQL session wide) temporary tables by using the DECLARE LOCAL TEMPORARY TABLE statement.
Warning : The "SELECT ... INTO TEMP" statement is not supported in Sybase ASA.
Warning : Index creation is not supported on temporary tables in Sybase ASA, but the connector doesn't raise error. You have not to remove the index creation on temp tables in your 4gl programs, but keep in mind that index will not be created.
Solution :
INFORMIX temporary tables instructions are converted to generate native Sybase ASA temporary tables .
INFORMIX SQL statements can use subscripts on columns defined with
the character data type :
SELECT ... FROM tab1 WHERE col1[2,3] = 'RO'
SELECT ... FROM tab1 WHERE col1[10]
= 'R' -- Same as col1[10,10]
UPDATE tab1 SET col1[2,3]
= 'RO' WHERE ...
SELECT ... FROM tab1 ORDER BY col1[1,3]
.. while Sybase ASA provides the SUBSTR( ) function, to
extract a substring from a string expression :
SELECT .... FROM tab1 WHERE SUBSTRING(col1,2,2) = 'RO'
SELECT SUBSTRING('Some text',6,3)
FROM DUAL -- Gives 'tex'
Solution :
You must replace all Informix col[x,y] expressions by SUBSTRING(col,x,y-x+1).
Warning : In UPDATE
instructions, setting column values through subscripts will produce an error with
Sybase ASA :
UPDATE tab1 SET col1[2,3]
= 'RO' WHERE ...
is converted to :
UPDATE tab1 SET SUBSTRING(col1,2,3-2+1)
= 'RO' WHERE ...
Warning : Column
subscripts in ORDER BY expressions are also converted and produce an error with Sybase ASA
:
SELECT ... FROM tab1 ORDER BY col1[1,3]
is converted to :
SELECT ... FROM tab1 ORDER BY SUBSTRING(col1,1,3-1+1)
INFORMIX uses the following form to identify an SQL object :
[database[@dbservername]:][{owner|"owner"}.](identifier|"identifier")
With Sybase ASA, an object name takes the following form :
[{owner|"owner"}.]{identifier|"identifier"
Identifiers have a maximum length of 128 bytes and are composed of alphabetic characters ( _, @, #, $ are considered as alphabetic characters) or digits. The first character must be alphabetic.
INFORMIX database object names are not case sensitive in non-ANSI databases.
Sybase ASA database objects names are case sensitive by default, but this is related to the -c option of the dbinit command. Databases must be created as case-sensitive, otherwise a string comparison such as "abc"="ABC" would evaluate to TRUE.The ANSI string delimiter character is the single quote ( 'string' ). Double quotes are used to delimit database object names ("object-name").
Example : WHERE "tabname"."colname" = 'a string value'
As INFORMIX, Sql Server Anywhere allows to use double quotes as string delimiters, if the QUOTED_IDENTIFIER session option is OFF, the default is ON:
SET TEMPORARY OPTION QUOTED_IDENTIFIER = OFF
Remark : This problem concerns only double quotes within SQL statements. Double quotes used in BDL string expressions are not subject of SQL compatibility problems.
Solution :
When the ifxemul.dblquotes option is set, the Sybase ASA database interface converts all double quotes to single quotes in SQL statements. The database driver does not set the QUOTED_IDENTIFIER option implicitly.
Sybase ASA offers numeric data types which are quite similar to INFORMIX numeric data types. The table below shows general conversion rules for numeric data types :
INFORMIX | Sybase ASA |
SMALLINT | SMALLINT |
INTEGER (synonym: INT) | INTEGER (synonym: INT) |
DECIMAL[(p[,s)] (synonyms: DEC,
NUMERIC) DECIMAL(p,s) defines a fixed point decimal where p is the total number of significant digits and s the number of digits that fall on the right of the decimal point. DECIMAL(p) defines a floating point decimal where p is the total number of significant digits. The precision p can be from 1 to 32. DECIMAL is treated as DECIMAL(16). |
DECIMAL[(p[,s)] (synonyms: DEC,
NUMERIC) DECIMAL[(p[,s])] defines a fixed point decimal where p is the total number of significant digits and s the number of digits that fall on the right of the decimal point. Without any decimal storage specification, the precision defaults to 30 and the scale defaults to 6 : - DECIMAL in Sybase ASA = DECIMAL(30,0) in INFORMIX - DECIMAL(p) in Sybase ASA = DECIMAL(p,6) in INFORMIX |
MONEY[(p[,s]) |
Sybase ASA provides the MONEY and SMALLMONEY data types, but the currency symbol handling is quite different. Therefore, Informix MONEY columns should be implemented as DECIMAL columns in Sybase ASA. |
SMALLFLOAT (synonyms: REAL) | REAL |
FLOAT[(n)] (synonyms: DOUBLE
PRECISION) The precision (n) is ignored. |
FLOAT(n) (synonyms: DOUBLE PRECISION) Where n must be from 1 to 15. |
Solution :
In BDL programs :
When creating tables from BDL programs, the database interface automatically converts INFORMIX data types to corresponding Sybase ASA data types.
Database creation scripts :
With INFORMIX, you must use the system table with a condition on the table id :
SELECT user FROM systables WHERE tabid=1
With Sybase ASA, you can omit the FROM clause to generate one row only:
SELECT user
Solution :
Check the BDL sources for "FROM systables WHERE tabid=1" and use dynamic SQL to resolve this problem.
INFORMIX supports MATCHES and LIKE in SQL statements, while Sybase ASA supports the LIKE statement only.
The MATCHES operator of INFORMIX uses the star, question mark and
square braces wildcard characters.
The LIKE operator of Sybase ASA offers the percent, underscore and square braces wildcard
characters.
The following substitutions must be made to convert a MATCHES condition to a LIKE condition :
Solution :
Warning : SQL statements using MATCHES expressions must be reviewed in order to use LIKE expressions.
The BDL compiler supports several INFORMIX specific SQL statements that have no meaning when using Sybase ASA.
Examples :
Solution :
Review your BDL source and remove all static SQL statements which are INFORMIX specific.
INFORMIX supports insert cursors. An "insert cursor" is a special BDL cursor declared with an INSERT statement instead of a SELECT statement. When this kind of cursor is open, you can use the PUT instruction to add rows and the FLUSH instruction to insert the records into the database.
For INFORMIX database with transactions, OPEN, PUT and FLUSH instructions must be executed within a transaction.
Sybase ASA does not support insert cursors.
Solution :
Insert cursors are emulated by the Sybase ASA database interface.
Both INFORMIX and Sybase ASA provide special data types to store very large texts or images.
Sybase ASA recommends the following conversion rules :
INFORMIX Data Type | Sybase ASA Data Type |
TEXT | TEXT / LONG VARCHAR |
BYTE | BINARY / LONG BINARY / IMAGE / VARBINARY |
Solution :
Very large character data types are not supported yet by the Sybase ASA database interface.
INFORMIX automatically closes opened cursors when a transaction ends unless the WITH HOLD option is used in the DECLARE instruction.
Sybase ASA does not close cursors when a transaction ends, as long as the global parameter close_on_endtrans is off.
Solution :
BDL cursors that are not declared "WITH HOLD" are automatically closed by the database interface when a COMMIT WORK or ROLLBACK WORK is performed by the BDL program.
As in INFORMIX, Sybase ASA provides system catalog tables (sysobjects,syscolumns,etc) in each database, but the table names and their structure are quite different.
Solution :
Warning : No automatic conversion of INFORMIX system tables is provided by the database interface.
INFORMIX allows a specific syntax for UPDATE statements :
UPDATE table SET ( <col-list> ) = ( <val-list> )
or
UPDATE table SET table.* =
myrecord.*
UPDATE table SET * = myrecord.*
Solution :
Static UPDATE statements using the above syntax are converted by the
compiler to the
standard form :
UPDATE table SET column=value [,...]
INFORMIX's INTERVAL data type stores a value that represents a span of time. INTERVAL types are divided into two classes : year-month intervals and day-time intervals.
Sybase ASA does not provide a data type corresponding to the INFORMIX INTERVAL data type.
Solution :
Warning: The INTERVAL data type is not well supported because the database server has no equivalent native data type. However, you can store into and retrieve from CHAR columns BDL INTERVAL values.
An attempt should be made to preserve as much of the storage information as possible when converting from INFORMIX to Sybase ASA. Most important storage decisions made for INFORMIX database objects (like initial sizes and physical placement) can be reused in an Sybase ASA database.
Storage concepts are quite similar in INFORMIX and in Sybase ASA, but the names are different.
The following table compares INFORMIX storage concepts to Sybase ASA storage concepts :
INFORMIX | Sybase ASA |
Physical units of storage | |
The largest unit of physical disk space is
a "chunk", which can be allocated either as a cooked file ( I/O
is controlled by the OS) or as raw device (=UNIX partition, I/O is controlled by the
database engine). A "dbspace" uses at least one "chunk" for storage. You must add "chunks" to "dbspaces" in order to increase the size of the logical unit of storage. |
A database is composed of tablespace. Each tablespace is composed of a '.db' file. In a database, there is one tablespace at the creation, but can hold more than one tablespace. The size of a tablespace is increased automatically. |
A "page" is the
smallest physical unit of disk storage that the engine uses to read from and write to
databases. A "chunk" contains a certain number of "pages". The size of a "page" must be equal to the operating system's block size. |
At the finest level of granularity, Sql Server Anywhere stores data in "page" which size can be defined at the creation time. |
An "extent"
consists of a collection of continuous "pages" that the engine uses to allocate
both initial and subsequent storage space for database tables. When creating a table, you can specify the first extent size and the size of future extents with the EXTENT SIZE and NEXT EXTENT options. For a single table, "extents" can be located in different "chunks" of the same "dbspace". |
Database files are extended by 32 pages at a time when the space is needed. |
Logical units of storage | |
A "table" is a logical unit of storage that contains rows of data values. | Same concept as INFORMIX. |
A "database" is a logical unit of storage that contains table and index data. Each database also contains a system catalog that tracks information about database elements like tables, indexes, stored procedures, integrity constraints and user privileges. | Same concept as INFORMIX. |
Database tables are created in a specific
"dbspace", which defines a logical place to store data. If no dbspace is given when creating the table, INFORMIX defaults to the current database dbspace. |
? |
The total disk space allocated for a table is the "tblspace", which includes "pages" allocated for data, indexes, blobs, tracking page usage within table extents. | ? |
Other concepts | |
When initializing an INFORMIX engine, a "root dbspace" is created to store information about all databases, including storage information (chunks used, other dbspaces, etc.). | ? |
The "physical log"
is a set of continuous disk pages where the engine stores "before-images" of
data that has been modified during processing. The "logical log" is a set of "logical-log files" used to record logical operations during on-line processing. All transaction information is stored in the logical log files if a database has been created with transaction log. INFORMIX combines "physical log" and "logical log" information when doing fast recovery. Saved "logical logs" can be used to restore a database from tape. |
Sybase ASA uses "database
log files" to record SQL transactions. |
INFORMIX offers the NCHAR and NVARCHAR data types to store strings in a localized character set.
Solution :
Warning : National character data types are not supported yet.
INFORMIX provides two SQL instructions to export / import data from / into a database table: The UNLOAD instruction copies rows from a database table into an text file and the LOAD instruction inserts rows from an text file into a database table.
Warning : Sybase ASA has LOAD and UNLOAD instructions, but those commands are related to database backup and recovery. Do not confuse with INFORMIX commands.
Solution :
LOAD and UNLOAD instructions are supported.
Warning : The LOAD instruction does not work with tables using emulated SERIAL columns because the generated INSERT statement holds the "SERIAL" column which is actually a IDENTITY column in Sybase ASA. See the limitations of INSERT statements when using SERIALs.
Warning : In Sybase ASA, INFORMIX DATE data is stored in DATETIME columns, but DATETIME columns are similar to INFORMIX DATETIME YEAR TO FRACTION(3) columns. Therefore, when using LOAD and UNLOAD, those columns are converted to text data with the format "YYYY-MM-DD hh:mm:ss.fff".
Warning : In Sybase ASA, INFORMIX DATETIME data is stored in DATETIME columns, but DATETIME columns are similar to INFORMIX DATETIME YEAR TO FRACTION(3) columns. Therefore, when using LOAD and UNLOAD, those columns are converted to text data with the format "YYYY-MM-DD hh:mm:ss.fff".
Warning : When using an INFORMIX database, simple dates are unloaded with the DBDATE format (ex: "23/12/1998"). Therefore, unloading from an INFORMIX database for loading into a Sybase ASA database is not supported.
In INFORMIX, database object names like table and column names are not case sensitive :
CREATE TABLE Customer ( Custno INTEGER, ... )
SELECT CustNo FROM cuSTomer ...
In Sybase ASA, database object names and character data are case-unsenstive by default :
CREATE TABLE Customer ( Custno INTEGER, CustName CHAR(20) )
INSERT INTO CUSTOMER VALUES ( 1, 'TECHNOSOFT' )
SELECT CustNo FROM cuSTomer WHERE custname = 'techNOSoft'
Solution :
When you create a Sybase ASA database with dbinit, you can use the -c option to make the database case-sensitive.
INFORMIX provides a special instruction to compute database statistics in order to help the optimizer find the right query execution plan :
UPDATE STATISTICS ...
Sybase ASA offers a similar instruction, but it uses different clauses :
UPDATE STATISTICS ...
See Sybase ASA documentation for more details.
Solution :
Centralize the optimization instruction in a function. See the ODILIB.BDL source as example.
INFORMIX and MS Sybase ASA use different implementations of the ALTER TABLE instruction. For example, INFORMIX allows you to use multiple ADD clauses separated by comma. This is not supported by Sybase ASA :
INFORMIX :
ALTER TABLE customer ADD(col1 INTEGER), ADD(col2 CHAR(20))
Sybase ASA :
ALTER TABLE customer ADD col1 INTEGER, col2 CHAR(20)
Solution :
Warning : No automatic conversion is done by the database interface. There is even no real standard for this instruction ( that is, no common syntax for all database servers). Read the SQL documentation and review the SQL scripts or the BDL programs in order to use the database server specific syntax for ALTER TABLE.
INFORMIX Data Types | Sybase ASA Data Types |
CHAR(n) | CHAR(n) (limit = 32767c!) |
VARCHAR(n) | VARCHAR(n) (limit = 32767c!) |
INTEGER | INTEGER |
SMALLINT | SMALLINT |
FLOAT[(n)] | FLOAT(n) |
SMALLFLOAT | REAL |
DECIMAL(p,s) | DECIMAL(p,s)! upper limit = 128 digits |
MONEY(p,s) | DECIMAL(p,s)! upper limit = 128 digits |
DATE | DATE (yyyy-mm-dd) |
DATETIME HOUR TO FRACTION | TIME (hh:mm:ss.fff) |
DATETIME q1 TO q2 (q2>FRACTION) | TIMESTAMP (yyyy-mm-dd hh:mm:ss.fff) |
INTERVAL q1 TO q2 | CHAR(n) |