BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database...

94
BaanERP Sybase Database Driver Technical Reference Manual

Transcript of BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database...

Page 1: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERPSybase Database DriverTechnical Reference Manual

Page 2: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

A publication of:

Baan Development B.V.P.O.Box 1433770 AC BarneveldThe Netherlands

Printed in the Netherlands

© Baan Development B.V. 1998.All rights reserved.

The information in this documentis subject to change withoutnotice. No part of this documentmay be reproduced, stored ortransmitted in any form or by anymeans, electronic or mechanical,for any purpose, without theexpress written permission ofBaan Development B.V.

Baan Development B.V.assumes no liability for anydamages incurred, directly orindirectly, from any errors,omissions or discrepanciesbetween the software and theinformation contained in thisdocument.

Document Information

Code: U7082B USGroup: User DocumentationEdition: BDate: July 1998

Page 3: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

i

Sybase Database Driver Technical Reference Manual

1 BaanERP database driver overview 1-1The BaanERP architecture 1-1Display tier 1-2Application tier 1-2Database tier 1-3Data flow through the BaanERP architecture 1-4BaanERP hardware configurations 1-5

2 BaanERP database organization 2-1BaanERP data dictionary 2-1Table naming convention 2-2Column naming convention 2-3Index naming convention 2-4Stored procedure naming convention 2-5Data type mapping 2-6Additional constraints 2-7

3 Database driver internal processing 3-1Data integrity 3-1Referential integrity 3-1Data buffering 3-1Database driver SQL processing 3-2Open Client library 3-2SQL processing 3-3Setting driver behavior 3-3Driver resources 3-4Environment variables 3-5Storage file 3-7

4 Database security 4-1Database Security 4-1Groups 4-1Object security 4-2Authentication 4-3DBA module 4-4

Table of contents

Page 4: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Table of contents

Sybase Database Driver Technical Reference Manual

ii

5 Database driver profiling and statistics 5-1Profiling 5-1Effect of optimization 5-4Gathering statistics 5-4Enabling statistics from the tabledef file 5-4Enabling statistics with the environment variable SYBSTAT 5-5Troubleshooting 5-7Error reporting 5-7Steps for analyzing errors 5-8Logging database driver trace information 5-8Logging errors 5-8

6 Database driver configuration and tuning 6-1Optimization 6-1Index optimization 6-2Duplicate indexes 6-4Hash optimization 6-4Hash column naming convention 6-5Size of hash columns 6-6Specifying index optimization 6-6Fetch optimization 6-7Row caching 6-8Stored procedures 6-9Optimistic and pessimistic reference checks 6-10Isolation levels 6-10Transaction management 6-11Locking behavior 6-11High-level lock retries 6-12

7 Appendix A: Database driver resources and environment variables 7-1Summary of Sybase resources and environment variables 7-1Detailed description of Sybase resources and environment variables 7-3Generic driver resources 7-4Sybase driver specific resources 7-14Sybase environment variables 7-19

8 Appendix B: Database driver file formats and configuration options 8-1Storage file 8-1Storage file field descriptions 8-2Users and groups files 8-7The users file 8-7The groups file 8-9

Page 5: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Table of contents

Sybase Database Driver Technical Reference Manual

iii

9 Appendix C: BaanERP Sybase database driver SQL queries 9-1No Hash optimization 9-1Unique index 9-1Duplicate Index 9-2Hash optimization 9-3Unique Index 9-3Duplicate Index 9-4

Page 6: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Table of contents

Sybase Database Driver Technical Reference Manual

iv

Page 7: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

v

This document describes the BaanERP database driver that forms the interfacebetween the BaanERP application virtual machine and the Sybase databaseserver. It supplies technical reference information about the BaanERP databasedriver for Sybase. This document is intended for those who wish to configure orcustomize the BaanERP database driver for Sybase. An elementary knowledge ofUNIX and Sybase is assumed. An understanding of database technology is alsoassumed.

The procedure for installing the Sybase and BaanERP software is described inthe Sybase Installation Guide for BaanERP on UNIX (U7081 US).

This document is divided into the following six chapters and three appendices:

Chapter 1 provides an overview of the BaanERP database driver architecture andhow the database driver fits within the BaanERP system.

Chapter 2 describes the BaanERP database organization and details the namingconventions used for data and objects within the Sybase database.

Chapter 3 describes some of the internal features of the BaanERP Sybasedatabase driver.

Chapter 4 describes several aspects of database security provided by theBaanERP Sybase database driver.

Chapter 5 describes the facilities for profiling and gathering statistics aboutdatabase driver performance.

Chapter 6 details the configuration and tuning options for the BaanERP Sybasedatabase driver.

Appendix A supplies information about the variables that can be configured forthe database driver.

Appendix B contains information about the file format of the storage file, theusers file, and the groups file. It also discusses the driver configuration optionsspecific to the BaanERP Sybase database driver.

Appendix C lists the SQL queries generated by the BaanERP Sybase databasedriver.

About this document

Page 8: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

About this document

Sybase Database Driver Technical Reference Manual

vi

Page 9: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

1-1

The database driver plays an important role in Baan’s commitment to an opensystems client/server architecture. Because the BaanERP architecture includesboth the BaanERP software and a third party relational database managementsystem (RDBMS), the driver is needed to provide a seamless interface betweenthe BaanERP software and the different RDBMS products. The database driverallows the majority of the BaanERP processing to be independent of theRDBMS. This chapter provides an overview of the database driver and how itfits into the BaanERP architecture.

The following topics are covered in this chapter:

� The BaanERP architecture� Data flow through the BaanERP architecture� BaanERP hardware configurations� BaanERP hardware configurations

The BaanERP architectureBaanERP supports a three-tier architecture consisting of a display tier, anapplication tier, and a database tier. The display tier provides presentationservices for user interaction. The application tier consists of the BaanERPapplication virtual machine and the application objects. The database tierincludes the BaanERP database driver and a third party RDBMS product thatacts as the database server. Figure 1 depicts the BaanERP architecture.

The emphasis of this document is the BaanERP database driver. The databasedriver is the interface between the BaanERP applications and the RDBMS server.The database driver translates database requests from the BaanERP applicationvirtual machine to RDBMS specific SQL requests that it sends to the databaseserver. After the database server retrieves the requested information, the databasedriver then passes the data back to the BaanERP application virtual machine.

1 BaanERP database driver overview

Page 10: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-2

To put the functions of the database driver into perspective, each of the threetiers of the total BaanERP architecture is described briefly below.

ApplicationVirtual Machine

(bshell)

Display Tier

Application Tier

Database Tier

Database Driver

Display Driver

Application Objects

Database Server(RDBMS)

Figure 1, BaanERP three-tier architecture

Display tier

The display tier consists of the display driver, the BaanERP user interface forMicrosoft Windows (BW) and for Internet browsers (BI). The display driverfacilitates the communication between the user and the application tier. Datainput from the user through BW or BI is relayed to the BaanERP applicationvirtual machine; data returned from the BaanERP application virtual machine isdisplayed to the user in graphical form by the display server.

Application tier

The application tier includes both the application objects and the BaanERPapplication virtual machine. Together, the application objects and the applicationvirtual machine provide much of the functionality of BaanERP.

The application objects include the compiled BaanERP applications and the datadictionary. The BaanERP applications provide the functionality needed toimplement the BaanERP Enterprise Resource Planning (ERP) system. Theseapplications are written in Baan 3GL or Baan 4GL, programming languagessupported by the BaanERP Tools package.

Page 11: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-3

The data dictionary defines the data models used by the applications. The datadictionary includes information about the domains, schemas, and referentialintegrity rules used by BaanERP.

The BaanERP application virtual machine schedules and runs the applicationobjects, sends and receives information to and from the display server, andinitiates an instance of the database driver as necessary for communication withthe database server. A running database driver can support multiple connectionsto a single RDBMS instance. If a BaanERP installation stores data tables inmultiple RDBMS products or instances, the application virtual machine muststart one instance of the database driver for each RDBMS product or RDBMSinstance with which it must communicate.

The BaanERP application virtual machine has traditionally been called theBaanERP shell or more often simply the bshell. Throughout the remainder of thisdocument, it is referred to as the BaanERP application virtual machine or theapplication virtual machine.

Database tier

The database tier consists of the BaanERP database driver and the databaseserver. The database driver provides a common interface between the BaanERPapplication virtual machine and the database server. Communication between theapplication virtual machine and the database driver is the same, no matter whichRDBMS product is used as the database server. There is one database driver foreach of the RDBMS products that BaanERP supports.

Communication between the database driver and the database server is tailored tothe RDBMS being used. The database driver communicates with the RDBMSthrough structured query language (SQL) statements and the native applicationprogramming interface (API) of the RDBMS.

The database server consists of one of five third party RDBMS products: Oracle,Informix, Sybase, DB2, or Microsoft SQL Server. All BaanERP application datais stored in a relational database managed by an RDBMS. It is possible to havemultiple RDBMS products in one BaanERP installation, with some data residingin one database server and other data residing in another.

Page 12: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-4

Data flow through the BaanERP architectureNote that the database driver provides an interface between the BaanERPapplication virtual machine and the specific RDBMS server being used. The flowof data through the system is described below.

When a user performs an operation at a GUI workstation, the display serverinterprets the input and sends the information to the BaanERP application virtualmachine. Based on the information it receives, the application virtual machinecauses the appropriate application object to be executed.

When a running application object requires information that is stored in thedatabase, the application virtual machine sends the request to the database driver.Data requests from the client applications are RDBMS independent and are madeusing BaanERP SQL, an RDBMS independent SQL language.

When the application virtual machine executes a database query from anapplication object, it first determines whether or not there is a running databasedriver available to process the query. If there is no database driver running, or ifthe running database driver instances are communicating with a database serverother than the one storing the needed data, the application virtual machine starts anew instance of the database driver. The application virtual machine parses theBaanERP SQL database query it receives from the application object and sendsan internal representation of the query to the database driver. The internalrepresentation of the query that the database driver receives is still RDBMSindependent.

The database driver translates the database query into an appropriate query usingSQL statements compatible with the specific RDBMS being used. Each databasedriver takes advantage of the design of the particular RDBMS that it supports sothat the resulting SQL statements are valid for the RDBMS and provide the bestpossible performance. The RDBMS specific SQL statements are then submittedto the RDBMS server, which processes the data request.

When the RDBMS has processed the query, it returns the data to the databasedriver. Any error conditions are caught and handled by the database driver. Thedatabase driver then returns the data and status information to the applicationvirtual machine, where it provides the information to the application thatrequested it. The application virtual machine may also send a message to thedisplay server, which displays an appropriate message on the user’s workstation.

Page 13: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-5

BaanERP hardware configurationsSeveral hardware configurations are supported for a BaanERP implementation.These configurations include standalone mode and many variations ofclient/server mode. Available hardware, data storage requirements, andperformance expectations determine the most appropriate hardwareconfiguration.

Standalone mode refers to a configuration where all components of the BaanERParchitecture run on a single machine. In standalone mode, an end user can workfrom the host machine or from a thin client machine, such as an X-Terminalrunning BI. The standalone mode configuration is illustrated in Figure 2.

ApplicationVirtual Machine

(bshell)

Database Driver

Display Driver

Application Objects

Database Server(RDBMS)

Figure 2, Standalone mode configuration

Page 14: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-6

In a client/server configuration, the components of the BaanERP architecture aredistributed over two or more machines. There are many client/serverconfigurations. The most common configurations are described here.

The simplest client/server configuration is sometimes thought of as a variation ofstandalone mode. In this configuration, the application tier, database driver andRDBMS are on one machine, while the display drivers are distributed among theuser workstations. An instance of the application virtual machine and at least oneinstance of the database driver is started for each user. All users have access tothe same application objects and database servers. This configuration isillustrated in Figure 3.

ApplicationVirtual Machine

(bshell)

Database Driver

Display Driver Display Driver

Application ObjectsApplication

Virtual Machine(bshell)

Database Driver

Database Server(RDBMS)

Figure 3, Client/Server configuration I

Page 15: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-7

When two machines are available to be used as servers, two configurations arecommonly used. In both configurations, the display drivers reside on the userworkstations. In the first configuration, the application tier is placed on oneserver, while the database driver and the database server are placed on another.As with the previous configuration, an instance of the application virtual machineand at least one instance of the database driver is started for each user. All usershave access to the same application objects and database servers. Thisclient/server configuration is illustrated in Figure 4. This configuration uses theBaanERP method of client/server access between the application virtual machineand the database server.

ApplicationVirtual Machine

(bshell)

Database Driver

Display Driver Display Driver

Application ObjectsApplication

Virtual Machine(bshell)

Database Driver

Database Server(RDBMS)

Figure 4, Client/Server configuration II

Page 16: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database driver overview

Sybase Database Driver Technical Reference Manual

1-8

An alternative configuration with two servers is to place the applications and thedatabase driver on one server and the database server on another. End userworkstations are again linked to the machine with the application virtualmachine. Again, an instance of the application virtual machine and at least oneinstance of the database driver is started for each user. All users have access tothe same application objects and database servers. This client/serverconfiguration is illustrated in Figure 5. This configuration uses the RDBMS’sability to provide client/server access.

ApplicationVirtual Machine

(bshell)

Database Driver

Display Driver Display Driver

Application ObjectsApplication

Virtual Machine(bshell)

Database Driver

Database Server(RDBMS)

Figure 5, Client/Server configuration III

There are many other configurations of client/server systems, including dividingthe application logic among multiple servers or using multiple servers fordistributing the database.

Page 17: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

2-1

All of the application data used by BaanERP is stored in database tables in theRDBMS. To keep the majority of the BaanERP processing independent of theRDBMS, BaanERP uses a data dictionary. The data dictionary includes domain,schema, and referential integrity information that is stored in a databaseindependent manner.

Because so many tables are needed, a convention is used for naming tables,columns within tables, and indexes to data within the tables. This chapterdescribes the data dictionary and the naming conventions used by the BaanERPdatabase drivers to access data stored in the RDBMS. It also discusses howBaanERP data types are mapped to Sybase data types.

The following topics are covered in this chapter:

n BaanERP data dictionaryn Table naming conventionn Column naming conventionn Index naming conventionn Stored procedure naming conventionn Data type mappingn Additional constraints

BaanERP data dictionaryA data dictionary is a catalog that provides information about the data in adatabase. It can be thought of as “data about the data,” or metadata. A datadictionary can be used to find data that resides within a database table.

The BaanERP database drivers maintain a data dictionary because the data usedby the BaanERP applications may differ from the database tables defined in theRDBMS. The BaanERP data dictionary maps BaanERP data types, domains,schemas, and referential integrity information to the appropriate information inthe RDBMS. When storing or retrieving data in the RDBMS, the database drivermaps data dictionary information to database table definitions.

BaanERP data dictionary information can be kept in shared memory where it willbe available to all running BaanERP application virtual machines. The datadictionary information is shared among all the sessions open within a singledatabase driver.

2 BaanERP database organization

Page 18: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-2

The BaanERP data dictionary cannot be used directly by the database driver tocreate Sybase tables. This is because not all BaanERP data types exactly matchSybase data types. To create valid Sybase tables, the driver must perform somemapping or translation. When mapping the BaanERP data dictionary to tables inSybase, conventions are used for the table names, column names, and indexnames.

Table naming conventionThe table name of a BaanERP table stored in Sybase has the following format.

t<Package><DD Table name><Company number>

The following describes each of the components of the table name.

n PackageThe package is a two-letter code that refers to the BaanERP package thatcreated the table. For example, a table created by the BaanERP Toolspackage has the package code tt.

n DD Table NameThe DD table name is the name of the table used in the data dictionary. Thedata dictionary table name consists of three letters followed by three digits.The letters refer to the application that uses the table and the digits indicatethe order in which the tables were created.

n Company NumberWithin BaanERP, three digit company numbers are used to differentiate areasof functionality. There must be a company with the number 000. In addition,there may be several other company numbers.

For example, the data dictionary table adv999 with company number 000 iscreated in Sybase as tttadv999000.

In addition to the conventions described above, the BaanERP database driveruses the owner/tablename convention when accessing tables. If tablettfgld006505 is created by user root, it is accessed as root.ttfgld006505. Ifinstead, the table is created by user bsp, it is accessed as bsp.ttfgld006505.

Page 19: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-3

Column naming conventionEach column in the BaanERP data dictionary corresponds to one or morecolumns in a Sybase table.

The rules for column names are as follows:

n GeneralWhen a BaanERP column name is created in Sybase, it is preceded by thestring t_. For example, the BaanERP column with the name cpac is created inSybase with the name t_cpac. By preceding column names by t_, reservedwords are avoided. If a column name contains a period [ . ], the period isreplaced by the underscore [ _ ] character.

n Long string columnsBaanERP columns of type string can exceed the maximum length ofcharacter columns in Sybase. The Sybase data type CHAR has a limit of 255characters. When a BaanERP string column exceeds this limit, the column issplit into segments with up to 255 characters each. The first 255 charactersare placed in a column where the name of the column is extended with _1.The next 255 characters are placed in a column with a name extended by _2,and so on until all the characters of the string are placed in a column. Forexample, if a BaanERP string column called desc contains 300 characters, thefollowing two Sybase columns are created:

− t_desc_1: size 255− t_desc_2: size 45

n Array columnsIn the BaanERP data dictionary, array columns can be defined. An arraycolumn is a column with multiple elements in the column. The number ofelements is called the depth. For example, a column containing a date can bedefined as an array of three elements—a day, a month, and a year. In Sybase,the three elements of the array column are placed in separate columns. Thenames of these columns include a suffix with the element number. Forexample, an array column called date will become:

− t_date_1: element 1− t_date_2: element 2− t_date_3: element 3

Note that if the element is of type string and one element type exceeds themaximum Sybase character size of 255, it is split. For example:

− t_str_1_1: element 1, part 1− t_str_1_2: element 1, part 2

Page 20: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-4

n Array compressionThe maximum number of Sybase columns is 250. If the number of BaanERPcolumns exceeds the maximum number of Sybase columns, the databasedriver tries to compress (join) array columns to reduce the number ofcolumns. All array elements of one array column are stored as one column inthe Sybase database with the elements concatenated in binary format. Thedriver starts by compressing the array column that yields the highest numberof columns. It continues compressing array columns until the number ofcolumns is less than 250. The name of the compressed column in Sybasefollows the same convention used for the other columns. For example:

− t_array: contains all elements of the compressed column

Note that when a compressed array column is longer than 255 characters, isbe split in segments of 255 characters or less.

Index naming conventionBaanERP indexes are identified by a sequence number for each table, with thesequence numbers starting from one. Each table has at least one index: theprimary index. Sybase requires that for each table, all index names must beunique. For this reason, the index number is included in the index name. Indexnames have the following format:

I<Index Number>a

For example, the index name for index 1 on any BaanERP table is I1a. Forindex 2, the name is I2a, and so on.

Sybase allows descending scans on an index. This means that the same index canbe used for both ascending queries and for descending order queries.

All indexes built by the BaanERP database driver are unique. If an index isdefined as duplicate in BaanERP, it is still made unique by the BaanERPdatabase driver using one of the techniques described below.

n If the index has the hash optimization option, using parts of that indexcombined with parts of the primary index (which is always unique) makes thehash column for that index. Thus each hash column value is unique in thetable because of primary key parts even though duplicate values are specifiedfor that index, and a unique index is created on this column.

Page 21: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-5

n If the hash optimization technique is not used, then a unique composite indexis created on columns of that index and columns of the primary index, whichare not parts of that index. For example, if the primary index is on bothcolumns c1, c2 and the duplicate index is defined on columns c8, c9, c10, theBaanERP database driver actually creates a unique composite index on c8,c9, c10, c1, c2. If another duplicate index is defined on c1, c5, c6 then thatindex is created on c1, c5, c6, and c2. Here, because column c1 is also part ofa duplicate index, it is used only once, in the order sequence of that index andnot as part of the primary index.

Stored procedure naming conventionThe BaanERP database driver can optionally create and use stored procedures forsingleton selects on unique indexes of a table.

For each unique index of a table, a stored procedure is created. The name of thestored procedure is formed as follows:

s<Package><Table_Name><Company_Number><Index_Number>

For example, a stored procedure for table tiitm001, company 812, and index 1, isnamed:

stiitm0018121

There is a variation of singleton select, which is used to lock the record. Thisselect always occurs on primary index of the table. There is an extra storedprocedure is created for doing a select with lock, on primary index. Thisprocedure does a select for update at isolation repeatable read (isolation 2).

The name of the stored procedure is formed as

s<Package><Table Name><Company Number>1L

Note that this name has similar format to the names of procedures created fordirty read isolation. Since this procedure is always created on index 1 (only), andit is used to lock the row, the suffix is always 1L, where L indicates the lockingvariation.

Page 22: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-6

Data type mappingThe following table shows the mapping between BaanERP data types and theirSybase counterparts.

Mapping between BaanERP and Sybase data types

BaanERP data types Sybase data types

CHAR TINYINT

ENUM TINYINT

SHORT SMALLINT

LONG INTEGER

MAIL INTEGER

TIME INTEGER

BITSET INTEGER

FLOAT REAL

DOUBLE FLOAT

STRING CHAR

TSS_STRING CHAR

DATE DATETIME

Note that the BaanERP Sybase driver uses the CHAR data type when ANSI-compliant behavior is expected for character data, such as with the BaanERPstring type. When the CHAR data type is used, operations such as comparisonand concatenation can be done in a predefined manner with predictable results.

Page 23: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-7

Additional constraintsIn addition to the above naming conventions and data types, the following rulesapply when mapping BaanERP data to Sybase data:

n All names generated by the database driver are in lowercase characters, andare not enclosed within double quotation marks. Since the binary sort order isselected during the installation, Sybase treats object names with casesensitivity.

n All columns created by the Sybase driver have the NOT NULL constraint.BaanERP applications do not support NULLS.

n BaanERP applications have internal representations to identify “undefined”values.

n For hash columns, the Sybase data type BINARY is used.

n If a BaanERP index is defined as a unique index, then the Sybase index isalso created with the UNIQUE clause. Otherwise (duplicate) indexes are notdefined with the UNIQUE clause.

n The date range for the BaanERP application virtual machine (bshell) is notthe same as the range for Sybase. When using the Sybase data typeDATETIME the earliest date that can be stored is 1/1/1753 and the latest dateis 31/12/9999. The BaanERP database driver reserves the Sybase minimumdate (1/1/1753) to indicate an unspecified BaanERP date (Date 0). The date1/1/1753 and earlier dates cannot be stored in the BaanERP Sybase database.The database driver returns an error message NOT_IN_RANGE if one ofthese dates is specified.

Page 24: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

BaanERP database organization

Sybase Database Driver Technical Reference Manual

2-8

Page 25: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

3-1

The Sybase database driver converts RDBMS independent database requests intorequests designed specifically for Sybase. This chapter describes some of theinternal processing that occurs within the BaanERP Sybase database driver. First,some of the features that ensure data integrity are discussed. Next, the internalprocessing of a SQL statement within the driver is explained. The final section ofthis chapter describes the mechanisms that allow the default behavior of thedatabase driver to be modified.

In this chapter the following BaanERP Sybase database driver internal issues arediscussed.

n Data integrityn Database driver SQL processingn Setting driver behavior

Data integritySeveral features of the BaanERP database driver help to insure data integrity.These features include locking mechanisms, methods used for insuringreferential integrity, and methods used for distributed databases. In addition, dataintegrity is maintained while minimizing network traffic by using data bufferingtechniques. This section gives an overview of the features used by the BaanERPSybase database driver to ensure referential integrity, to work with distributeddatabases, and to apply data buffering techniques. Locking strategies arediscussed in detail in Chapter 6.

Referential integrity

Referential integrity preserves the defined relationships between tables whenrecords are maintained. The BaanERP database driver has a built-in mechanismfor preserving referential integrity; it does not depend on the underlying RDBMSfor maintaining referential integrity.

Data buffering

Updates can be buffered by the application virtual machine and flushed at thetime of transaction commit, or earlier when necessary. This reduces the numberof network round trips and data volumes.

3 Database driver internal processing

Page 26: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-2

When multiple rows are returned from a query, the rows are buffered and thensent back to the application virtual machine as one block. Data reduction andcompression is applied to minimize the amount of data transferred between theapplication virtual machine and the database driver

Database driver SQL processingAs discussed in Chapter 1, the application virtual machine sends RDBMSindependent database queries and update requests to the database driver. It is upto the database driver to convert these RDBMS independent database requestsinto SQL statements that are appropriate to the specific RDBMS being used. Forexample, the Sybase RDBMS may not support some of the BaanERP operatorsbecause the BaanERP definition of the operator is different from that of theSybase RDBMS. Such expressions are translated by the BaanERP databasedriver into a Sybase ASE equivalent statement that is supported by the SybaseRDBMS. All expressions that can be supported by the Sybase RDBMS arecombined and the database-dependent layer within the BaanERP database drivergenerates a database expression.

This section details the SQL processing performed by the BaanERP Sybasedatabase driver. Because the BaanERP Sybase database driver uses the SybaseOpen Client /C library to communicate with Sybase, the Open Client library willbe described first.

Open Client library

The Sybase driver uses the Open Client /C library to communicate with Sybase.The Open Client library is a function library (or a set of C functions) that can becalled from a C program to execute SQL statements.

The functions called by the Sybase driver perform the following actions:

n Logon to Sybase (open session)n Allocate a command structuren Parse a SQL statementn Binding of input variablesn Binding of output variablesn Execute the SQL statementn Fetch the resulting rowsn Cancel a queryn Commit/abort transactionn Close a cursorn Logoff from Sybase (close session)

Page 27: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-3

SQL processing

SQL statements are dynamically generated by the database dependent layer ofthe BaanERP Sybase database driver. Because BaanERP applications aredynamic, it is not known in advance which tables will be used at run time, henceit is not possible to prepare the queries before run time.

Within the BaanERP Sybase database driver, SQL statements are processed inseveral steps. This section describes these steps.

When the BaanERP Sybase driver receives a query from the application virtualmachine, the query is translated into a format suitable for Sybase, and is passedto Sybase using Open Client library function calls. Within Sybase, a cursor isallocated and the query is executed by assigning it to the cursor. The cursor isopened after the input values are bound to it. Next, a fetch operation is done onthe cursor and the resulting column values are placed in the bound outputvariables. The rows returned by Sybase are passed to the database independentlayer of the BaanERP Sybase database driver, which sends the results back to theapplication virtual machine.

When a statement needs to be re-executed, the cursor from the previousexecution is closed and the resulting rows are discarded (whether the re-execution is with the same input parameters or not). If new input values arerequired, the new values are assigned to the input parameter columns, and thequery is re-executed. When a query is re-executed, the cursor does not need to beredefined. This improves the overall performance.

When array fetching is enabled, the driver uses Open Client library buffering.The Open Client library fetches multiple rows for a fetch call. These rows arebuffered inside the Open Client library and are returned to the driver for futurefetch requests. When the Open Client library buffer is exhausted, it fetches thenext set of rows from the database.

Data can be placed into the database using the BaanERP utility bdbpost6.2. Thisutility is used to place data into a new database table or to append data to anexisting database table.

Setting driver behaviorThere are several facilities available for configuring the BaanERP Sybasedatabase driver. The most common is through driver resources. Two otherfacilities for configuring the BaanERP Sybase database driver are environmentvariables and the storage file. The driver resources and environment variables aredescribed in more detail in Appendix A and the storage file in Appendix B.

Page 28: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-4

Driver resources

The database driver resources are parameters that can be set to modify thebehavior of the BaanERP Sybase database driver. These parameters are set in afile called the resource file (db_resource). There is one resource file for alldatabase drivers that run in a BaanERP environment; resources for all thedatabase driver types can be found there. A database driver reads the parametersset in the resource file when it is first invoked.

The resource file may contain many entries, with one entry per line. Each entry isused to set a single resource parameter, with the resource name followed by acolon and then the value to which the resource is to be set. The following is anexample of the contents of a resource file containing two entries:

dbsinit:01syb_lock_timeout:300

When modifying the behavior of the database driver, it is often necessary tomodify the behavior of the BaanERP application virtual machine to takeadvantage of the characteristics of the database driver. Therefore, there are twotypes of database driver resources: those that are used to modify the behavior ofthe database driver and those that are used to modify the behavior of theapplication virtual machine. Driver resources that are used to modify databasedriver behavior are called resources for the server. Driver resources that are usedto modify behavior in the application virtual machine are called resources for theclient.

In a UNIX environment, the resource file, db_resource, is located in thedirectory $BSE/lib/defaults, where $BSE refers to the directory where theBaanERP software environment is installed. When both the database driver andthe application virtual machine run on the same machine, there will be only onedb_resource file containing all the necessary resources parameters. When thedatabase driver and the application virtual machine run on different machines,there must be one db_resource file located on the machine running the databasedriver that contains the server resources, and one db_resource file located on themachine running the application virtual machine that contains the clientresources.

In addition to the default resource file, db_resource, it is possible to set up analternative resource file to override resource values for specific users or groupsof users. The alternative resource file is specified with the environment variablesUSR_DBS_RES and USR_DBC_RES. USR_DBS_RES is used to specify thepath to a file containing an alternative resource file for the server and must be seton the machine running the database driver.

Page 29: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-5

USR_DBC_RES is used to specify the path to a file containing an alternativeresource file for the client and must be set on the machine running the applicationvirtual machine. Any driver resource set in the alternative resource file willoverride the setting of the same driver resource in db_resource. The next sectiondescribes how to set the database driver environment variables.

Environment variables

Environment variables can be used to override driver resources. Usually, adefault set of resource parameters is configured in the resource file. Theadministrator can override these default settings with environment variables.

For the most part, there is an environment variable corresponding to eachresource parameter. The environment variable name is usually the uppercaseequivalent of the resource parameter name. As with the database driverresources, some environment variables are used to modify the behavior of thedatabase driver (server) and some are used to modify the behavior of theapplication virtual machine (client). When a database driver environmentvariable for the server is to be used, it must be set on the machine running thedatabase driver to override the corresponding driver resource. When a databasedriver environment variable for the client is to be used, it must be set on themachine running the application virtual machine to override the correspondingdriver resource.

Server environment variables

Environment variables that affect the database driver can be used to override thedriver resources for all tables in a database or for specific tables and companynumbers within the database. There are three ways to set the database driverserver environment variables:

n By using the BaanERP sessions Database Definitions (ttaad4510m000) andTables by Database (ttaad4111m000)

n By manually modifying the BaanERP tabledef6.2 file

n By using the standard operating system mechanism for setting environmentvariables

The BaanERP session Database Definitions is the recommended method tomodify database driver behavior. When specific tables and companies are to beconfigured for access with a specific database driver, the session Tables byDatabase should be used. These sessions causes environment variables for aparticular database driver to override the defaults set in the resource file andallow the environment variables to be maintained centrally.

Page 30: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-6

The session Database Definitions maintains database driver configurationinformation in a file called tabledef6.2. This file is stored in the directory$BSE/lib residing on the machine where the database driver runs. While it isrecommended that the Database Definitions session be used to maintain thisfile, advanced users can modify this file manually. The format of the tabledef6.2file is as follows:

<table name>:<company number>:<driver type>(<environment variable>=<value>)

If multiple environment variables are to be specified for a single table andcompany number, they are listed within the parentheses and separated bycommas. If all tables or all companies are to be specified, the asterisk (*) is usedin place of table name or company number. For example, the following entry canbe made in the tabledef6.2 file:

tccom010:812:syb(SYBPROF=0.4)

In this example all the queries on table tccom010812 which require at least0.4 seconds are logged in the SYBPROF file. Note that this table is considered tohave a different database definition from other tables. If a Sybase driver isalready running, but is accessing a different table, a separate driver will bestarted for this table. Environment variables that appear in the driverspecifications of the tabledef6.2 file are put into the driver’s environment beforeit is invoked, so they are available to the driver at startup.

If the default database driver resources must be modified for specific users, thestandard operating system method can be used to set database driver environmentvariables for specific users. These environment variables will override thesettings created in the Database Definitions session for these users.

Client environment variables

Database driver environment variables that affect the client can be used tooverride the client resources that affect the application virtual machine. Theseenvironment variables must be set on the machine running the application virtualmachine and should be set using the standard operating system methods used forsetting environment variables. Any client environment variables that are usedoverride the equivalent resource variables set for the client in the db_resourcefile.

Page 31: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-7

Storage file

The storage file provides a way to specify the distribution of table and index datain different segments. Storage parameters are used by the database driverwhenever a DDL statement such as a create table or create index statement isexecuted. The following is an example of an entry in the storage file:

SEGMENT segment1

In this example, the database driver adds the “on <segment name>” clause to thecreate statement during index or table creation.

A storage file is defined for each database driver. The storage file for theBaanERP Sybase database driver is called syb_storage and is located in thedirectory $BSE/lib/sybase. The format of the storage file is described in detail inAppendix B.

Page 32: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver internal processing

Sybase Database Driver Technical Reference Manual

3-8

Page 33: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

4-1

The BaanERP Sybase database driver maintains security by controlling useraccess to the database and user access to database objects. The BaanERPdatabase administrator (DBA) module allows the DBA to control access to thedatabase using BaanERP sessions. Using the DBA module makes DBA taskseasier and less prone to errors than using database driver tools directly. Thischapter first discusses how the BaanERP Sybase database driver handles issuesrelated to database security. It then briefly describes the DBA module.

The following topics are covered in this chapter:

n Database securityn The DBA module

Database SecurityThere are two aspects of database security: object security and authentication.Object security refers to the process of determining whether or not a user whohas access to the database is authorized to access particular database objects.Authentication refers to the process of determining whether or not a user isauthorized to access the database. Both object security and authentication use theconcept of groups to ensure security. This section first describes the groupconcept, then describes how the BaanERP Sybase driver provides object securityand authentication.

Groups

In any RDBMS, a group is defined as a collection of database users. All usersassigned to a group are granted the same database privileges. Once a group isdefined with a certain set of privileges, users can be assigned to that group. Usinggroups simplifies management of a large number of users with commonrequirements.

A BaanERP group consists of a database name and methods for providing objectsecurity and authentication within the database. The BaanERP group name is thesame as the name of the database that holds the BaanERP data within theRDBMS. The BaanERP group uses the mechanisms of the RDBMS to provideobject security and authentication.

4 Database security

Page 34: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database security

Sybase Database Driver Technical Reference Manual

4-2

A BaanERP group is a superset of the usual RDBMS group in that it includes notonly the RDBMS group, but also the database name and an RDBMS login.

In Sybase, a BaanERP group is made up of three components: a database, aSybase login (for authentication) and a Sybase group (for object security). TheSybase database has the same name as the BaanERP group. The login is the samename as the BaanERP group and is assigned database owner (DBO) privileges inthe database. A Sybase group is created which becomes the target for privilegesgranted on objects in the database. Users are added to the Sybase group and, as aresult, inherit the privileges granted to the Sybase group. The advantage ofhaving a group table is that the members of the group can share and operate onthe same data in a single table.

For example, users maria and john can both be assigned to BaanERP groupbaandb. Group baandb owns the tables and grants select, insert, delete, andupdate privileges to the Sybase group. As a result, users maria and john inheritthe select, insert, delete, and update privileges granted to the Sybase group,allowing them to access and manipulate BaanERP group table data.

The BaanERP user is shielded from the RDBMS groups. The database driverdoes all the processing that is needed to make use of the RDBMS groups. Onlythe database administrator needs to be concerned about the RDBMS groups, andthe BaanERP DBA module allows the administrator to easily maintain theRDBMS groups.

Object security

In Sybase, when a user creates an object such as a table, the user becomes theowner of that object, and only the owner can access the object. Other users canonly access the object if they have been granted privileges to do so. In aBaanERP environment where many users access the same tables in the Sybasedatabase, a mechanism has been developed to allow users to share these tables.

To allow different BaanERP users to share the same Sybase table, the groupconcept is used. A BaanERP group maps users to a database in Sybase andensures that members of the BaanERP group have sufficient privileges to accessand update data in the BaanERP group’s tables.

The BaanERP Sybase driver uses a Sybase group to implement the BaanERPgroup concept. Whenever a new table is created by the BaanERP group user,select, insert, delete, and update privileges are granted to the Sybase group. Anyuser associated with the Sybase group automatically inherits these privileges andcan individually perform these operations on the BaanERP group table.

Page 35: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database security

Sybase Database Driver Technical Reference Manual

4-3

When new users are added, they need only be added to the Sybase group; theyautomatically inherit all privileges currently granted to the Sybase group withoutneed to grant privileges on every object in the database to the user. When theuser is dropped from the Sybase group, these privileges are revoked. The user nolonger has access to tables within that Sybase group. If the privileges to operateon the tables are explicitly granted to the user, then they must also be explicitlyrevoked when the user is dropped from the Sybase group. The overhead ofadding users is greatly reduced by granting privileges to the Sybase group. Thisalso provides flexibility and ease of maintenance.

A user can define whether a table should be created as a group table or as aprivate table. When a table is identified as a private table, the user becomes theowner and no privileges are given to other users. When a table is identified as agroup table, the table is created by the group login and the privileges are grantedto the group, allowing all users in the group to access the table. A table can beconfigured as private or group via the file $BSE/lib/sybase/syb_storage.

In the DDL statements generated by the driver, object names are qualified by theowner name. When creating objects identified as belonging to the group, the usercreating the object logs into Sybase as the group user. In this case the table willbe owned by the group and permissions will be granted on it to allow all groupusers access. When creating objects identified as private, users are connected toSybase under their own login. When private objects are created, the user ownsthem; no other permissions are granted.

A table’s configuration is defined in the file $BSE/lib/sybase/syb_storage. Theconfiguration includes whether it was created as a private or a group table. Theformat of the storage file is explained below. The keywords group or privatecan be specified in the appropriate field. For example:

{maria,john}tdsfc:*:T:group:011::{anne}tdsfc:*:T:private:011::

This indicates that users maria and john create tables in module tdsfc as grouptables and user anne has her own private tables in module tdsfc.

Authentication

The database driver maps BaanERP users to Sybase user accounts to allow themto establish a connection to Sybase and access data. To prevent unauthorizedusers from accessing the database, non-mapped users cannot establish aconnection to the database. When a database is created, a Sybase systemadministrator (sa) creates a login for the user and associates the user with aSybase group in the database that has object privileges. The group usercorresponds to the target database.

Page 36: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database security

Sybase Database Driver Technical Reference Manual

4-4

The members belonging to this group inherit the group privileges and are able toestablish a connection to the database either via unified login or using a validpassword stored in encrypted form in the driver administration files.

A user can be added to or dropped from the group by using the BaanERP DBA(database administration) module. Users who are authorized to access thedatabase are registered in the BaanERP driver administration files. The username and password each BaanERP user will use to log on to Sybase ismaintained in the file $BSE/lib/sybase/syb_users. Here, $BSE refers to theBaanERP software environment (BSE), the directory where the BaanERPsoftware was installed.

All the BaanERP users and their corresponding Sybase logon names andpasswords and the name of the group they are assigned to are defined in the file$BSE/lib/sybase/syb_users. The format of each entry in this file is as follows:

<BaanERP user>:<Sybase user>:<Encrypted Sybase user password>:<BaanERP group name>

The BaanERP Sybase driver is started by the BaanERP application virtualmachine on behalf of the user. From the file $BSE/lib/sybase/syb_users thedriver identifies the Sybase user and the user’s password and establishes theconnection to Sybase.

The group logon procedure also includes a password, which is defined in the file$BSE/lib/sybase/syb_groups. The format is as follows:

<Group name>:<Encrypted Group password>

DBA moduleThe DBA module maintains the database administration files used by the Sybasedatabase driver. This module allows an administrator to register authorized usersand to give users access to data. A tool is provided with the BaanERP Sybasedatabase driver to maintain the administration files that the database driver needsat run time. The administration files are stored in the directory $BSE/lib/sybase.

The DBA module implements the user and group administration functions for allBaanERP database drivers. The SYB_MAINT utility is an executable programcalled by the DBA module that implements the functions necessary to makechanges in Sybase. While it is possible to call the SYB_MAINT utility fromoutside the DBA module, this is not recommended because the users and groupsfiles are not modified by SYB_MAINT.

The DBA module is described in more detail in the BaanERP document SybaseInstallation Guide for BaanERP on UNIX (U7081A US).

Page 37: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

5-1

The BaanERP Sybase database driver provides a facility for monitoring systemperformance. These include a profiling facility that allows the user gather timinginformation for SQL statements, and a statistics facility for gathering driver-widestatistics. In addition, the driver provides a facility for troubleshooting problems.In this chapter, the profiling, statistics, and debugging features of the BaanERPSybase database driver are discussed.

The following topics are covered in this chapter:

n Profilingn Gathering statisticsn Troubleshooting

ProfilingThe database driver allows users to log timing aspects and statistics. This isuseful for tuning because the information may help to identify performancebottlenecks and can give input into the tuning process.

The database driver’s profiling option provides the user with a way to gather thetiming of SQL statements that are being executed. Logging all statements withtheir timings, however, will result in a log file that is so large it cannot beproperly analyzed. It is possible to define a logging threshold where onlystatements that take more than a predefined number of seconds are logged.

With profiling, the following information is logged: the RDBMS request, theelapsed time, the user name, the date, and the time. The maximum precision thatcan be specified is 0.01 seconds.

To determine which table actions are most time consuming you can set theSYBPROF environment variable to a number of seconds. For example,SYBPROF can be set as follows:

SYBPROF=5.0

This sets SYBPROF to five seconds, causing statements that takes more than 5.0seconds of elapsed time to be logged to the file sybprof. The file sybprof isstored in the directory where the driver was started.

5 Database driver profiling andstatistics

Page 38: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-2

An alternate way to set SYBPROF is to set it in $BSE/lib/tabledef6.2 file asfollows:

*:*:sybase(SYBASE=/usr1/sybase,SYBPROF=0.4)

This sets the value of the SYBPROF variable to 0.4 seconds. Actual profiling isperformed for selective tables. Tables for which profiling is required, shouldhave the PROFILE variable in their corresponding storage file entry. Forexample, after setting the above value in the tabledef file, if profiling is requiredfor all BaanERP finance tables, then for these tables, the storage file entry can beas follows.

tf:*:T:group:011:10:PROFILE*:*:T:group:011::

In this case, profiling is performed only on the finance tables. For any financetable, if a select takes more than 0.4 seconds, an entry is generated.

Note that if two tables have different SYBPROF values a separate BaanERPdatabase driver will be started when the second table is accessed. Differentprofile values can be specified in tabledef file, such as:

tfgld005:*:sybase(SYBASE=/usr1/sybase,SYBPROF=0.1)tfgld006:*:sybase(SYBASE=/usr1/sybase,SYBPROF=0.2)*:*:sybase(SYBASE=/usr1/sybase)

Note that the following two statement types are timed and can appear in the logfile:

n The execute eventThis represents the amount of time the RDBMS takes to execute an SQLstatement.

n The fetch eventThis represents the amount of time it takes to retrieve data from the buffer orthe RDBMS.

Page 39: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-3

A sample SYBPROF file is shown below.

Profiling value = 0.00 secPid Table Owner I Mode Cache Exe Fetch Exe Fetch Tot<11350> tiitm001812 jim 1 FIRST : - 0.01 0.00 - - 0.04< 8024> tiitm001812 jim 1 FIRST : - 0.01 0.00 - - 0.05<11350> tiitm001812 jim 1 FIRST : 0.00 - - - - 0.00<11350> tiitm001812 jim 1 FIRST : 0.00 - - - - 0.00<11350> tiitm001812 jim 1 FIRST*: - 0.01 0.00 0.01 0.00 0.06< 8024> tiitm001812 jim 1 FIRST*: - 0.00 0.05 0.00 - 0.10<11350> tiitm001812 jim 1 NEXT : - - 0.00 - - 0.00<11350> tiitm001812 jim 1 NEXT : - - 0.00 - - 0.00<11350> tiitm001812 jim 1 NEXT : - - 0.00 - - 0.00<11350> tiitm001812 jim 1 NEXT : - - 0.00 - - 0.00<11350> tiitm001812 jim 1 NEXT : - - 0.01 - - 0.01<11350> tiitm001812 jim 1 NEXT* : - - 0.01 0.01 0.00 0.02<11350> tiitm001812 jim 1 NEXT* : - - 0.00 0.01 0.00 0.01<11350> tiitm001812 jim 1 PREV : - 0.00 1.02 - - 1.05<11350> tiitm001812 jim 1 PREV : - - 0.01 - - 0.02<11350> tiitm001812 jim 1 PREV : - - 0.00 - - 0.016

The data in the above sample file can be interpreted as follows:

n In this example, the number of seconds (profiling value) is 0.00. This meansthat all actions are written to the file.

n The asterisk [*] after some of the records indicate that the records were firstread and then locked.

n The I column lists the number of the index used.

n The Cache column lists a value when a result is retrieved from cachememory.

n For each action, two executes and two fetches are recorded. This is usefulwhen a record must be read in locked mode or when only key fields areselected first and then the other fields are retrieved.

Statement execution time can be viewed for individual tables by setting theSYBPROF environment variable in the file $BSE/lib/tabledef6.2. For example,the following entry can be made in the file:

tccom010:812:syb(SYBPROF=0.4)

In this example all the queries on table tccom010812 which require more than0.4 seconds are logged in the sybprof file. Note that a separate driver is startedfor this table; the table is considered to have a different database definition.

Page 40: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-4

Effect of optimization

The BaanERP database driver has a single record cache. If the row is fetchedfrom the cache, no query is executed. In the following example, both db.equalswere performed with the same key value. For the first command, a query wasexecuted and the result was fetched. For the next command, since the record wasin cache, it was used from the cache and no execute and fetch was required.

The record id the cache is indicated by the entry in the Cache column and noentries in any Exe or Fetch columns.

After executing an ascending sequence query such as db.first or db.great, if thenext query is db.next, the query is fetch optimized. There is no execute stage,only a fetch stage. Similarly after a descending sequence query such as db.last ordb.less, if the next query is db.prev, the query is fetch optimized.

Gathering statisticsThe database driver provides an option to gather driver-wide statistics on actionsperformed, such as:

n Number of cursors (opened, closed, current open)n Number of parses, binds, executes, fetchesn Number of logons (sessions)n Number of inserts, updates, deletesn Number of commits, rollbacks

For each action, the cumulative elapsed time spent and the average time islogged. Gathering statistics can be enabled with an entry in the tabledef file$BSE/lib/tabledef6.2 or with the environment variable SYBSTAT.

Enabling statistics from the tabledef file

To enable statistics from the tabledef file, set the value of the SYBSTATvariable in the $BSE/lib/tabledef6.2 file. The tabledef entry can look like:

.:sybase(SYBASE=/dbms/sybase,SYBSTAT=45)

The value of the SYBSTAT variable is the time interval in seconds during whichstatistics are accumulated. A fractional value cannot be specified.

For tables that require statistics, there should be a STATISTICS variabledefined in their storage file entry. If, for example, statistics is to be enabled forall itm tables, then the storage file can look like:

tiitm:*:T:group:011:10:STATISTICS

Page 41: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-5

Now statistics are enabled for all itm tables. Statistics are accumulated for each45-second period as specified in the tabledef file, and at the end of each periodthe statistics are written into a text file. This file is called sybstat and is createdin the directory where the BaanERP database driver was started.

Enabling statistics with the environment variableSYBSTAT

When the variable is set to zero, a statistics report is generated when the driverterminates (exit from BaanERP Tools or session). When a value n greater thanzero is specified, the driver logs an incremental report every n seconds (thedriver must be active). The statistics report is written to the file SYBSTAT in thecurrent directory.

The following are examples of how SYBSTAT can be set:

SYBSTAT=30export SYBSTAT

In the first example, SYBSTAT is set to zero. With this value, only a final reportis generated. In the second example, SYBSTAT is set to 30. This logs a reportevery 30 seconds while the driver is active. The statistics report is logged in thefile sybstat in the current directory.

Page 42: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-6

Below is a sample output of SYBSTAT. Since the report is generic for alldatabases, some information, such as the specific row actions, may not beappropriate for a particular database driver.

<26752> 98-03-30[13:39:14]: Statistics [interval = 10]

C U R S O R S Opened Closed Parse Bind Define Execute FetchCount 156 150 61 0 38 308 626Time(s) 0.03 0.01 0.42 0.00 0.01 0.97 1.19Avg 0.00 0.00 0.01 0.00 0.00 0.00 0.00

D A T A B A S E First Last Next Prev Curr Great Gteq Equal Less Eqle Equal*Count Read 4 0 345 160 0 20 73 36 16 43Cached Read 0 0 0 0 0 0 0 6 0 0 29Fetched Read 0 0 345 160 0 0 0 0 0 0Executed Read 4 0 0 0 0 20 73 30 16 43 65Time(s) Read 0.04 0.00 0.56 0.28 0.00 0.15 0.55 0.15 0.12 0.27Avg Read 0.01 0.00 0.00 0.00 0.00 0.01 0.01 0.00 0.01 0.01

Count Lock 0 0 0 0 0 0 0 94 0 0Time(s) Lock 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.48 0.00 0.00Avg Lock 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 0.00 0.00

Insert Delete UpdateCount Exe 11 29 0Time(s) Exe 0.06 0.14 0.00Avg Exe 0.01 0.00 0.00

CrIdx DrIdx ChOrd CrTbl ClTbl DrTbl LkTbl NrRowCount Exe 0 0 80 0 4 0 0 0Time(s) Exe 0.00 0.00 0.00 0.00 0.12 0.00 0.00 0.00Avg Exe 0.00 0.00 0.00 0.00 0.03 0.00 0.00 0.00

Commt Rolbk RdOnl PrCmt NotAcCount Exe 22 46 0 0 0Time(s) Exe 0.06 0.35 0.00 0.00 0.00Avg Exe 0.00 0.01 0.00 0.00 0.00

S U M M A R Y Count Time(s) AvgTotal asc read (s) 442 1.30 0.00Total desc read (s) 219 0.67 0.00Total exact read (s) 130 0.62 0.00Total all read (s) 791 2.59 0.00Total updates (s) 40 0.20 0.01

Count PercTotal cache hit (%) 35 4.42Total fetch opt (%) 505 63.84

CountForced close 0Current open cursors 6Sessions (logon/logoff) 2 / 0

Page 43: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-7

CURSORS gives statistics about cursor actions. This includes the total numberof times an action is performed, the total time required for those actions andaverage time required per action.

DATABASE gives statistics about all read actions, all read-with-lock actions, allinsert, delete, update and transaction actions. For SELECT actions, theoptimization (fetch optimization or fetched from cache) is also counted.

The tuning options are:

n Index optimization, 1 column (that is, single hash)n Key only optimizationn Extend refresh timen Separate data from indices in tablespaces

TroubleshootingThe BaanERP Sybase database driver provides a facility for troubleshootingproblems. The actions performed by the driver can be traced and stored in a logfile. In addition, any errors that occur are logged. The following sections explainhow to log trace information and how to find and interpret the error log.

Error reporting

The Sybase RDBMS performs error detection and reporting at two levels:

n Sybase ASE Errorsn Sybase Client-Library Errors

These two error-handling mechanisms operate independently of each other andhave their own error reporting mechanisms via callback routines, which can beuser supplied. The BaanERP database driver installs callback routines for theSybase messages and the client library messages.

When a SQL command is executed, the following combinations can occur:

n No ASE error. No client-library error. This means that the command wassuccessfully executed. See the section on “Limitations” for exceptions.

n ASE error. No client-library error. This means that the command executionfailed.

n Client-library error. No ASE error. This means that the command executionfailed.

Page 44: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-8

Steps for analyzing errors

The Client-Library error entries in the log file are identified by the keywordCTLIB_ERROR. The Sybase error entries in the log file are identified by thekeyword SQL_ERROR.

If you receive a generic error (one not defined in the BaanERP environment),such as 3812, then subtract 1000 from this error code to get the actual errornumber. Then check the error log for the entry with the actual error code. Theerror message text can help to locate the problem.

Logging database driver trace information

The database driver provides an option to trace online information about theactions that are being performed by the driver. The resulting log file containsdebugging information that can help solve problems.

When tracing is enabled, the information stored in the log files includes:

n Table and index information (data dictionary)n The SQL statements being executedn Values of the input and output bind variablesn Other function-level debug statements

Tracing can be enabled using the environment variable DBSLOG. Debugginginformation is appended to the file dbs.log in the UNIX directory $BSE/tmp.Tracing can be enabled by entering the following command:

SET DBSLOG=1570

Several tracing categories are defined so that tracing can be enabled for only categories ofinterest. See Appendix A for more details.

Logging errors

In a UNIX environment, the driver logs its error messages in the log file in the$BSE/log directory. The log file is called log.sybase.

The following information can be retrieved from the log files.

n The user name, date, time, source file, and line numbern The function calledn The error code returned by the databasen The database error descriptionn The BDB error code returned to the applicationn The failing SQL statement, in some cases

Page 45: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-9

When a database error occurs, an attempt is made to map it to some known oranticipated error condition. Generally, these mapped BDB errors havecorresponding error numbers falling in the range of 1 to 1000. If a databasespecific error occurs, it is mapped to the BDB error code over 1000 with thefollowing formula:

abs(error_code) + 1000

So, if an error -1652 occurs, BDB error 2652 is returned to the application.

In most cases, the log entries from the display driver, application virtualmachine, and database driver contain enough information to determine the natureof and solution to the problem. Whenever an error is encountered with an errorcode greater than 1000, you are advised to check the log entries from thedatabase driver.

The BaanERP database driver logs all errors which could not be mapped toapplication errors into the log file $BSE/log/log.<driver name in tabledef>. If adatabase driver is defined as sybase in tabledef, all related errors are logged infile $BSE/log/log.sybase. The log entry consists of error number and errormessage text. Such errors are called generic errors.

Page 46: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver profiling and statistics

Sybase Database Driver Technical Reference Manual

5-10

Page 47: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

6-1

The BaanERP Sybase database driver is designed to allow tuning for optimalperformance. Several parameters used by the database driver are preset withdefault values that should provide acceptable system performance, but sinceevery environment is different, the default values of these parameters may notprovide optimal performance. This chapter discusses the BaanERP Sybasedatabase driver parameters that can be set, and the changes in driver behaviorthat you can expect when you adjust these parameters.

The following topics are covered in this chapter:

n Optimizationn Cursor managementn Array interfacen Index optimizationn Fetch optimizationn Row cachingn Optimistic and pessimistic reference checksn Isolation levelsn Transaction Managementn Locking behaviorn High level lock retries

OptimizationIn principle, for every database action, the database driver can construct a SQLstatement and send it to Sybase where it is parsed and executed. When the nextrequest arrives, this cycle is repeated. In fact, this cycle uses an enormousoverhead to execute all these steps for each command. If each action wasexecuted in this manner, performance would be very slow. Instead, the BaanERPdatabase driver uses various techniques to speed up performance.

6 Database driver configuration andtuning

Page 48: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-2

These techniques are based on the observations of the client applicationsdescribed below.

n Selects are the most common actions on a table, followed by updates, inserts,and deletes. Further, there are a fixed number of types of select, such as first,last, great, less, gteq, eqle, next, prev, equal, curr and their counterparts withthe lock option. Table level actions, such as create table, drop table, or cleartable, are infrequent. So, the Sybase RDBMS database administrator shouldattempt to optimize the select commands.

n Generally when a table is accessed, more than one row from a set in that tableis read. There are exceptions such as checking a reference where only onedb.equal is performed. Another example is after performing db.first ordb.great many times, the BaanERP application performs db.next until somecondition occurs. Similarly after performing db.last or db.eqle, frequentlydb.prev is executed.

Index optimizationIndex optimization is a technique used in Level 1 drivers to obtain betterperformance for SELECT statements in relational databases. Because BaanERPLevel 1 drivers generate queries that are not very complex, the driver can takeadvantage of several attributes of BaanERP application tables to improve accesstime. The index optimization technique causes a new column (referred to as ahash column) to be created in the table for each index defined in the BaanERPdata dictionary. This hash column contains a concatenation of values from eachcolumn participating in the key for that index. Also, the first (or primary) index isalways unique, so it can be used (again concatenated) in other non-uniqueindexes to make them unique. Finally, a raw data type can be chosen as thestorage type for the hash column. The combination of key reduction(concatenation into a single column) and index uniqueness has been found togive performance gains in Level 1 drivers.

In addition, sophisticated optimizers in RDBMSs tend to overanalyze theseLevel 1 queries in an attempt to optimize their execution, so the driver exploitsany means available in the host RDBMS to reduce the effort needed for theoptimizer to arrive at an acceptable execution plan.

Page 49: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-3

In BaanERP applications, an index can consist of multiple columns(concatenated keys). When you retrieve data in the order of the index, the firstcolumn in the index is considered most significant, the last part is consideredleast significant. Each column has its own significance within the order. Thisconcept is common to all Level 1 database drivers. BaanERP also requiressignificance of the columns in the WHERE clause, which means that you shouldtreat each column differently.

As an example, consider Table A with columns t_col1, t_col2, and t_col3, all oftype integer, and an index on t_col1, t_col2, and t_col3. The table contains fiverows.

Example table A containing the following five rows

col1 col2 col3

0 0 0

0 0 1

0 1 2

1 2 1

1 2 3

Suppose we want the rows that are greater than the first row: {0, 0, 0}. Thecorrect query to solve this would be:

SELECT col1, col2, col3 FROM AWHERE(col1 > 0 OR col1 = 0 AND(col2 > 0 OR col2 = 0 AND(col3 > 0)))ORDER BY col1, col2, col3

We see that this query contains a nested list of AND/OR conditions, which ingeneral cannot be efficiently optimized by the RDBMS. As a result, when thereare multiple columns in an index and there are many rows in the table, theRDBMS servers spend a long time searching all the rows that meet the condition.This causes considerably slower performance.

The way to solve this problem is called index optimization. This means that inthe example above, the three columns col1, col2, and col3 are concatenated andadded to the table as a separate column. This additional column is called the hashcolumn, and it contains a sortable value of the three concatenated column values.An index is created on the hash column. For our example table, this results in thefollowing table. Note that the hash value is simplified for the example.

Page 50: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-4

Example table A with additional hash column

col1 col2 col3 hash1

0 0 0 “000”

0 0 1 “001”

0 1 2 “012”

1 2 1 “121”

1 2 3 “123”

When searching for rows greater than {0, 0, 0}, we can now specify thefollowing query, including the hash column:

SELECT col1, col2, col3 FROM AWHEREhash1 > “000”ORDER BY hash1

This query is much simpler and can be quickly evaluated by the optimizer. Notethat there is always just one condition in the WHERE clause.

Duplicate indexes

For duplicate indexes, the primary key parts are appended to the hash column tomake it unique. In this way, a distinction is made between an ascending anddescending sorting order through the duplicate rows. The order as such, however,is not defined; the only distinction made is between ascending and descending.

Hash optimization

Consider table1 with columns c1, c2, c3, c4, c5 having a composite index 1 onc2, c4, c5. The index is created as:

create unique index I1a on table1( c2, c4, c5 )

When a user wants to execute a db.first on this table, the required query lookslike:

select * from table1where c2 > ? or ( c2 = ? and ( c4 > ? or c4 = ? and ( c5 > ? ) ) )order by c2, c4, c5

Because of the presence of “or “ clause in the “where” clause of the above query,the DBMS query optimizer may decide to perform a sort, which degrades theperformance. However, the sort can be avoided if the index is made on singlecolumn.

Page 51: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-5

For this purpose, a hash column is used. The hash column is an additionalcolumn in the table. It has a value that is obtained by concatenating all the keycolumn values using an algorithm. The index is created on this column (insteadof the original key columns). Thus the index consists of single column and thesearch time is reduced.

When a hash column is used, the index is created as follows:

create index I1a on ... ( hash1 ).

Then our query looks like:

“select ... where hash1 >= ? order by hash1 asc”.

This eliminates sort and results in a faster query. This optimization is called hashoptimization

If a hash column is made unique, the index is also unique, further improvingqueries. The BaanERP application always enforces the unique primary key. If anon- primary key is duplicate, the BaanERP database driver still makes its hashcolumn values unique by using columns of the primary key with current keycolumns, when computing the hash column values. So every hash column andevery index is made unique, irrespective of its definition in the BaanERP datadictionary.

Hash column naming convention

A hash column is created for an index when the index has hash optimization. Foreach index with hash optimization, an extra column is created in the table. Thename of the hash column in a BaanERP application table is formed using thehash keyword and the index number for which it is being created. For example,the hash column for index 1 will be named hash1; the hash column for index 2will be named hash2.

Page 52: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-6

Size of hash columns

The size of the hash column is determined by the data types and sizes of all thecolumns in the index. The table below demonstrates the contribution of each datatype to the size of the hash column.

Relationship between data types and size of hash column

Data type Size of hash column

CHAR 1

CHAR(n) n

SHORT 3

DATE 4

LONG 5

FLOAT (digv + diga + 2) / 2

DOUBLE (digv + diga + 2) / 2

Where digv is the number of digits before the decimal point and diga the numberof digits after the decimal point.

If the index is a composite, the size of the hash column is the total of the sizerequired for each column in the index. For example, if the index consists of aLONG column and a CHAR column, then the hash column size is 6 (5 + 1).

If the index has single hash optimization, then the index has one such column. Ifthe index has double hash optimization, two such columns are created.

Specifying index optimization

Index optimization can be specified per table and per index in the$BSE/lib/sybase/syb_storage file. To specify whether index optimizationshould be used, the following (octal) values are available:

0000 No optimization0001 Optimization using 1 hash columns0010 Use stored procedures

You can define the default value for each table in a table [T] entry. Any value inan index [I] entry overrides the table default. If there is no entry for a specifictable, the default value is 000.

You can combine the key only optimization with hash optimization values byadding the octal values.

Page 53: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-7

Fetch optimizationIn BaanERP, it often occurs that a set of rows is retrieved from a table in thedatabase. Usually an application is doing the following sequence:

DB.FIRSTDB.NEXTDB.NEXTDB.NEXT

When a query is processed after fetching the first row, the subsequent rows arefetched from the retrieved set of rows and are returned to the user. Thistechnique, combined with the isolation level or locking strategy employed,determines how current the data is during a read operation. On-demand readscombined with dirty read locking gives the most current view of the data.However, in many situations this behavior is not required. Read performance canbe improved at the expense of a less current view of the data.

Fetch optimization is described as follows. After fetching the first row of a querywith a multi-row result set, subsequent rows satisfying the query are also fetchedand returned to the client. Rows updated or deleted in other concurrentconnections between fetches may not be reflected in this set of rows. Thechanges made in other concurrent connections will only be reflected when thequery is re-executed. A user may not need to see all row changes at the exactmoment they occur, and could simply fetch the next row from the existing(buffered) row set, instead of re-executing the statement to get the most currentview. This technique is referred to as fetch optimization.

Critical to the use of this technique is the definition of a refresh time that allowsthe user to specify a time interval, in seconds, for which a fetch-optimized set ofrows is valid. As long as the set is deemed valid, data can be fetched from thebuffered row set. Changes that occurred as a result of activity in otherconnections since the query was executed are not reflected in the data. If the rowset expires (that is, refresh time is exceeded), the statement will automatically bere-executed in the driver before the next row is returned.

For example, let’s assume that a set of rows is retrieved when DB.FIRST isissued. For a refresh time of five seconds, the DB.NEXT call will fetch the nextrow from the fetch-optimized set of rows. All consecutive DB.NEXT calls withinfive seconds will not fetch from the database, but will be fed from the bufferedrow set until the buffer is exhausted. After five seconds the set will be consideredinvalid and a subsequent DB.NEXT will cause a re-execute of the query andfetch from the database. This results in a performance improvement by reducingthe number of query executions. This translates into reduced RDBMS server loadand reduced network traffic.

Page 54: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-8

You can set the refresh time for tables (T entries) in the storage file. For index (I)entries, the refresh field is ignored. The default is 0 if not specified.

For example, the syb_storage file can contain the following entries:

*:*:T:group:011:5:*:*:I:group:011::

In the above example, all tables and companies will use single hash columns forindex optimization and a refresh time period of five seconds for fetchoptimization.

The following example shows two entries that might be set in the syb_storagefile:

*:*:T:group:011::*:*:I:group:011::

In this example, all the tables have a default refresh time of 0 seconds, meaningthat fetch optimization is disabled.

Fetch optimization is useful when there are several records in the result set and afetch next action takes place within the refresh interval, or if the entire table islocked by the query.

Row cachingRow caching is based on the fact that the last retrieved result (using fetch) isstored in a single-row cache. When two consecutive database requests are exactlyidentical, the result can be copied from a single-row cache. A restriction is thatthe second action takes place within the refresh time. This situation occursfrequently when joins are processed. Every time the outer row contains the samekey value, a DB.EQ on the outer table can be cached, so the request will not bepassed to the RDBMS.

Note that caching and fetch optimization are consistent for one BaanERP user.Database changes made in any of the sessions running within a single applicationvirtual machine (bshell) will always disable current sets related to the update.Consequently, additional fetches will always fetch the new result. The changesmade by other users will not be reflected within the refresh time.

Page 55: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-9

Stored proceduresThe Sybase driver uses client library cursors to do selects. Each session usesseveral cursors to perform selects. A cursor can not be shared across sessions.When a cursor is declared, several commands need to be sent from the databasedriver to Sybase. Sybase also has to parse and compile the select statement Thisincreases network traffic as well as CPU requirements for Sybase.

The BaanERP database driver provides the option of using stored proceduresinstead of cursors for most frequent type of selects. In the BaanERPenvironment, singleton selects such as db.equal() are good candidates for storedprocedure usage. The stored procedures are used for unique indexes of a table.

For a table, stored procedures are specified by OR-ing the flag 010 to the indexoptimization flag in storage file $BSE/lib/sybase/syb_storage. For example, forhash column (001), 011 can specify stored procedures.

Stored procedures are created when the table is created. After creating the table,the BaanERP database driver creates procedures for all the indexes on that table,which are defined as unique in BaanERP. The BaanERP database driver does notcreate procedures on duplicate indexes as defined in BaanERP. The reason is thatduplicate indexes performed by the client do not result in db.equal() in theBaanERP database driver. Hence the BaanERP database driver never makesdb.equal() on a duplicate index and the stored procedure for that index is notrequired.

When the table is dropped, all stored procedures for that table are dropped.

If a user decides to use stored procedures for existing tables, the user shouldupdate the storage file $BSE/lib/sybase/syb_storage to indicate storedprocedure usage and continue using the applications. When the driver tries to usea stored procedure on a table and finds the stored procedure is missing, it willcreate the stored procedures on the fly. There will be no error returned to theapplication, which will keep on working, now using the stored procedures.

A sample procedure is listed below.

create procedure dbo.saabdb9990001 @khash1 binary(3) asselect t_byte, t_int, t_date, t_long, t_string,t_refcntd, t_refcntu, hash1from dbo.taabdb999000 ( Index I1a )where hash1 = @khash1at isolation 0

Page 56: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-10

Optimistic and pessimistic reference checksTo optimize concurrency, the BaanERP Sybase database driver supportsoptimistic and pessimistic reference checks. In lookup reference mode, wheninserts are performed in a child table, the driver checks whether the referenceexists in the parent table and locks the referenced record to be sure that anotheruser cannot delete it within the current transaction. This approach is called thepessimistic approach.

This approach blocks an insert of another user referencing the same parent row,thereby affecting the concurrency. To avoid this problem there, is also anapproach where a row in the parent table that is not locked is used dependingupon the choice of the user. This approach is called the optimistic approach. Asthe record is not locked, another user can still perform an insert operation, whichimproves the concurrency. Enabling of this option is configurable via the dbsinitresource variable.

Isolation levelsSybase provides four isolation levels for SELECT actions. These isolation levelsare dirty read, committed read, repeatable read, and holdlock. When theBaanERP Sybase database driver performs a SELECT WITHOUT LOCK query,the dirty read isolation level is used. When the BaanERP Sybase database driverperforms a SELECT WITH LOCK query, the repeatable read isolation level isused.

To update a lock, the BaanERP Sybase database driver uses the FOR UPDATEclause. If the FOR UPDATE clause is not specified, a shared lock is used. With ashared lock, users can lock the same row with SELECTs, causing deadlock whenother queries try to UPDATE or DELETE. When a deadlock occurs, thetransactions involved in the deadlock are rolled back. This reduces throughput. Ifthe FOR UPDATE clause is used, an update lock is obtained by the first query,blocking all other queries until the first query releases the lock, avoidingdeadlocks.

Page 57: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-11

Transaction managementThe BaanERP Sybase database driver does not use the Sybase ANSI chainedtransaction mode. Instead, the driver starts an explicit transaction when any ofthe following actions are requested:

n Select with lockn Lock tablen Insert rown Update rown Delete rown Clear table (delete all rows)

Once a transaction is started, it lasts until either the application commits or abortsthe transaction or an error forces Sybase to abort the transaction. When Sybaseaborts the transaction, the database driver notifies the application.

Locking behaviorSybase provides the following lock granularities for tables:

n All Page LockingPage locks are used for data and index pages. This is the default mode when atable is created, unless a different lock mode is specified. This lock mode isthe same what was used in earlier versions of Sybase.

n Data Page LockingPage locks are used for data pages. Index pages are not locked.

n Data Row LockingRow locks are used for data rows. Indexes are not locked.

In the BaanERP environment, the lock mode can be specified for a table in thestorage file $BSE/lib/sybase/syb_storage. Different lock modes can be specifiedfor different tables. If a lock mode is not specified for a table, the driver createsthe table with data row locking.

Sybase provides a lock timeout feature. A user, blocked on a lock, can wait for acontrolled interval to obtain the lock.

Page 58: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Database driver configuration and tuning

Sybase Database Driver Technical Reference Manual

6-12

High-level lock retriesWhen a row lock cannot be acquired, high-level lock retries are initiated by theBaanERP application virtual machine. This means that the same action isperformed after a sleep period. The retry pattern can be defined by environmentvariable LOCK_RETRY or resource variable lock_retry. This can contain acomma, separated list of combinations of number of retries and sleep periods inmilliseconds (ms), for example:

LOCK_RETRY=”5*100,5*500”

or

lock_retry:”5*100,5*500” (resource variable)

This is the default retry pattern, which means that the action is retried 5 timeswith a sleep period of 100 ms and then 5 times with a sleep period of 500 ms.The lock retries can also be disabled by specifying:

LOCK_RETRY=”0”

or

lock_retry:”0”

This is a feature common to all database drivers. Since Sybase provides a locktimeout feature, it is not advisable to use BaanERP lock retries.

Page 59: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

7-1

This appendix lists all the database driver resources and environment variablesthat can be used as configuration parameters to modify the behavior of theSybase database driver. Some of these resources are used with the client andothers with the server. In this context, the client is the BaanERP applicationvirtual machine and the server is the BaanERP Sybase database driver. If theBaanERP application virtual machine and the database driver are running ondifferent machines, client resources must be set on the machine running theBaanERP application virtual machine and server resources must be set on themachine running the database driver. Resources for both the client and the servermust be set on both machines.

A description of how to set the database driver resources and environmentvariables can be found beginning on Page 3-3.

This appendix provides the following information:

n Summary of Sybase resources and environment variablesn Detailed description of Sybase resources and environment variables

Summary of Sybase resources andenvironment variablesThere are four types of resources and environment variables that can be usedwith the BaanERP Sybase database driver:

n Client and server resources used by all BaanERP database driversn Client resources used by all BaanERP database driversn Server resources used by all BaanERP database driversn Resources used only by the BaanERP Sybase database driver

The following four tables provide a summary of each of these types of resourcesand environment variables. Detailed descriptions of each entry in the tables canbe found beginning on Page 7-3.

7 Appendix A: Database driverresources and environment variables

Page 60: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-2

Client and server resources used by all BaanERP database drivers

Resource name Environment variable Description

rds_full RDS_FULL Sets maximum number of rows transferred inone block

tt_sql_trace TT_SQL_TRACE Allows viewing of SQL query information

use_shm_info USE_SHM_INFO Enables or disables shared memory use

Client resources used by all BaanERP database drivers

Resource name Environment variable Description

bdb_debug BDB_DEBUG Sets debugging link between client and server

bdb_driver BDB_DRIVER Sets database specifications

bdb_max_server_schedule

BDB_MAX_SERVER_SCHEDULE

Defines mechanism for terminating idledatabase drivers

ssts_set_rows SSTS_SET_ROWS Sets number of rows read ahead (single tablesingle row)

USR_DBC_RES Specifies alternative resource file for client

Server resources used by all BaanERP database drivers

Resource name Environment variable Description

bdb_max_session BDB_MAX_SESSIONS Defines number of sessions per driver

bdb_max_session_schedule

BDB_MAX_SESSION_SCHEDULE

Defines mechanism for closing idle driversessions

dbslog DBSLOG Allows driver profiling

DBSLOG_LOCK_PROF Specifies lock time above which locks arelogged

DBSLOG_NAME Allows file name to be specified for logging

dbsinit Specifies optimistic or pessimistic referencechecking

enable_refmsg ENABLE_REFMSG Causes logging of denied updates of deleteactions

lock_retry LOCK_RETRY Defines the number of lock retries and thesleep period between retries

USR_DBS_RES Specifies alternative resource file for server

Page 61: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-3

Resources used only by the BaanERP Sybase database driver

Resource name Environment variable Description

syb_char_set SYB_CHAR_SET Sets alternative character set

syb_con_max_prepares

SYB_CON_MAX_PREPARES

Modifies limit to number of cursors allowed perconnection

syb_init SYB_INIT Defines which Sybase version is being used

syb_lock_timeout SYB_LOCK_TIMEOUT Sets lock timeout

syb_login_timeout SYB_LOGIN_TIMEOUT Modifies length of login timeout

syb_max_connections

SYB_MAX_CONNECTIONS

Sets maximum number of connections toSybase

syb_misc_options SYB_MISC_OPTIONS Specifies several options

syb_national_lang SYB_NATIONAL_LANG

Sets language for error messages

SYBPROF Allows profiling

SYBSTAT Allows statistics to be gathered

syb_tds_packet_size

SYB_TDS_PACKET_SIZE

Sets packet size for TDS protocol

Detailed description of Sybase resources andenvironment variablesThis section provides detailed information about the BaanERP Sybase driverresources and environment variables. The driver resources are divided into twosections: those that are generic to all BaanERP database drivers and those thatare specific to the BaanERP Sybase driver. Each group of resources is listed inalphabetical order.

Page 62: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-4

Generic driver resources

bdb_debug / BDB_DEBUG

Driver resource bdb_debug

Environment variable BDB_DEBUG

Client/Server resource Set for client only

Type Integer (octal)

Default 0

Description This variable is used to generate debugginginformation about the communication between theclient and the database driver. When set, the clientprints debugging information to standard error (stderr).The following categories of debugging information canbe specified:

00001 server types

00002 database actions

00004 delayed lock actions

00010 reference information

00040 TSS info from $BSE/lib/tss_mbstore

00100 permission information

Multiple categories can be defined by adding the octalvalues. The value is compared bitwise to determine if agiven category should be logged.

bdb_driver / BDB_DRIVER

Driver resource bdb_driver

Environment variable BDB_DRIVER

Client/Server resource Set for client only

Type String

Default None

Description This variable is used to set a database specification,usually found in the file tabledef6.2. When this variableis set, all tables will be accessed using the databasedriver specified and tabledef6.2 will not be read. Thedriver specified must be defined in the file$BSE/lib/ipc_info.

Page 63: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-5

bdb_max_server_schedule / BDB_MAX_SERVER_SCHEDULE

Driver resource bdb_max_server_schedule

Environment variable BDB_MAX_SERVER_SCHEDULE

Client/Server resource Set for client only

Type Integer

Default 3

Description This variable defines the mechanism for terminatingidle database drivers by the application virtual machine.Whenever the database driver has no more opensessions, it can be terminated by the application virtualmachine. Closing an idle database driver is done aftera number of schedule ticks. A schedule tick isgenerated whenever a BaanERP session is ended. Atthis point, all idle database drivers will have a schedulecounter incremented. When the value of the schedulecounter reaches the value ofbdb_max_server_schedule, the database driver isterminated.

bdb_max_sessions / BDB_MAX_SESSIONS

Driver resource bdb_max_sessions

Environment variable BDB_MAX_SESSIONS

Client/Server resource Set for server only

Type Integer

Default 0 (unlimited)

Description This variable defines the number of sessions per driver.If any driver has reached this threshold, a new driverwill be started to handle any new sessions.

Page 64: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-6

bdb_max_session_schedule / BDB_MAX_SESSION_SCHEDULE

Driver resource bdb_max_session_schedule

Environment variable BDB_MAX_SESSION_SCHEDULE

Client/Server resource Set for server only

Type Integer

Default 3

Description This variable defines the mechanism for closing idlesessions in the driver. Whenever the client process hasno more references (cursors or queries) to the session,it can be closed by the client. Closing an idle session isdone after a number of schedule ticks. A schedule tickis generated whenever a BaanERP session is ended.At this point, all idle sessions will have a schedulecounter incremented. When the value of the schedulecounter reaches the value ofbdb_max_session_schedule, the session is closed

The default for bdb_max_session_schedule is three.Setting bdb_max_session_schedule to one wouldresult in fewer connections from the driver to theRDBMS since whenever a BaanERP session is ended,the corresponding RDBMS session (logon) is closed(logoff).

Page 65: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-7

dbsinit

Driver resource dbsinit

Environment variable —

Client/Server resource Set for server only

Type Integer (octal)

Default 0

Description This variable allows flags to be set to specify theoptimizations to be used. At this time, legal values are000 (not set) and 001. Other values are reserved andshould not be used.

A flag of 00001 specifies that an optimistic approachshould be used when checking for references in parenttables. The referenced row in the parent table is notlocked, improving the overall concurrency. If this flag isnot set, optimistic reference checking is not used.Optimistic and pessimistic reference checks aredescribed on Page 6-10.

Other values are reserved for future use and should notbe used. Multiple categories can be defined by addingthe octal values. The value is compared bitwise todetermine if a given category should be logged.

Page 66: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-8

dbslog / DBSLOG

Driver resource dbslog

Environment variable DBSLOG

Client/Server resource Set for server only

Type Integer (octal)

Default 0

Description This variable provides detailed debugging informationabout the online processing of the driver. Theinformation is logged in the file dbs.log in the driver’scurrent directory. The following debugging categoriescan be specified:

0000001 Data Dictionary information of tables withinthe driver

0000002 Query info (SQL Level 1)

0000004 Query plan info (SQL Level 2)

0000010 Row action information

0000020 Table action information

0000040 Transaction action information

0000100 DBMS input/output data (SQL Level 2)

0000200 Administration file info (SQL drivers)

0000400 DBMS SQL statements

0001000 General debug statements

0002000 Query processing info (for tt_sql_trace info)

0004000 Data buffering info (communication)

0100000 Lock retries logged (includes session name)

0200000 Logs successful locks and longest lockduration in a transaction

Multiple categories can be defined by adding the octalvalues. The value is compared bitwise to determine if agiven category should be logged.

Page 67: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-9

DBSLOG_LOCK_PROF

Driver resource —

Environment variable DBSLOG_LOCK_PROF

Client/Server resource Set for server only

Type Floating point number

Default 0

Description Specifies the minimum duration of a lock that should belogged. Any locks of shorter duration will not be logged.This variable specifies the minimum number ofseconds, to a precision of milliseconds, that shouldelapse before a lock is logged. Lock time is calculatedas the time from when the first record in a transaction islocked to the time of the commit or abort. This is thelongest time a record remains locked during atransaction. Please note that the appropriate dbslogcategories must be set.

DBSLOG_NAME

Driver resource —

Environment variable DBSLOG_NAME

Client/Server resource Set for server only

Type String

Default dbs.log

Description Allows a file name to be specified where DBS logginginformation is to be written. If there is already a file withthe same name, it will be used for logging. If the file islocked during write operations, multiple servers canuse the same log file.

Page 68: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-10

enable_refmsg / ENABLE_REFMSG

Driver resource enable_refmsg

Environment variable ENABLE_REFMSG

Client/Server resource Set for server only

Type Boolean

Default 0 (disabled)

Description There are two valid values for this variable: 0 and 1.When it is set to 1, a log message is generated in thedatabase driver log file when an update of a deleteaction has been denied because of existing references.When it is set to 0, no log messages are generated.

lock_retry / LOCK_RETRY

Driver resource lock_retry

Environment variable LOCK_RETRY

Client/Server resource Set for server only

Type String

Default 5*100,5*500

Description This variable defines the high-level locking behaviorthat is used when an action is locked. It defines thenumber of retries and the length of the sleep periodsbetween retries in milliseconds (MS). For example, forthe default setting, the action is retried five times with asleep period after each try of 100 MS. The action isthen retried five more times with a sleep period of 500MS after each retry.

Page 69: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-11

rds_full / RDS_FULL

Driver resource rds_full

Environment variable RDS_FULL

Client/Server resource Set for both client and server

Type Integer

Default 5

Description This variable defines the maximum number of rowstransferred between the BaanERP application virtualmachine and the driver as one block. Multiple blocks(and thus network round trips) are transferred if morerows are requested. This variable should be set to thesame value for both client and server.

ssts_set_rows / SSTS_SET_ROWS

Driver resource ssts_set_rows

Environment variable SSTS_SET_ROWS

Client/Server resource Set for client only

Type Integer

Default 3

Description This variable defines the number of rows to be readahead for a fetch request from the client. The default isthree rows, which means that for one fetch request,three rows will be read. For the following two fetchrequests, rows will be taken from the client row bufferor fetched from the database without re-executing thequery.

Page 70: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-12

tt_sql_trace / TT_SQL_TRACE

Driver resource tt_sql_trace

Environment variable TT_SQL_TRACE

Client/Server resource Set for both client and server

Type Integer (octal)

Default 0

Description This variable is introduced to view the BaanERP SQLquery information being handled in client and server.When this variable is set, the client prints debuginformation to the display; the server prints informationonly if the dbslog variable allows it. The informationcontains different categories which can be enabledseparately, such as evaluation trees, SQL statements,bind variables, timings, and communication debugging.The possible values of the TT_SQL_TRACE variableand their descriptions are shown below:

000040 (c) Show queries with their QID

000200 (c) Show query execution times

002000 (c) Show calls of internal SQL functions

004000 (c+s) Show query execution tree

010000 (s) Show query evaluation plan

020000 (s) Show FullTableScan

use_shm_info / USE_SHM_INFO

Driver resource use_shm_info

Environment variable USE_SHM_INFO

Client/Server resource Set for both client and server

Type Boolean

Default 1 (enabled)

Description This variable can be used to enable or disable the useof shared memory to each of the database driver DDs.There are two valid values for this variable: 0 and 1.When it is set to 0, shared memory is disabled. When itis set to 1, shared memory is enabled.

Page 71: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-13

USR_DBC_RES

Driver resource

Environment variable USR_DBC_RES

Client/Server resource Set for client only

Type String

Default None

Description This variable contains the file specification of analternative resource file for the client. The filespecification is based on the BSE directory and iswithin double quotes. When set, any resources in thealternative resource file override the same clientresources set in db_resource.

USR_DBS_RES

Driver resource

Environment variable USR_DBS_RES

Client/Server resource Set for server only

Type String

Default None

Description This variable contains the file specification of analternative resource file for the client. The filespecification is based on the BSE directory and iswithin double quotes. When set, any resources in thealternative resource file override the same serverresources set in db_resource.

Page 72: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-14

Sybase driver specific resources

syb_char_set / SYB_CHAR_SET

Driver resource syb_char_set

Environment variable SYB_CHAR_SET

Client/Server resource Set for server only

Type String

Default Not set

Description If a character set is specified using this variable, theBaanERP database driver turns on the conversionbetween this set and the Sybase character set.

syb_con_max_prepares / SYB_CON_MAX_PREPARES

Driver resource syb_con_max_prepares

Environment variable SYB_CON_MAX_PREPARES

Client/Server resource Set for server only

Type Integer

Default 256

Description The client library allows an unlimited number of cursorsto be defined and an unlimited number of statements tobe prepared in one connection. Cursors andstatements take resources and the BaanERP databasedriver can run out of memory if there is no limit kept onthese parameters.

By default, the BaanERP database driver never allowsthe total number of cursors and statements in aconnection to be more than 256. If a connection needsto prepare more statements or define more cursors,existing statements and cursors are first freed. Use thisvariable to change that limit to another value.

Note that setting the value too high results in morememory allocated in the BaanERP database driver andother Sybase resources, such as the procedure cache,and it may run out of memory. Setting the value too lowleads to frequently re-preparing statements and re-declaring cursors, which results in poor performance.

Page 73: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-15

syb_init / SYB_INIT

Driver resource syb_init

Environment variable SYB_INIT

Client/Server resource Set for server only

Type Integer

Default Not set (Sybase ASE 11.5 assumed)

Description The BaanERP Sybase database driver can operatewith Sybase ASE 11.5 as well as Sybase ASE 11.9.There are significant differences between ASE 11.5and ASE 11.9. By default, the driver assumes that theunderlying Sybase DBMS is ASE 11.5. When used withSybase ASE 11.9, the resource variable syb_initshould be set to the value 01. If it is not set, SybaseASE 11.5 is assumed.

If ASE 11.9 is used, but syb_init is not set, the driverwill exhibit ASE 11.5 behavior. This will work, but willnot be optimized. On the other hand, if syb_init is setto 01 and underlying DBMS is ASE 11.5, driver willreturn errors and will not work properly.

syb_lock_timeout / SYB_LOCK_TIMEOUT

Driver resource syb_lock_timeout

Environment variable SYB_LOCK_TIMEOUT

Client/Server resource Set for server only

Type Integer

Default 300

Description By default, the client library waits forever for a requestto complete. The BaanERP database driver sets atimeout of 300 seconds by default. This resourcevariable can be used to set the timeout to some othervalue in seconds. Note that setting the timeout to zero(infinite waiting) is not recommended. Setting this valuetoo low may result in spurious timeouts, especially on abusy server.

Note that Sybase ASE 11.9 provides server based locktimeouts. When used in a Sybase ASE 11.9environment, this timeout is not used for the client. Thelock timeout is set in server, and is used to abort acommand that fails to obtain a lock. The client defaulttimeout is used for Sybase ASE 11.9.

Page 74: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-16

syb_login_timeout / SYB_LOGIN_TIMEOUT

Driver resource syb_login_timeout

Environment variable SYB_LOGIN_TIMEOUT

Client/Server resource Set for server only

Type Integer

Default 60

Description The default login timeout used in the client library is 60seconds. Use this resource to specify a higher logintimeout value. The resource syb_login_timeout is aninteger value that represents the number of seconds toset for the login timeout.

syb_max_connections / SYB_MAX_CONNECTIONS

Driver resource syb_max_connections

Environment variable SYB_MAX_CONNECTIONS

Client/Server resource Set for server only

Type Integer

Default 25

Description By default, the client library allows 25 connections froma single process. This variable can be used to changethat value.

Page 75: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-17

syb_misc_options / SYB_MISC_OPTIONS

Driver resource syb_misc_options

Environment variable SYB_MISC_OPTIONS

Client/Server resource Set for server only

Type Integer (octal)

Default 0

Description Use this variable to specify various options for theBaanERP database driver. These options are octalvalues and multiple options can be specified byperforming an OR operation of individual values. Thefollowing describes each of these options.

001A value of 001 causes the BaanERP database driver toexecute the SET SHOWPLAN ON statement at thestart of each connection. The Sybase server returns aquery execution plan to the BaanERP database driver.The BaanERP database driver writes this informationto the dbs.log file if the 01000 flag is set in dbslog.

002A value of 002 changes the default behavior of Sybasedriver for network buffering. By default, the BaanERPdatabase driver disables TDS packet buffering in theSybase client library. In most cases, this leads to betterperformance at the cost of higher network traffic. Thisflag enables buffering in the client library. Note that thisflag affects the client side and does not affect theSybase server. Note that Sybase also has the option todisable the buffering on the server side by turning onthe configuration option tcp no delay.

004A value of 004 causes the BaanERP database drivernot to force indexes for SELECT queries (by default,the BaanERP driver forces index on SELECT queries).Note that if stored procedures are created on a tablewhen this flag is set, the procedures do not force anindex in the query.

Page 76: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-18

syb_national_lang / SYB_NATIONAL_LANG

Driver resource syb_national_lang

Environment variable SYB_NATIONAL_LANG

Client/Server resource Set for server only

Type String

Default Not set

Description If this resource variable is set, the BaanERP databasedriver uses the specified language for error messages.

SYBPROF

Driver resource —

Environment variable SYBPROF

Client/Server resource Set for server only

Type Floating point

Default Not set

Description When a value is specified in this variable, anystatement that takes more than the number of secondsspecified will be logged. The maximum precision thatcan be specified is 0.01 seconds. This variable is usedto determine which table actions are the most timeconsuming.

SYBSTAT

Driver resource —

Environment variable SYBSTAT

Client/Server resource Set for server only

Type Integer

Default Not set

Description This variable allows database driver statistics to bereported. If it is set to a value n greater than 0, statisticsare logged every n seconds while the driver is active. Ifit is set to 0, a statistics report is generated when thedriver terminates.

Page 77: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-19

syb_tds_packet_size / SYB_TDS_PACKET_SIZE

Driver resource syb_tds_packet_size

Environment variable SYB_TDS_PACKET_SIZE

Client/Server resource Set for server only

Type Integer

Default 512

Description This specifies the packet size of the TDS protocol usedby the Sybase client library and the Sybase ASE forcommunication. By default, the packet size is 512bytes. Use this variable to define the increase in thepacket size used by the client library. Increasing thepacket size can boost performance.

When the client side packet size is increased, theSybase ASE maximum packet size should also bechanged. Set the Sybase ASE options max networkpacket size and default network packet size to allowlarger packets.

Sybase environment variablesThe following environment variables can be set to control the actions of Sybasedirectly. They must be set before accessing Sybase.

n SYBASE refers to the directory where the Sybase RDBMS is installed.

n DSQUERY is the name of the Sybase server to be used. The value set forthis variable should exist in the interface file. See the Sybase RDBMSInstallation and Administration Manuals for more information about theinterface file. If this is not set, use the default name Sybase.

Page 78: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix A: Database driver resources and environment variables

Sybase Database Driver Technical Reference Manual

7-20

Page 79: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

8-1

This appendix discusses the formats and configuration options of the storage file,the users file, and the groups file. This appendix includes information on thefollowing topics:

n Storage filen Users and groups files

Storage fileThe storage file provides a way to specify the distribution of table and index datain different segments. Storage parameters are used by the database driverwhenever a DDL statement such as a create table or create index statement isexecuted. The following is an example of an entry in the storage file:

SEGMENT tableseg

In this example, the database driver adds the “in <tablespace name> index in<index tablespace name>” clause to the create statement during index or tablecreation. If the tablespace for a table or index is not specified, the table and indexdata are created in the default segment. If index data is to be separated, it isnecessary to specify a tablespace.

A storage file is defined for each database driver. The storage file for theBaanERP DB2 database driver is called syb_storage and is located in thedirectory $BSE/lib/sybase.

The entries in the syb_storage file consists of fields that are the same for thestorage files for all database drivers and storage parameters that are specific tothe DB2 database driver. This appendix describes the fields that make up theentries in the syb_storage file.

The storage file consists of one or more entries, each consisting of several fieldsseparated by colons. The format of an entry in the storage file is as follows:

[{<user list>}]<table/module specification>:<company number>:<object type>: <private |group>:<table/index optimization>:<refresh time>:<storage parameters>

8 Appendix B: Database driver fileformats and configuration options

Page 80: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-2

The following describes each of the fields in an entry in the storage file.

Storage file field descriptions

user list

Description This field consists of a list of comma-separated usernames to which this entry applies. When no list isspecified, the entry applies to all users.

Example {maria,john}

table/module specification

Description This field consists of a list of comma-separated tablenames or a module name to which the entry applies.An asterisk (*) indicates all tables.

Example ttadv000,ttadv999 two specific tables

ttadv all tables in module tt and packageadv

tt all tables in module tt

* all tables

company number

Description This field consists of a list of company numbers towhich the entry applies. An asterisk (*) indicates allcompany numbers.

Example 000,999 companies 000 and 999

* all companies

Page 81: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-3

object type

Description This field consists of a list of object (table or index)identifications to which the entry applies. The followingoptions can be specified:

T table only

I all indexes

I <index number> only specified index

* both table and indexes

Example I1,I2 only index 1 and 2

T only for table

private | group

Description This field identifies the owner of the table. Eitherprivate or group should be specified.

table/index optimization

Description Specific flags related to indexes and tables can bespecified. When specified on a “T” object entry, itdefines the default for all indexes.

The following octal values can be used to set the flagsfor a specific index or table:

0000 Use no hash columns

0001 Use single hash optimization

0010 Use stored procedure for singleton select onunique index

Default values can be defined for each table entry.Optimizations are explained in more detail inChapter 6.

Example 0001

Page 82: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-4

refresh time

Description This specifies the amount of time (in seconds) that aretrieved dataset is considered valid. No fetch from thedatabase will be made if the same request is madewithin this time.

Example 5

Page 83: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-5

storage parameters

Description These are defined by the specific database driverimplementation and often map to table and index creationoptions available in the host RDBMS.The following Sybase storage parameters are defined:

CURSROWCOUNTThe client library can provide buffering for rows. Whenperforming a fetch on a cursor, it is possible to fetch multiplerows from Sybase to the client library internal buffers. Thesubsequent fetches return the data from client librarybuffers, rather than Sybase. This parameter specifies thenumber of rows that the client library fetches internally whenthe database driver performs a fetch on the cursor. Thedatabase driver still gets a single row but subsequentfetches get data from the client library and not from Sybase,which is faster. This is useful when fetch optimization isperformed.

STATISTICSThis parameter enables the statistics feature of the databasedriver for the table. See Page 5-4 for more information.

PROFILEThis parameter enables the profiling by database driver forthis table. See Page 5-1 for more information.

CLUSTEREDThis parameter specifies that the primary index for the tableshould be clustered. Although Sybase RDBMS allows anyindex of the table to be clustered, it makes sense to keep themost frequently used index as clustered. So the databasedriver makes only the primary index clustered. Use theSEGMENT parameter if the primary index is going to beclustered.

ROWSPERPAGEThis parameter specifies the max_rows_per_page factorfor table or indexes. When creating clustered indexes, thedatabase driver ignores this parameter. Note thatmax_rows_per_page and fillfactor are mutually exclusiveparameters and only one of these should be specified for anindex.

FILLFACTORThis parameter specifies the fill factor for the index. Notethat fillfactor and max_rows_per_page are mutuallyexclusive parameters and only one of these should bespecified for an index.

PREFETCHThis parameter is used to specify a prefetch kilobyte size fora query. This is used when the index is forced. The validvalues are 2, 4, 8 or 16.

Page 84: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-6

CACHEThis parameter is used to force a cache strategy, forexample, “mru” or “lru” in selects.

SEGMENTThis parameter specifies the segment on which the table orindex should be placed. Indexes can be located on asegment different from the segment on which the table iscreated. The only exception is a clustered index, which, byormats and configuration options8-5Appendix B: Databasedriver file formats and configuration options8-6Appendix B:Database driver file formats and configurationt on which theindex is created. To avoid this effect, the database driveralways creates a clustered index on the same segment asthat of the table. For non-primary indexes or for a non-clustered primary index, a SEGMENT other than tablesegment can be used.

LOCKMODESybase ASE 11.9 provides various locking modes for tables.The Sybase driver uses “datarows” locking mode as default,when creating tables. The locking mode can be changedusing LOCKMODE option in the storage file. This optiontakes three values: “allpages”, “datapages”, and “datarows”.Note that “datarows” is the default behavior.

Once a table is created with any lock mode, updating thestorage file will not change the lock mode for the table. Afterupdating the storage file, the table needs to be dropped andrecreated, to change the lock mode.

Examples In the following example, the table and primary index arecreated on the default segment; other indexes are createdon the segment indexsegment.

tiitm001:*:T:group:011:0:tiitm001:*:I:group:011:0:SEGMENT indexsegmentCLUSTERED

In the following example, the table and primary indexes arecreated on the segment tablesegment; other indexes arecreated on the segment indexsegment.

tiitm001:*:T:group:011:0:SEGMENT tablesegmenttiitm001:*:I:group:011:0:CLUSTERED SEGMENTindexsegment

In the following example, the table is created on the segmenttablesegment; all indexes are created on the segmentindexsegment.

tiitm001:*:T:group:01:0:SEGMENT tablesegmenttiitm001:*:I:group:01:0:SEGMENT indexsegment

Page 85: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-7

The storage file is scanned from the beginning whenever a create table orcreate index is performed. The first entry that matches the table or indexis taken, so the order in which the entries are specified is important. Forexample:

{maria,john}ttadv999,ttadv000:000:T:private:011:5:SEGMENT mydatasegmentCLUSTERED{maria,john}ttadv999,ttadv000:000:I::011:5: SEGMENT myindexsegmenttdsfc:505:::011:5:*:*:T:group:011:5:SEGMENT datasegment CLUSTERED*:*:I:group:011::SEGMENT indexsegment

In the example above, the users maria and john will create tables ttadv999and ttadv000 of company 000 in segment mysegment. The associatedindexes will be created in segment myindexsegment and index 1 will be aclustered index. All users creating tables in module tdsfc will create tablesand indexes in the default segment. Other users create tables and indexesin segments datasegment and indexsegment, respectively, with index 1being a clustered index.

If the segment for a table or index is not specified, the table and indexdata are created in the default segment. If you want to separate the indexdata, you must specify a segment.

Users and groups filesThe Sybase database driver maintains a users file and a groups file for databaseadministration. These files are stored in the following directories:$BSE/lib/sybase/syb_users and $BSE/lib/sybase/syb_groups.

It is recommended that you use the BaanERP DBA Module to make any changesto the information in the users or groups files.

The users file

The BaanERP Sybase database driver uses the users file to connect to the Sybaseusers file. The user file contains information on all BaanERP users on the systemwho use the BaanERP Sybase database driver. Each line in this file is made up ofthe following four fields, each separated by a colon (:).

<BaanERP User>:<Sybase User>:<Sybase User Password>:<User Group>.

NOTE:

NOTE:

WARNING:

Page 86: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-8

These four fields are described as follows:

n BaanERP UserThis is the value set for the variable $USER.

n Sybase UserThis is the Sybase login for the database that is accessed. This can bedifferent from the BaanERP user name. BaanERP users cannot share theSybase login.

n Sybase User PasswordThis is the password assigned to the Sybase user while creating a Sybaselogin. The BaanERP Sybase database driver uses this password to log intoSybase. The password is stored in encrypted form.

n User GroupThis is the group to which the BaanERP user belongs.

A sample user file is shown below.

acp:acp:MyNO?%H$h9/Bnc9yb/@2‘(llU=8:4Wbj:financeacr:acr:\‘$YW/k\RfbL^<qhM<vxk3Dhm2ayV^]7:financegld:gld:>9~[{’EOu^UA,)[(vt\MTw3y=AhTdPgK:financesls:sales:N$x’1$xHoY+^5hm[.:7JQx-;B(=>@,^/:tradepur:purchase:KqJeZwD@PC6d3Z+KojKb,;/utq%0nJa+:tradet1:tool1:jkfjkdjkjkjd3Z+KojKb,;/utq%0nJa+:toolst2:tool2:KqJjsfjkjsdfj*and#ojKb,;/88890nJB-:tools

The users in this sample user file are listed in the following table.

Explanation of sample user file

BaanERP user Sybase user Group

acp acp finance

acr acr finance

gld gld finance

sls sales trade

pur purchase trade

t1 tool1 tools

t2 tool2 tools

Note that the Sybase user can be different from the BaanERP user, and thatmultiple BaanERP users cannot share a Sybase user.

This file is created and maintained by the DBA Module. The DBA module isdescribed in the BaanERP document Sybase Installation Guide for BaanERP onUNIX.

Page 87: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-9

The groups file

The BaanERP Sybase database driver uses the groups file to connect to theSybase groups file. This file contains information on all groups used by allBaanERP users who use the BaanERP Sybase database driver. Each line in thisfile is made up of the following two fields, which are separated by a colon (:).

<Group Name>:<Group Password>

These four fields are described as follows:

n Group NameThis is the name used by the BaanERP Sybase database driver to login toSybase when performing table-level actions such as: create table, or droptable for group tables. This is a Sybase login and the login is the owner of adatabase of the same name.

n Group PasswordThis is the password assigned to the group when a Sybase login was createdfor it. The password is in encrypted form. The BaanERP Sybase databasedriver uses this password when it performs a login as a group.

A sample file is shown below:

finance:5tT’”I*/qmn;7cORtYP:8*Hksop*9‘g6trade:ESMQ3Ti(khD‘@@a+,y”75+B5andNEno<f”tools:B8jkj8%*’jkjlkjsKJLJkjRjjkJLjlUt

Here the groups file contains the groups finance, trade and tools.

This file is created and maintained by the DBA Module. The DBA module isdescribed in the BaanERP document Sybase Installation Guide for BaanERP onUNIX.

Page 88: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix B: Database driver file formats and configuration options

Sybase Database Driver Technical Reference Manual

8-10

Page 89: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Sybase Database Driver Technical Reference Manual

9-1

This appendix lists the SQL queries generated by the BaanERP Sybase databasedriver for the various selects. In the examples, the following table is used:

Table: t_byte, t_int, t_float, t_long, t_string, t_date,t_doublePrimary index: t_byte, t_intDuplicate index: t_long

The BaanERP Sybase database driver uses the “force index” option of the SybaseASE optimizer and specifies the index name for select queries. When theduplicate index has no hash optimization, it uses the primary index parts to forcethe select order.

No Hash optimization

Unique index

SELECT_FIRST, SELECT_GTEQselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 (Index I1a )where t_byte > @kt_byte OR t_byte = @k2t_byte AND (t_int >= @kt_int)order by t_byte ,t_intat isolation 0

SELECT_NEXT, SELECT_GREATselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index I1a)where t_byte > @kt_byte OR t_byte = @k2t_byte AND (t_int > @kt_int)order by t_byte ,t_intat isolation 0

SELECT_EQUALselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index I1a)where t_byte = @kt_byte AND t_int = @kt_intat isolation 0

9 Appendix C: BaanERP Sybasedatabase driver SQL queries

Page 90: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix C: BaanERP Sybase database driver SQL queries

Sybase Database Driver Technical Reference Manual

9-2

SELECT_LAST, SELECT_EQLEselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index I1a )where t_byte < @kt_byte OR t_byte = @k2t_byte AND (t_int <= @kt_int)order by t_byte DESC,t_int DESCat isolation 0

SELECT_PREV, SELECT_LESSselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index I1a )where t_byte < @kt_byte OR t_byte = @k2t_byte AND (t_int < @kt_int)order by t_byte DESC,t_int DESCat isolation 0

SELECT_EQUAL_WITH_LOCKselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index I1a )where t_byte = @kt_byte AND t_int = @kt_intfor updateat isolation 2

Duplicate Index

SELECT_FIRST, SELECT_GTEQselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 ( Index 2a)where t_long >= @kt_longorder by t_long ,t_byte, t_intat isolation 0

SELECT_GREATselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 (Index 2a)where t_long > @kt_longorder by t_long ,t_byte, t_intat isolation 0

SELECT_LAST, SELECT_EQLEselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 (3)where t_long <= @kt_long order by t_long DESC,t_byte DESC,t_int DESC

Page 91: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix C: BaanERP Sybase database driver SQL queries

Sybase Database Driver Technical Reference Manual

9-3

SELECT_LESSselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntufrom dbo.taabdb996000 (3)where t_long < @kt_long order by t_long DESC,t_byte DESC,t_int DESC

Hash optimization

Unique Index

SELECT_FIRST, SELECT_GTEQselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a)where hash1 >= @khash1order by hash1at isolation 0

SELECT_NEXT, SELECT_GREATselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a)where hash1 > @khash1order by hash1at isolation 0

SELECT_EQUALselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a)where hash1 = @khash1at isolation 0

SELECT_LAST, SELECT_EQLEselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a)where hash1 <= @khash1order by hash1 DESCat isolation 0

Page 92: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix C: BaanERP Sybase database driver SQL queries

Sybase Database Driver Technical Reference Manual

9-4

SELECT_PREV, SELECT_LESSselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a)where hash1 < @khash1order by hash1 descat isolation 0

SELECT_EQUAL_WITH_LOCKselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash1from dbo.taabdb996000 (Index I1a )where hash1 = @khash1for updateat isolation 2

Duplicate Index

SELECT_FIRST, SELECT_GTEQselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash2from dbo.taabdb996000 (Index 2a)where hash2 >= @khash2order by hash2at isolation 0

SELECT_NEXT, SELECT_GREATselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash2from dbo.taabdb996000 (Index 2a)where hash2 > @khash2order by hash2at isolation 0

SELECT_LAST, SELECT_EQLEselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash2from dbo.taabdb996000 (Index I2a)where hash2 <= @khash2order by hash2 descat isolation 0

Page 93: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix C: BaanERP Sybase database driver SQL queries

Sybase Database Driver Technical Reference Manual

9-5

SELECT_PREV, SELECT_LESSselect t_byte,t_int,t_float,t_long,t_string,t_date,t_double,t_Refcntd,t_Refcntu,hash2from dbo.taabdb996000 (Index 2a)where hash2 < @khash2order by hash2 descat isolation 0

Page 94: BaanERPbaansupport.com/docs/baan/Sybase Database Driver Technical Refer… · Sybase Database Driver Technical Reference Manual 1 BaanERP database driver overview 1-1 The BaanERP

Appendix C: BaanERP Sybase database driver SQL queries

Sybase Database Driver Technical Reference Manual

9-6