Summary of Contents for Sybase Adaptive Server Anywhere
Page 1
Adaptive Server ™ Anywhere Reference Last modified: November 2000 Part Number: MC0058...
Page 2
Information in this manual may change without notice and does not represent a commitment on the part of Sybase, Inc. and its subsidiaries. Sybase, Inc. provides the software described in this manual under a Sybase License Agreement. The software may be used only in accordance with the terms of the agreement.
Documentation conventions............xiii The sample database..............xvi File Locations and Installation Settings......1 Installation directory structure ........... 2 How Adaptive Server Anywhere locates files ......4 Environment variables .............. 6 Registry entries and INI files ........... 10 The Database Server ............13 The database server ...............
Page 4
The Server Location utility ............ 125 The Service Creation utility ........... 126 The Spawn utility..............129 The Stop utility ..............130 The Transaction Log utility............ 132 The Uncompression utility............. 136 The Unload utility ..............138 The Upgrade utility..............145 The Validation utility.............. 148 The Write File utility ..............
Page 5
SQL Functions ............... 303 Function types............... 304 Alphabetical list of functions..........313 SQL Statements ............. 377 Using the SQL statement reference........378 ALLOCATE DESCRIPTOR statement [ESQL] ..... 381 ALTER DATABASE statement ..........383 ALTER DBSPACE statement ..........385 ALTER EVENT statement............. 387 ALTER PROCEDURE statement..........
Page 8
Error messages indexed by Adaptive Server Anywhere SQLCODE ............650 Error messages indexed by SQLSTATE ......669 Error messages indexed by Sybase error code....687 Alphabetic list of error messages.......... 711 Internal errors (assertion failed) ..........929 SQL Preprocessor Error Messages......931 SQL Preprocessor error messages indexed by error message value .............
Page 9
SYSARTICLECOL system table ........... 998 SYSCAPABILITY system table..........999 SYSCAPABILITYNAME system table ........ 1000 SYSCOLLATION system table ........... 1001 SYSCOLLATIONMAPPINGS system table ......1002 SYSCOLPERM system table..........1003 SYSCOLUMN system table ..........1004 SYSDOMAIN system table ..........1006 SYSEXTENT system table ..........1007 SYSEXTERNLOGINS system table ........
Page 10
SYSCAPABILITIES system view........1055 SYSCATALOG system view ..........1056 SYSCOLAUTH system view ..........1057 SYSCOLUMNS system view ..........1058 SYSFOREIGNKEYS system view ........1059 SYSGROUPS system view..........1060 SYSINDEXES system view ..........1061 SYSOPTIONS system view ..........1062 SYSPROCAUTH system view ..........1063 SYSPROCPARMS system view.........
Audience This manual is for all users of Adaptive Server Anywhere. It is to be used in conjunction with other manuals in the documentation set. Contents...
Related documentation Adaptive Server Anywhere is a part of SQL Anywhere Studio. For an overview of the different components of SQL Anywhere Studio, see Introducing SQL Anywhere Studio. The Adaptive Server Anywhere documentation consists of the following books: ♦ Getting Started...
Documentation conventions This section lists the typographic and graphical conventions used in this documentation. Syntax conventions The following conventions are used in the SQL syntax descriptions: ♦ Keywords All SQL keywords are shown in UPPER CASE. However, SQL keywords are case insensitive, so you can enter keywords in any case you wish;...
Page 14
If the icon is used to represent a particular application or kind of application, the name is indicated in the bottom right corner. A database server, such as Sybase Adaptive Server Anywhere or Adaptive Server Enterprise. If the icon is used to represent a particular kind of database server, such as Adaptive Server Anywhere, the name is indicated in the bottom right corner.
Page 15
This subdirectory has the following name: ♦ Windows NT and Windows 95/98 win32 ♦ UNIX ♦ Windows 3.x ♦ NetWare and Windows CE The executables are held in the Adaptive Server Anywhere installation directory itself on these platforms.
The sample database There is a sample database included with Adaptive Server Anywhere. Many of the examples throughout the documentation use this sample database. The sample database represents a small company. It contains internal information about the company (employees, departments, and financial data) as well as product information (products), sales information (sales orders, customers, and contacts), and financial information (fin_code, fin_data).
Page 17
The sample database is held in a file named asademo.db , and is located in your installation directory. xvii...
File Locations and Installation Settings About this chapter This chapter describes the installation and operating system settings used by Adaptive Server Anywhere. Depending on the operating system, these settings may be stored as environment variables, initialization file entries, or registry entries.
Some of the files in these directories are essential, and others are not. This section describes the directory structure. Adaptive Server Anywhere software, whether you receive it as a product or bundled as part of another product, is installed under a single installation directory.
Page 21
Chapter 1 File Locations and Installation Settings ♦ h directory The h directory contains header files for ESQL and ODBC database development. Novell NetWare file On Novell NetWare, all files are installed to a single directory on the server. locations Throughout this documentation, when reference is made to files in subdirectories of the installation directory, the file on NetWare is in the installation directory itself.
CREATE DATABASE statement statement and similar statements that can create files (such as CREATE WRITEFILE). In some cases, Adaptive Server Anywhere uses a simple algorithm to locate files. In other cases, a more extensive search is carried out. Simple file...
Page 23
(the directory from which it is started). This directory is searched for required files. Location registry entry On installation onto Windows 95/98, and NT, Adaptive Server Anywhere adds a LOCATION registry entry. The indicated directory is searched, followed by: ♦ A child named scripts ♦...
Environment variables Environment variables Adaptive Server Anywhere uses a set of environment variables to store various types of information. Not all variables need to be set in all circumstances. These environment variables are listed in this section. Setting environment variables The way you set an environment variable depends on the operating system you are using.
Page 25
PATH= installation_path Description The PATH environment variable is modified by the installation program to include the directories where Adaptive Server Anywhere executables are located. The executables are located in a subdirectory of the installation directory. In addition, if you are using other Sybase applications, the...
Page 26
Environment variables SQLCONNECT environment variable SQLCONNECT= parameter # value ; ... Syntax Description The SQLCONNECT environment variable is optional, and is not set by the installation program. SQLCONNECT specifies connection parameters that are used by several of the database administration utilities when connecting to a database server. This string is a list of parameter settings, of the form parameter=value, delimited by semicolons.
Page 27
SYBASE environment variable Syntax SYBASE= path Description The SYBASE variable marks the home directory for installation of some Sybase applications, including Adaptive Server Enterprise and utilities such dsedit . You need this variable only if you are using Adaptive Server Anywhere together with other members of the Adaptive Server family.
When local If you are running an Adaptive Server Anywhere program as a service under machine settings Windows NT, you should ensure that the settings are made at the local are needed machine level.
Page 29
Chapter 1 File Locations and Installation Settings Registry structure On Windows 95/98 and Windows NT, you can access the registry directly with the registry editor. The Adaptive Server Anywhere registry entries are held in either the HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE registries, in the following location:...
C H A P T E R The Database Server About this chapter This chapter describes the command-line options for the Adaptive Server Anywhere database server. It also contains information for the command-line options of the client executable (provided for compatibility with Version 5 software). Contents Topic Page...
The database server The database server Function Start a personal database server or network database server. Syntax { dbeng7 | dbsrv7 } [ server-switches ] [ database-file [ database-switches ] ]* load dbsrv7 [ server-switches ] [ database-file [ database-switches ] ]* NetWare syntax Switch Description...
Page 33
Chapter 2 The Database Server Switch Description -gd level Set database starting permission. See "–gd command-line option" on page 26. -ge size Set the stack size for threads that run external functions [not UNIX]. See "–ge command-line option" on page 27. Disable firing of triggers.
Page 34
The database server Switch Description Opens database in read-only mode. See "–r command-line option" on page 33. Set the syslog facility ID [UNIX]. See "–s command-line option" on page 34. -sb [ 0 | 1 ] Specify how the server reacts to broadcasts. See "–sb command- line option"...
Page 35
Chapter 2 The Database Server Recovery Switch Description -a filename Apply the named transaction log file. See "–a command-line option" on page 41. Force the database to start without a transaction log. See "–f command-line option" on page 41. Database Switch Description Truncate (delete) the transaction log after each checkpoint.
Page 36
Novell has also provided an updated for NetWare 3.11. This update clib.nlm contains bug fixes that are necessary for Adaptive Server Anywhere to work properly. It is installed during the installation of Adaptive Server Anywhere if it is not already on your NetWare server.
Page 37
NT event log entries by setting a registry entry. The registry entry is log messages Software\Sybase\Adaptive Server Anywhere\7.0 To control event log entries, set the EventLogMask key, which is of type REG_DWORD. The value is a bit mask containing the internal bit values for...
Page 38
The database server #This is the server name: -n MyServer #These are the protocols: -x tcpip #This is the database file my.db @environment-variable command-line option Function Read in command-line switches from the supplied environment variable. Syntax [ dbsrv7 | dbeng7 ] @ env-var ... Applies to All operating systems and servers.
Page 39
Chapter 2 The Database Server Description This is useful for using the Interactive SQL INPUT command to load large quantities of data into a database. option should not be used if you are using LOAD TABLE to bulk load data. When you use this option, the database server allows only one connection by one application.
Page 40
The database server ♦ Windows NT, Windows 95/98, NetWare 2 Mb ♦ 8 Mb UNIX It computes a runtime-specific minimum default cache size, which is the lesser of the following items: ♦ 25% of the machine’s physical memory ♦ The sum of the sizes of the main database files specified on the command line.
Page 41
Chapter 2 The Database Server See also "–c command-line option" on page 21 "–ch command-line option" on page 23 –ch command-line option Function Sets a maximum cache size, as a limit to automatic cache growth. [ dbsrv7 | dbeng7 ] -ch [ integer | integer K | integer M | integer P ] ... Syntax Applies to Windows NT, Windows 95/98...
Page 42
The database server Description For troubleshooting purposes, display cache information in the database server window whenever the cache size changes. –ct command-line option Function Enable character set translation. Syntax [ dbsrv7 | dbeng7 ] -ct ... Applies to All operating systems except NetWare and Windows CE. Description Character set translation converting strings between character sets that represent the same characters, but at different values.
Page 43
Chapter 2 The Database Server Syntax [ dbsrv7 | dbeng7 ] -ga ... Applies to All operating systems except NetWare. Description The meaning of this switch depends on whether you are running a personal server or a network server. ♦ Network server Specifying this switch on the network server causes each database to be unloaded after the last connection to it is dropped.
Page 44
The database server "Checkpoints and the checkpoint log" on page 668 of the book ASA User’s Guide –gd command-line option Function Set permissions required to start a database. Syntax [ dbsrv7 | dbeng7 ] -gd [ dba | all | none ] ... Applies to All operating systems and servers.
Page 45
Chapter 2 The Database Server –ge command-line option Function Set stack size for external functions. Syntax [ dbsrv7 | dbeng7 ] -ge integer ... Applies to Windows 95/98, Windows NT, NetWare Description Sets the stack size for threads running external functions, in bytes. The default is 16384 (16K).
Page 46
The database server To control access to the file system using these statements, the –gl command-line option allows you to control the level of database permission that is required to use these statements. The allowed values are as follows: ♦ Only users with DBA authority can load or unload data from the database.
Page 47
Chapter 2 The Database Server The default is 20 threads for the network database server, and 10 threads for the personal database server. The number of threads cannot be greater than the number of server connections, so the maximum number of threads for the personal database server is also 10.
Page 48
The database server –gss command-line option Function Set the stack size per internal execution thread in the server. Syntax [ dbsrv7 | dbeng7 ] -gss [ integer | integer K | integer M ] ... Applies to This option has no effect on Windows operating systems. Description The number of internal execution threads is controlled by the option, and...
Page 49
Chapter 2 The Database Server Syntax [ dbsrv7 | dbeng7 ] -gx integer ... Applies to Windows 95/98, Windows NT Description By default, this is set to one more than the number of CPUs on the machine. You may want to increase the option setting to reserve threads for external tasks, separate from standard database tasks.
Page 50
By default, the database server receives the name of the database file with the path and extension removed. For example, if the server is started on the file c:\sybase\asa6\asademo.db and no switch is specified, the name of the server is asademo.
Page 51
Chapter 2 The Database Server Applies to All operating systems and servers. Description Limit the size of the log file used by the switch. The default is no limit, –o and the value is in bytes. See also "–o command-line option" on page 32 –p command-line option Function Set the maximum size of communication packets.
Page 52
The database server If you attempt to modify the database, for example with an INSERT or DELETE statement, a SQLSTATE_READ_ONLY_DATABASE error is returned. Databases that require recovery cannot be started in read-only mode. For example, database files created using an online backup cannot be started in read-only mode if there were any open transactions when the backup was started, since these transactions would require recovery when the backup copy is started.
Page 53
Chapter 2 The Database Server –sc command-line option Function Disable the shared memory communications protocol and use Named Pipes. Syntax [ dbsrv7 | dbeng7 ] -sc... Applies to Windows NT. Description This option disables the shared memory communications protocol that is used for same-machine communications, and starts the NamedPipes protocol.
Page 54
The database server Description A liveness packet is sent periodically across a client/server TCP/IP or SPX communications protocol to confirm that a connection is intact. If the server runs for a liveness timeout period (default 2 minutes) without detecting a liveness packet, the communication is severed.
Page 55
Chapter 2 The Database Server Syntax [ dbsrv7 | dbeng7 ] -tq [ datetime | time ]... Applies to All operating systems and servers. See also "sa_server_option system procedure" on page 971 Description This is useful for setting up automatic off-line backup procedures (see "Backup and Data Recovery"...
Page 56
The database server –ut command-line option Function Touch temporary files. Syntax [ dbsrv7 | dbeng7 ] -ut minutes ... Applies to UNIX Description This switch causes the server to touch temporary files at specified intervals. –v command-line option Function Display the software version. Syntax [ dbsrv7 | dbeng7 ] -v Applies to...
Page 57
Chapter 2 The Database Server ♦ The IPX protocols is not started unless they are explicitly requested. It is recommended that you use SPX instead of IPX. The list is a comma-separated list of settings taken from the following case- insensitive list: ♦...
Page 58
The database server –y command-line option Function Run as a Windows 95/98 service. Syntax [ dbsrv7 | dbeng7 ] -y ... Applies to Windows 95/98 Description If the server registered as a Windows 95/98 service, it continues to operate whether users log on or off, and shutdown commands are ignored. –z command-line option Function Display communications operations on startup for troubleshooting purposes.
Page 59
Chapter 2 The Database Server Description This should only be used when tracking problems. The information is displayed in the database server window or sent to the logging file. –zs command-line option Function Limit the size of the request-level logging file. Syntax [ dbsrv7 | dbeng7 ] -zs size ...
Page 60
The database server Description If there is no transaction log, the database server carries out a checkpoint recovery of the database and then terminates—it does not continue to run. You can then restart the database server without the option for normal operation.
Page 61
Chapter 2 The Database Server Replicated databases Do not use the option with databases that are being replicated. Replication inherently relies on transaction log information. –n command-line option Function Set the name of the database. Syntax [ dbsrv7 | dbeng7 ] [ server-switches ]. database-file -n string .. Applies to All operating systems and servers.
C H A P T E R Connection and Communication Parameters About this chapter This chapter provides a reference for the parameters that establish and describe connections from client applications to a database. Contents Topic Page Connection parameters Network communications parameters...
In an ODBC data source. For more information, see "Working with ODBC data sources" on page 49 of the book ASA User’s Guide. ♦ In the Adaptive Server Anywhere connection window. For more information, see "Connecting from Adaptive Server Anywhere utilities" on page 48 of the book ASA User’s Guide.
Page 65
♦ TCP/IP connection to a database server running on the local machine. This is useful only for Adaptive Server Anywhere version 6 Windows 3.x applications running on Windows 95/98. For the application to attempt a Named Pipes or TCP/IP connection, these links must be specified in a CommLinks connection parameter.
Page 66
This connection parameter is sent to the database server from Embedded SQL, ODBC, or OLE DB clients. It is not available from Open Client or jConnect applications such as Interactive SQL or Sybase Central. It consists of a generated string that holds information about the client process, such as the IP address of the client machine, the operating system it is running on, and so on.
Page 67
Chapter 3 Connection and Communication Parameters ♦ Examples Connect to the default database from the C++ version of Interactive SQL: dbisqlc -c uid=dba;pwd=sql View the application information: select connection_property(’appinfo’) The result is as follows (in a single string): HOST= machine-name ; OS=Windows NT 4.0;...
Page 68
Connection parameters AutoStop connection parameter [Astop] Function To prevent a database from being stopped as soon as there are no more open connections. Usage Embedded databases Default Description By default, any server that is started from a connection string is stopped when there are no more connections to it.
Page 69
Chapter 3 Connection and Communication Parameters Description If you supply a value for CharSet, the specified character set is used for the current connection. For a list of valid character set values, see "Character set labels" on page 300 of the book ASA User’s Guide. CommBufferSize connection parameter [CBSize] Function To set the maximum size of communication packets, in bytes.
Page 70
Connection parameters CommBufferSpace connection parameter [CBSpace] Function To specify the amount of space to allocate on startup for communication buffers, in kilobytes. Usage Anywhere Values Integer Default Description Specify amount of space to allocate on startup for communication buffers, in kilobytes.
Page 71
Chapter 3 Connection and Communication Parameters Available values of the CommLinks parameter are case insensitive, and are as follows: ♦ Start all available communications links except IPX and NamedPipes. ♦ Start the IPX communications link. The IPX protocol is currently supported for Windows and NetWare clients.
Page 72
Connection parameters ♦ Examples The following connection string fragment starts the TCP/IP protocol only: CommLinks=tcpip ♦ The following connection string fragment starts the TCP/IP and IPX protocols, searching for the host kangaroo in addition to servers on the immediate TCP/IP network: CommLinks=ipx,tcpip(HOST=kangaroo) ConnectionName connection parameter [CON] Function...
Page 73
Chapter 3 Connection and Communication Parameters ♦ The path of the file is relative to the working directory of the database server. If you start the server from the command prompt, the working directory is the directory that you are in when entering the command. If you start the server from an icon or shortcut, it is the working directory that the icon or shortcut specifies.
Page 74
ODBC. The ODBC driver manager and ODBC driver locate the data source, which contains the remainder of the connection parameters. In Adaptive Server Anywhere, Embedded SQL applications can also use ODBC data sources to store connection parameters. ♦...
Page 75
Chapter 3 Connection and Communication Parameters Description If you are having trouble establishing a connection to a network server, set the Debug connection parameter to Yes and the Logfile parameter to a log file name. Diagnostic information is then placed in the log file. The DEBUG connection parameter is connection-specific, so from a single application you can set DEBUG=ON on one connection and OFF on another, or set DEBUG=ON on both but log to different files.
Page 76
You need to supply an EngineName only if more than one local database server is running, or you wish to connect to a network server. In the Sybase Central and Interactive SQL Connect dialog box, and in the ODBC Administrator, this is the Server Name field.
Page 77
Chapter 3 Connection and Communication Parameters This parameter corresponds to the SQL Anywhere Version 5 dbclient –e command-line switch. Using the switch on the dbsrv7 command line encrypts packets for all clients regardless of whether the Encryption parameter is used at the client. Similarly, if the client asks for encryption, the server will encrypt.
Page 78
Connection parameters ♦ An integrated login is attempted. If the connection attempt fails and the LOGIN_MODE option is set to Mixed, a standard login is attempted. ♦ This is the default setting. No integrated login is attempted. For a client application to use an integrated login, the server must be running with the LOGIN_MODE database option set to Mixed or Integrated.
Page 79
The password parameter is not encrypted. If you are storing passwords in a data source, you should use the EncryptedPassword parameter. Sybase Central and the Adaptive Server Anywhere ODBC configuration tool both use encrypted parameters. If both Password and EncryptedPassword are specified, Password takes...
Page 80
Connection parameters ♦ Examples The following connection string fragment supplies the user ID password uid=DBA;pwd=SQL Alternatively, you can set these parameters in the User ID and Password text boxes in the connection window. PrefetchBuffer connection parameter [PBUF] Function Set the maximum amount of memory for buffering rows, in kilobytes. Usage Anywhere Default...
Page 81
Chapter 3 Connection and Communication Parameters Improvements occur particularly under the following conditions: ♦ The application fetches many rows (several hundred or more) with very few absolute fetches. ♦ The application fetches rows at a high rate, and the client and server are on the same machine or connected by a fast network.
Page 82
Connection parameters Unconditional connection parameter [UNC] Function To stop a server using dbstop even when there are connections to the server. Usage Anywhere Default See also "The dbstop command-line utility" on page 130 Description dbstop command-line utility shuts down a database server. If you specify unc=Yes in the connection string, the server is shut down even if...
Chapter 3 Connection and Communication Parameters Network communications parameters If you experience problems with client/server network communications, there are a number of command line parameters for both the client and the server. These parameters enable you to work around peculiarities of different network protocol implementations.
Page 84
Network communications parameters This option is provided for connections across firewalls, as firewall software Description filters according to TCP/UDP port. It is recommended that you do not use this parameter unless you need to for firewall reasons. The ClientPort option designates the port number on which the client application communicates using TCP/IP.
Page 85
Chapter 3 Connection and Communication Parameters Specifying DoBroadcast=NONE causes no UDP or IPX broadcasts to be used. This option is helpful if you are attempting to connect to a server that is protected by a firewall, since many firewalls filter out UDP packets. YES and NO arguments are still accepted.
Page 86
Network communications parameters ♦ Example The following command starts a NetWare server with name asademo-1. load dbsrv7.nlm -x ipx(ExtendedName=Yes) asademo-1 Host parameter [IP] Usage TCP/IP, SPX, IPX (all platforms) Server and client sides Where See also "Debug connection parameter" on page 56 "ClientPort parameter"...
Page 87
Chapter 3 Connection and Communication Parameters Description Each path through a NetBIOS protocol stack is assigned a LAN adapter number. By default, the server looks through all possible numbers up to 255. To speed up server startup, you can truncate the search for valid LAN adapters at a specified value using the MAXLANA parameter.
Page 88
Network communications parameters ReceiveBufferSize parameter Usage TCP/IP Description Sets the size for a buffer used by the TCP/IP protocol stack. You may want to increase the value if blob performance over the network is important. Default Machine-dependent. RegisterBindery parameter [REGBIN] Usage IPX, SPX (Windows 95/98 and NT only).
Page 89
The value is an integer, with maximum value 254. NetBIOS network software has a limit to the number of commands allowed per machine. Adaptive Server Anywhere uses these NetBIOS commands, and disallows further connections if the system has no more commands available, even if this is less than the value of the Sessions parameter.
Page 90
Network communications parameters ♦ Example The following statement starts a server with a database named asademo, allowing 200 NetBIOS connections. dbsrv7 -x netbios(sessions=200) asademo.db TDS parameter Usage TCP/IP, NamedPipes. Server side only. Description To disallow TDS connections to a database server, set TDS to NO. If you want to ensure that only encrypted connections are made to your server, these port options are the only way to disallow TDS connections.
Page 91
Chapter 3 Connection and Communication Parameters ♦ Example The following statement places the statistics in the file ipxstat.txt in the current directory. dbsrv7 -x ipx(threadstats=ipxstat.txt) c:\asa7\asademo.db Timeout parameter [TO] Usage TCP/IP, IPX, SPX (all platforms) Description TIMEOUT specifies the length of time, in seconds, to wait for a response when establishing communications.
C H A P T E R Database Administration Utilities About this chapter Adaptive Server Anywhere includes a set of utility programs for backing up databases and performing other database administration tasks. This chapter provides reference information for each of the database administration utilities.
Page 94
Administration utilities overview The Unload utility The Upgrade utility The Validation utility The Write File utility...
This chapter presents reference information on the programs and database administration utilities that are part of Adaptive Server Anywhere. The utilities can be accessed from Sybase Central, from Interactive SQL, or as command-line programs. For comprehensive documentation on Sybase Central, see the Sybase Central online Help.
Data Recovery" on page 645 of the book ASA User’s Guide. For more information about the backup utility, see "BACKUP statement" on page 401. Backing up a database from Sybase Central v To back up a running database: Connect to the database.
Page 97
Chapter 4 Database Administration Utilities For full information on backing up a database from Sybase Central, see "Backup and Data Recovery" on page 645 of the book ASA User’s Guide. For more information about options, see "Backup utility options" on page 79...
Page 98
The Backup utility Connection parameters (–c) For a description of the connection parameters, see "Connection parameters" on page 64 of the book ASA User’s Guide. If the connection parameters are not specified, connection parameters from the SQLCONNECT environment variable are used, if set. The user ID must have DBA authority or REMOTE DBA authority.
Page 99
Chapter 4 Database Administration Utilities ♦ Step 2 The current transaction log remains in its current directory, but is renamed using the format , where xx is a number from yymmdd 00 to 99 and yymmdd represents the current year, month and day. This file is then no longer the current transaction log.
With the Collation utility, you can extract a collation (sorting sequence) into a file suitable for creating a database using a custom collation. The file that is produced can be modified and used with Sybase Central or option of to create a new database with a custom collation.
Page 101
SYS.SYSCOLLATION system table. This collation is selected from the set of collations specified in scripts subdirectory of your Adaptive Server Anywhere installation directory. Custom collations are added to the custom.sql script. The...
Page 102
The Collation utility Include empty mappings (–e) Normally, collations don’t specify the actual value that a character is to sort to. Instead, each line of the collation sorts to one position higher than the previous line. However, older collations have gaps between some sort positions. Normally, the Collation utility skips the gaps and writes the next line with an explicit sort-position.
This is useful for incorporating into batch or command files. Compressing a database in Sybase Central v To compress a database file: Open the Utilities folder in the left panel. Double-click Compress Database in the right panel. The Compress Database wizard appears.
Page 104
The Compression utility Description dbshrink utility reads database-file and creates a compressed database file. The compressed filename defaults to the same name as the original database file, but with an extension of .cdb . The output filename (with extension) must not be same as the input filename (with extension). For more information about the command-line switches, see "Compression utility options"...
The Console utility provides administration and monitoring facilities for database server connections. The Console utility is available on NetWare and UNIX operating systems only. On other operating systems, you can use Sybase Central to carry out the equivalent tasks. Syntax (UNIX)
Page 106
The Console utility For a description of connection parameters, see "Connection parameters" on page 64 of the book ASA User’s Guide.
Chapter 4 Database Administration Utilities The Data Source utility Syntax dbdsn [ modifier-switches ] { –l[ u ] [ s ] | –d[ u | s ] dsn | –g[ u | s ] dsn | –w[ u | s ] dsn [ details-switches;… ] | –cl } Parameters Major switch...
Page 108
The Data Source utility See also "Working with ODBC data sources" on page 49 of the book ASA User’s Guide "Using ODBC data sources on UNIX" on page 57 of the book ASA User’s Guide Description The Data Source utility is a cross-platform alternative to the ODBC Administrator for creating, changing, and deleting Adaptive Server Anywhere ODBC data sources.
Page 109
ASA User’s Guide. The remainder of the details switches are supplied for users familiar with the dbcli6.exe utility shipped with Adaptive Server Anywhere version 6. Encrypt network packets (–ec) Encrypt packets sent between the client application and the server.
Page 110
The Data Source utility For more information, see "CommLinks connection parameter" on page 52. Display debugging information (–z) Provide diagnostic information on communications links on startup. For more information, see "Debug connection parameter" on page 56. Server name Connect to the named server. Only the first 40 characters are used.
Page 111
Chapter 4 Database Administration Utilities The following example connects to the sample database server. The server name sample overrides the previous specified value of MyServer: dbdsn -w NewDSN -c "uid=DBA;pwd=SQL;eng=MyServer" sample List all connection parameter names and their aliases: dbdsn -cl...
This is useful for incorporating into batch or command files. For more information, see the "DROP DATABASE statement" on page 507. Erasing a database from Sybase Central v To erase a database file: Open the Utilities folder in the left panel.
Page 113
Chapter 4 Database Administration Utilities For full information on erasing a database from Sybase Central, see "Erasing a database" on page 118 of the book ASA User’s Guide. The dberase command-line utility Syntax dberase [ switches ] database-file Switch Description –o filename...
The Information utility The Information utility With the Information utility, you can display information about a database. The utility indicates when the database was created, the name of any transaction log file or log mirror that is maintained, the page size, and other information.
Page 115
Chapter 4 Database Administration Utilities Page usage statistics (–u) Display information about the usage and size of all tables, including system and user-defined tables. You can only request page usage statistics if no other users are connected to the database.
This choice can be changed later using the transaction log utility. You can access the Initialization utility in the following ways: ♦ From Sybase Central, for interactive use under Windows 95/98,NT, or Java versions on non-win32 platforms. ♦ From the system command line, using the dbinit command-line utility.
Page 117
Chapter 4 Database Administration Utilities For full information on creating a database in Sybase Central, see "Creating a database" on page 115 of the book ASA User’s Guide. The dbinit command-line utility Syntax dbinit [ switches ] new-database-file Switch Description Blank padding of strings for comparisons and fetching –b...
Page 118
Java classes, you can specify the switch to avoid installing them. If you want, you can add Sybase runtime Java classes at a later time using Sybase Central.
Page 119
A transaction log mirror is an identical copy of a transaction log, usually maintained on a separate device, for greater protection of your data. By default, Adaptive Server Anywhere does not use a mirrored transaction log. Do not use a transaction log (–n) Creating a database without a transaction log saves disk space.
Page 120
The Initialization utility Set the transaction log filename (–t) The transaction log is a file where the database server logs all changes, made by all users, no matter what application system is being used. The transaction log plays a key role in backup and recovery (see "The transaction log"...
Page 122
ANSI Code Page 1254, Windows Latin 5, Turkish, ISO8859-9 with extensions SJIS Multibyte Japanese Shift-JIS Encoding SJIS2 Multibyte Japanese Shift-JIS Encoding, Sybase Adaptive Server Enterprise-compatible EUC_JAPAN Multibyte Japanese EUC JIS X 0208-1990 and JIS X 0212-1990 Encoding EUC_CHINA Multibyte Chinese GB 2312-80 Encoding...
Page 123
Chapter 4 Database Administration Utilities Collation label Type Description ISO1LATIN1 ANSI ISO8859-1, ISO Latin 1, Western, Latin 1 Ordering ISO9LATIN1 ANSI ISO8859-15, ISO Latin 9, Western, Latin 1 Ordering WIN_LATIN1 ANSI Windows Latin 1, Western, ISO8859-1 with extensions WIN_LATIN5 ANSI Windows Latin 5, Western, ISO8859-9 with extensions UTF8...
JDBC/ODBC bridge to use this option. However, if the data source to which you are connecting is not configured to use TCP/IP, you must use the JDBC/ODBC bridge to connect. Adaptive Server Anywhere data sources are configured to use TCP/IP by default.
Page 125
Interactive SQL connects using jConnect. –port Specify the port number on which the database server is running. The default port number for Adaptive Server Anywhere is 2638. –q Do not display output messages. This is useful only if you start Interactive SQL with a command or command file.
Page 126
-c "uid=DBA;pwd=SQL" grant connect to joe identified by passwd Starting Interactive SQL from Sybase Central You can start Interactive SQL from Sybase Central in the following ways: ♦ Right-click a database, and select Open Interactive SQL from the popup menu.
You must only use this utility in accordance with your Sybase license agreement to license the number of users to which you are entitled. Running this command does not grant you license. You can also use this utility to view the current license information for a server executable without starting the server.
Page 128
The License utility Executable name Enter the path and file name of the network database server executable ( ) you are licensing. The path can be relative. dbsrv7.exe You can view the current license information for a server executable without starting the server by entering only the executable name.
Description The Log Transfer Manager (LTM) is also known as a replication agent. The LTM is required for any Adaptive Server Anywhere database that participates in a Replication Server installation as a primary site. The Adaptive Server Anywhere LTM reads a database transaction log and sends committed changes to Replication Server.
Page 130
Open Servers. The default interfaces file is sql.ini in the subdirectory of your Sybase directory. On NetWare, the default interfaces file is named interfaces Specify LTM name (–S) Provides the server name for this LTM. The default LTM_name is DBLTM_LTM.
Page 131
LTM recognizes. Parameters that are used by the Adaptive Server Enterprise LTM but not by the Adaptive Server Anywhere LTM are included in this list, and marked as either ignored (in which case they may be present in the configuration file, but have no effect) or as unsupported (in which case they will cause an error if present in the configuration file).
Page 132
The Log Transfer Manager Parameter Description By default, this is on. When set to off, the LTM continuous automatically shuts down as soon as all committed data has been replicated. The password for the LTM_admin_user login LTM_admin_pw name. The system administrator LTM login name that LTM_admin_user is used to log in to the LTM.
Page 133
Adaptive Server Enterprise LTM. The Adaptive Server Anywhere server does not "wake up" and scan the log when records arrive in the log. For this reason, you may wish to set the scan_retry value to a smaller number then that for an Adaptive Server Enterprise LTM.
Page 134
The Log Transfer Manager # This is a comment line # Names are case sensitive. SQL_user=sa SQL_pwd=sysadmin SQL_server=PRIMESV SQL_database=primedb RS_source_ds=PRIMEOS RS_source_db=primedb RS=MY_REPSERVER RS_user=sa RS_pw=sysadmin LTM_admin_user=DBA LTM_admin_pw=SQL LTM_charset=cp850 scan_retry=2 SQL_log_files=e:\logs\backup APC_user=sa APC_pw=sysadmin...
This is useful for incorporating into batch or command files. Translating a transaction log in Sybase Central v To translate a transaction log into a command file: Open the Utilities folder in the left panel. Double-click Translate Log in the right panel. The Translate Log wizard appears.
Page 136
The Log Translation utility Switch Description Include audit records in output –g –id destination,... Include only rows intended for the specified destinations –ir offset1,offset2 Include only the portion of the log between the two specified offsets –is source,... Include only rows originating from the specified sources –it user.table,...
Page 137
Chapter 4 Database Administration Utilities The following command translates log information from the server asademo and places the output in a file named asademo.sql dbtran -c "eng=asademo;dbn=asademo;uid=DBA;pwd=SQL" -n asademo.sql ♦ Run in this way, the utility acts directly Against a transaction log file against a transaction log file.
Page 138
The Log Translation utility Include rows for specified destinations (–id) Isolate operations on rows that are being sent to one or more of the following destinations, specified as a comma-separated list: ♦ All rows. This is the default setting. ♦ Include only rows that are to be replicated using SQLRemote SQL Remote.
Page 139
Chapter 4 Database Administration Utilities Operate quietly (–q) Do not display output messages. This option is available only from the command-line utility. Do not include uncommitted transactions (–r) Remove any transactions that were not committed. This is the default behavior. Override Replication Server user names (–rsu) By default, the switches assume the default Replication Server user names of...
The Ping utility The Ping utility The Ping utility is provided to assist in diagnosing connection problems. Syntax dbping [ switches ] Switch Description –c "keyword=value; ..." Database connection parameters Make a database connection if the server is found –d -l library Use specified ODBC driver or driver manager library.
Page 141
Windows operating systems. On UNIX, the Adaptive Server Anywhere ODBC driver is used. If you are using -m or -l, an Adaptive Server Anywhere data source name should be supplied as part of the connection string. If no data source name is supplied, you must specify the Driver= connection parameter.
Databases can be rebuilt using the Rebuild batch file, command file, or shell script, which invokes a series of utilities to rebuild a database, or as part of the unload process using the Unload an Adaptive Server Anywhere Database wizard in Sybase Central.
Log output messages to a file –q Operate quietly—do not print messages Description command-line utility locates any Adaptive Server Anywhere dblocate database servers running over TCP/IP on the immediate network. It prints a list of database servers and their addresses.
This utility provides a comprehensive way of managing ASA services on NT. The Service Creation utility provides the same functionality as the Create Service wizard in Sybase Central. You must be a member of the Administrators group on the local machine to...
Page 145
The engine runs as the LocalSystem user: dbsvc -as -w myserv E:\asa70\win32\dbeng7 -n graeme -c 8m e:\asa70\sample.db Create a network server service called myserv. The server runs as the sybase user (password asa), and starts automatically when the machine is booted:...
Page 146
The Service Creation utility dbsvc -a sybase -p asa -s auto -t network -w myserv E:\asa70\win32\dbsrv7 -n graeme -x tcpip -c 8m e:\asa70\sample.db Delete the service called myserv, without prompting for confirmation: dbsvc -y -d myserv List all details about service myserv:...
Chapter 4 Database Administration Utilities The Spawn utility This utility is provided to start a database server in the background. Syntax dbspawn [ switches ] server command line Switch Description –f Do not check for a running server Report operating system process ID –q Quiet mode—do not print messages Description...
The Stop utility The Stop utility The Stop utility stops a database server. The Stop utility is a command-line utility only. In windowed environments, you can stop a database server by clicking Close on the server window or choosing Exit from the File menu on the server window. The dbstop command-line utility Syntax dbstop [ switches ] { name }...
Page 149
Chapter 4 Database Administration Utilities The behavior of dbstop can be controlled if there are active connections on a server. If there are active connections, provides a prompt asking if dbstop you wish to shut down the server. If you specify on the unconditional=true command line, the server is shut down without prompting, even if there are...
From the system command line, using the dblog command-line utility Changing a log file name from Sybase Central v To change a transaction log file name: Open the Utilities folder in the left panel. Double-click Change Log File Information in the right panel. The Transaction Log wizard appears.
Page 151
Chapter 4 Database Administration Utilities Switch Description –g n Sets the LTM generation number to n Ignores the LTM truncation offset stored in the –il database Ignores the SQL Remote truncation offset stored –ir in the database –m mirror-name Set transaction log mirror name No longer use a transaction log or mirror log –n –o filename...
Page 152
The Transaction Log utility Transaction log utility options Set the generation number (–g) Use this option if you are using the Log Transfer Manager to participate in a Replication Server installation. It can be used after a backup is restored, to set the generation number. It performs the same function as the following Replication Server function: dbcc settrunc( ’ltm’, ’gen_id’, n ) For information on generation numbers and...
Page 153
Chapter 4 Database Administration Utilities Set the current log offset (–x) For use when reloading a SQL Remote consolidated database. This option resets the current log offset so that the database can take part in replication. For information on how to use this option, see "Unloading and reloading a consolidated database"...
This is useful for incorporating into batch or command files. Uncompressing a database in Sybase Central v To uncompress a compressed database file: Open the Utilities folder in the left panel. Double-click Uncompress Database in the right panel. The Uncompress wizard appears.
Page 155
Chapter 4 Database Administration Utilities For more information about the command-line switches, see "Uncompression utility options" on page 137. Uncompression utility options Log output messages to file (–o) Write output messages to the named file. Operate quietly (–q) Do not display output messages. This option is available only from the command-line utility.
Accessing the You can access the Unload utility in the following ways: Unload utility ♦ From Sybase Central. The Unload an Adaptive Server Anywhere Database wizard steps you through the process of rebuilding your database. ♦ From the system command line, using the...
Page 157
You can also access this wizard by clicking Tools Adaptive Server Anywhere Unload Database. For full information on unloading a database from Sybase Central, see "Exporting a database" on page 721 of the book ASA User’s Guide. The dbunload command-line utility...
Page 158
The Unload utility Switch Description –o filename Log output messages to a file –p char Escape character for external unloads (default "\") Quiet mode—no windows or messages –q –r reload-file Specify name and directory of generated reload Interactive SQL command file (default reload.sql ) –t table,...
Page 159
Chapter 4 Database Administration Utilities Typically, you would create a new database using the Initialization utility, and then reload it using this switch. This method is useful when you want to change the initialization options, such as page size, or collation. For example, the following command (which should be entered all on one line) loads a copy of the database into an existing database file...
Page 160
Using external commands, file and directory paths are relative to the current directory of the user. In Sybase Central, you can specify whether to unload relative to the server or client. For more information on filenames and paths for the Unload utility, see "UNLOAD TABLE statement"...
Page 161
Chapter 4 Database Administration Utilities Use internal unload, external reload (–ix) This switch uses the UNLOAD statement to extract data from the database, and uses the Interactive SQL INPUT statement in the reload.sql file to repopulate the database with data. Repeated unload of view creation statements (–j) If your database contains view definitions that are dependent on each other, you can use this...
Page 162
The Unload utility Use external unloading, external reload (–xx) This switch uses the Interactive SQL OUTPUT statement to extract data from the database, and uses the Interactive SQL INPUT statement in the generated reload command file, reload.sql , to repopulate the database with data. Operate without confirming actions (–y) Choosing this option replaces existing command files without prompting you for confirmation.
The Upgrade utility The Upgrade utility upgrades a database created with older versions of the software. While Adaptive Server Anywhere does run against databases that were created with earlier releases of the software, some of the features that were introduced since the version that created the database are unavailable unless the database is upgraded.
Page 164
The dbupgrad command-line utility upgrades a database created with Watcom SQL 3.2, Watcom SQL 4.0, or SQL Anywhere 5.0 to the Adaptive Server Anywhere format. While Adaptive Server Anywhere does run against databases that were created with earlier releases of the software, some of the features that were introduced since the version that created the database are unavailable unless the database is upgraded.
Page 165
Do not install Sybase runtime Java classes (–j) If you wish to use Java in your database, you must install the Sybase runtime Java classes. By default, these classes are installed when a database is upgraded to Version 6. The runtime classes add several megabytes to the size of a database. If you...
For more information on validating tables, see "VALIDATE TABLE statement" on page 644. Validating a database from Sybase Central You can validate a database from Sybase Central, and validate individual tables. v To validate a database: Open the Utilities folder.
Page 167
Chapter 4 Database Administration Utilities For validating database, you can also access this wizard by clicking Tools Adaptive Server Anywhere Validate Database. The dbvalid command-line utility Syntax dbvalid [ switches ] [ object-name,... ] Switch Description object-name The name of a table or (if -i is used) an index to validate –c "keyword=value;...
Page 168
The Validation utility For example, the following validates the sample database, connecting as user with password dbvalid -c "uid=DBA;pwd=SQL;dbf=c:\asa6\asademo.db" Data check for each table (–fd) In addition to the default validation checks, check that all of each LONG BINARY, LONG VARCHAR, TEXT, or IMAGE data type can be read.
The database file cannot be modified after the write file is created, otherwise the write file becomes invalid. Creating a write file from Sybase Central v To create a write file for a database: Open the Utilities folder in the left panel.
Page 170
The Write File utility The dbwrite command-line utility dbwrite [ switches ] database-file [ write-name ] Syntax Switch Description Create a new write file –c –d database-file Point a write file to a different database –f database-file Force the write file to point at a file –m mirror-name Set the transaction log mirror name –o filename...
Page 171
Chapter 4 Database Administration Utilities Change the database file to which an existing write file points (–d) If a database file is moved to another directory, or renamed, this option allows you to maintain the link between the write file and the database file. This option is available only from the command-line utility.
C H A P T E R Database Options About this chapter This chapter describes the database and Interactive SQL options that can be set to customize and modify database behavior. Contents Topic Page Introduction to database options General database options Transact-SQL and SQL/92 compatibility options Replication options Interactive SQL options...
♦ Compatibility You can control how much like Adaptive Server Enterprise your Adaptive Server Anywhere database operates, and whether SQL that does not conform to SQL/92 generates errors. ♦ Error handling You can control what happens when errors such as dividing by zero, or overflow errors, occur.
Page 175
In Interactive SQL, the SET statement with no arguments lists the current setting of options. ♦ In Sybase Central, right-click on a database, and select Set Options from the popup menu. ♦ Use the following query on the SYSOPTIONS system view:...
Page 176
Introduction to database options Some options (such as COMMIT behavior) are database-wide in scope. Setting these options requires DBA permissions. Other options (such as ISOLATION_LEVEL) can also be applied to just the current connection, and need no special permissions. Changes to option settings take place at different times, depending on the option.
Page 177
(Open Client and jConnect JDBC connections) or through the Adaptive Server Anywhere protocol (ODBC, Embedded SQL). If you have users who use both TDS and the Adaptive Server Anywhere- specific protocol, you can configure their initial settings using stored procedures.
Page 178
Introduction to database options For more information, see "LOGIN_PROCEDURE option" on page 196, "sp_login_environment system procedure" on page 974, and "sp_tsql_environment system procedure" on page 979.
Chapter 5 Database Options General database options This section lists all database options. OPTION VALUES DEFAULT "AUDITING option" on page 172 ON, OFF "BACKGROUND_PRIORITY option" on ON, OFF page 174 "BLOCKING option" on page 175 ON, OFF "CHECKPOINT_TIME option" on Number of page 177 minutes...
Page 180
General database options OPTION VALUES DEFAULT "MAX_CURSOR_COUNT option" on Integer page 196 "MAX_HASH_SIZE option" on page 197 Integer "MAX_WORK_TABLE_HASH_SIZE Integer option" on page 197 "MAX_STATEMENT_COUNT option" on Integer page 198 "MIN_PASSWORD_LENGTH option" on Integer page 198 "OPTIMIZATION_GOAL option" on first-row or all- first-row page 201 rows...
Chapter 5 Database Options Transact-SQL and SQL/92 compatibility options The following options allow Adaptive Server Anywhere behavior to be made compatible with Adaptive Server Enterprise, or to support both old behavior and allow ISO SQL/92 behavior. For further compatibility with Adaptive Server Enterprise, some of these...
Page 182
Transact-SQL and SQL/92 compatibility options List of options The following table lists the compatibility options, their allowed values, and their default settings. OPTION VALUES DEFAULT "ALLOW_NULLS_BY_DEFAULT ON, OFF option" on page 169 "ANSI_BLANKS option" on page 169 ON, OFF "ANSI_CLOSE_CURSORS_ON_RO ON, OFF LLBACK option"...
Page 183
Chapter 5 Database Options OPTION VALUES DEFAULT "ON_TSQL_ERROR option" on STOP, CONDITIONAL page 201 CONDITION CONTINUE "PERCENT_AS_COMMENT option" ON, OFF on page 204 "QUERY_PLAN_ON_OPEN option" ON, OFF on page 206 "QUOTED_IDENTIFIER option" on ON, OFF page 207 "RI_TRIGGER_TIME option" on BEFORE, AFTER page 210...
Replication options Replication options The following options are included to provide control over replication behavior. Some replication options are useful for SQL Remote replication, and some are relevant for use with Sybase Replication Server. OPTION VALUES DEFAULT "BLOB_THRESHOLD option" Integer on page 174 "COMPRESSION option"...
Chapter 5 Database Options Alphabetical list of options This section lists options alphabetically ALLOW_NULLS_BY_DEFAULT option Function Controls whether new columns that are created without specifying either NULL or NOT NULL are allowed to contain NULL values. Allowed values ON, OFF Default OFF for Open Client and JDBC connections Description...
Page 188
Description The draft SQL/3 standard requires all cursors be closed when a transaction is rolled back. By default, on a rollback Adaptive Server Anywhere closes only those cursors that were opened without a WITH HOLD clause. This option allows you to force closure of all cursors.
Page 189
CURSORS in new databases. OFF in databases created before version 7.0. Description Adaptive Server Anywhere provides several extensions that allow updates which are not permitted by the ANSI SQL standard. These extensions provide powerful, efficient mechanisms for performing updates. However, in some cases, they cause behavior that is not intuitive.
Page 190
Alphabetical list of options ♦ Updates of columns that appear in an ORDER BY clause ♦ The FROM clauses is not allowed in UPDATE statements. If the option is set to CURSORS, these same restrictions are in place, but only for cursors. If a cursor is not opened with FOR UPDATE or FOR READ ONLY, the database server chooses updatability based on the SQL/92 standard.
Page 191
Chapter 5 Database Options SET OPTION PUBLIC.AUDITING = ’ON’ AUTO_COMMIT option [ISQL] Function Controls whether a COMMIT is performed after each statement. Allowed values ON, OFF Default Description If AUTO_COMMIT is on, a database COMMIT is performed after each successful statement. If the COMMIT fails, you have the option to execute additional SQL statements and perform the COMMIT again, or execute a ROLLBACK statement.
Page 192
Alphabetical list of options Description Controls whether any new columns with the TIMESTAMP data type that do not have an explicit default value defined are given a default value of the Transact-SQL timestamp value as a default. The AUTOMATIC_TIMESTAMP option is included for Transact-SQL compatibility.
Page 193
Chapter 5 Database Options Allowed values Integer, in kilobytes Default Description Any value longer than the BLOB_THRESHOLD option is replicated as a blob. That is, it is broken into pieces and replicated in chunks, before being reconstituted by using a SQL variable and concatenating the pieces at the recipient site.
Page 194
Alphabetical list of options Description Controls the Transact-SQL transaction mode. In Unchained mode (CHAINED = OFF), each statement is committed individually unless an explicit BEGIN TRANSACTION statement is executed to start a transaction. In chained mode (CHAINED = ON) a transaction is implicitly started before any data retrieval or modification statement.
Page 195
Chapter 5 Database Options CHECKPOINT_TIME option Function Set the maximum number of minutes that the database server will run without doing a checkpoint. Allowed values Integer Scope Can be set only for the PUBLIC group. DBA authority is required to set the option.
Page 196
Alphabetical list of options When CLOSE_ON_ENDTRANS is set to OFF, cursors are not closed at either a commit or a rollback, regardless of the ANSI_CLOSE_CURSORS_AT_ROLLBACK option setting or whether the cursor was opened WITH HOLD or not. Setting this to OFF provides Adaptive Server Enterprise compatible behavior.
Page 197
Chapter 5 Database Options Default Description The values have the following meanings: ♦ Send messages in Version 5 format. Message Agents (both dbremote ssremote ) from previous versions of SQL Remote cannot read messages sent in Version 6 format. You should ensure that COMPRESSION is set to -1 until all Message Agents in your system are upgraded to Version 6.
Page 198
Alphabetical list of options Intermediate RAISERROR statuses and codes are lost after the procedure terminates. If, at return time, an error occurs along with the RAISERROR, then the information for the new error is returned and the RAISERROR information is lost. The application can query intermediate RAISERROR statuses by examining the @@error global variable at different execution points.
Page 199
Chapter 5 Database Options If COOPERATIVE_COMMITS is set to ON (the default), the database server does not immediately write the COMMIT to the disk. Instead, the application waits for up to the maximum length set by the COOPERATIVE_COMMIT_TIMEOUT option for something else to put on the pages before they are written to disk.
Page 200
Alphabetical list of options Description The format is a string using the following symbols: Symbol Description Two digit year yyyy Four digit year Two digit month, or two digit minutes if following a colon(as in hh:mm) mmm[m...] Character short form for months—as many characters as there are Single digit day of week, (0 = Sunday, 6 = Saturday) Two digit day of month ddd[d...]...
Page 201
Some software, such as Microsoft Access, truncates TIMESTAMP values to three decimal places, making valid comparisons a problem. You can set the TRUNCATE_TIMESTAMP_VALUES option to ON to specify the number of decimal place values Adaptive Server Anywhere stores to maintain compatibility.
Page 202
Alphabetical list of options For more information, see "TRUNCATE_TIMESTAMP_VALUES option" on page 215. DELAYED_COMMITS option Function Determines when the server returns control to an application following a COMMIT. ON or OFF Allowed values Scope Can be set for an individual connection or for the PUBLIC group. Takes effect immediately.
Page 203
Description This option is used at MobiLink clients, by SQL Remote, and by the Adaptive Server Anywhere Replication Agent. The default setting is OFF. When it is set to ON, each old transaction log is deleted when all the changes it contains have been sent and confirmed as received.
Page 204
Alphabetical list of options When set to binary, Interactive SQL does no data conversion. DIVIDE_BY_ZERO_ERROR option Function Controls the reporting of division by zero. Allowed values ON, OFF Default Description This option indicates whether division by zero is reported as an error. If the option is set ON, then division by zero results in an error with SQLSTATE 22012.
Page 205
FIRE_TRIGGERS setting. This option is relevant when replicating data from Adaptive Server Enterprise to Adaptive Server Anywhere, because all actions from Adaptive Server Enterprise transaction logs are replicated to Adaptive Server Anywhere, including actions carried out by triggers.
Page 206
Adaptive Server Enterprise as REAL values. Since Adaptive Server Enterprise treats its own FLOAT values as DOUBLE, enabling this option makes Adaptive Server Anywhere treat FLOAT values in the same way Enterprise treats FLOAT values. REAL values are four bytes; DOUBLE values are eight bytes. According to the ANSI SQL/92 specification, FLOAT can be interpreted based on the platform.
Page 207
Chapter 5 Database Options A setting of 0 (the default) indicates that GLOBAL DEFAULT AUTOINCREMENT is disabled, and NULL is generated as a default. You can find the value of the option in the current database using the following statement: select db_property( ’GlobalDBId’...
Page 208
Alphabetical list of options ♦ ASCII Input lines are assumed to be ASCII characters, one row per line, with values separated by commas. Alphabetic strings may be enclosed in apostrophes (single quotes) or quotation marks (double quotes). Strings containing commas must be enclosed in either single or double quotes.
Page 209
Chapter 5 Database Options Description This boolean option controls whether SQL statements are timed or not. If you set the option to ON, YES, or 1, the time of execution appears in the Messages pane after you execute a statement. If you set the option to OFF, NO, or 0, the time does not appear.
Page 210
Alphabetical list of options ISQL_FIELD_SEPARATOR option [ISQL] Function Controls the default string used for separating values in data exported to ASCII files. Allowed values Any string Default A comma ( , ) Description Controls the default string used for separating (or delimiting) values in data exported to ASCII files.
Page 211
Chapter 5 Database Options ISQL_PLAN option [ISQL] Function Controls the amount of information displayed in the Messages pane after you execute statements. Allowed values NONE, SHORT, LONG Default SHORT Description After you execute a SQL statement in Interactive SQL, the optimizer provides information in the Messages pane about how it optimized the execution.
Page 212
Alphabetical list of options ISOLATION_LEVEL option Function Controls the locking isolation level. Allowed values 0, 1, 2, or 3 Scope Can be set for an individual connection or for the PUBLIC group. Takes effect immediately. Default 1 for Open Client and JDBC connections Description This option controls the locking isolation level as follows.
Page 213
Chapter 5 Database Options JAVA_INPUT_OUTPUT option Function To enable file access from Java in the database Allowed values ON, OFF Supported on NT only. Scope Can be set for the PUBLIC group only. DBA authority required. Takes effect when the database is restarted. Default See also "Supported Java packages"...
Page 214
Alphabetical list of options Description This option specifies whether integrated logins are permitted. The following values are accepted (the values are case insensitive): ♦ Standard This is the default setting, which does not permit integrated logins. An error occurs if an integrated login connection is attempted. ♦...
Page 215
Chapter 5 Database Options Allowed values Integer Scope Can be set for an individual connection or for the PUBLIC group. Takes effect immediately. DBA permissions are required to set this option for any connection. Default This resource governor allows a DBA to limit the number of cursors per Description connection that a user can use.
Page 216
Alphabetical list of options "Temporary tables used in query processing" on page 824 of the book ASA See also User’s Guide. In general, you should not need to use this option, as the query optimizer Description allocates hash sizes for the internal temporary tables based on the data distribution within the table.
Page 217
Two digit years less than the value are converted to 20yy, while years greater than or equal to the value are converted to 19yy. The historical Adaptive Server Anywhere behavior is to add 1900 to the year. Adaptive Server Enterprise behavior is to use the nearest century, so any year where value yy is less than 50, the year is set to 20yy.
Page 218
Alphabetical list of options keywords_4_0_d, keywords_4_0_c, keywords_4_0_b, keywords_4_0_a, keywords_4_0, keywords_5_0_01, keywords_5_0 The following statement prevents TRUNCATE and SYNCHRONIZE from being recognized as keywords: SET OPTION NON_KEYWORDS = ’TRUNCATE, SYNCHRONIZE’ The following statement prevents all keywords introduced since release 4.0d from being recognized as keywords: SET OPTION NON_KEYWORDS = ’keywords_4_0_d’...
Page 219
Chapter 5 Database Options ♦ CONTINUE The error is ignored and Interactive SQL continues reading statements from the command file. The INPUT statement continues with the next row, skipping the row that caused the error. ♦ EXIT Interactive SQL terminates. ♦...
Page 220
Default first-row Description By default, Adaptive Server Anywhere chooses an access plan that is intended to reduce the time to fetch the first row of output, possibly at the expense of total retrieval time. In particular, Adaptive Server Anywhere typically avoids materializing results if possible in order to reduce the time to return the first row.
Page 221
Chapter 5 Database Options ♦ DBASEII The output is a dBASE II format file with the column definitions at the top of the file. Note that a maximum of 32 columns can be output. Also, note that columns longer than 255 characters will be truncated in the file.
Page 222
The double-dash style is the SQL/92 comment delimiter. Adaptive Server Enterprise treats % as a modulo operator and does not support the Adaptive Server Anywhere mod function. Writing a statement that works in both environments and performs a modulo operation was previously impossible.
Page 223
The Sybase Central code editor does not highlight %-style comments. If you wish to have your comments highlighted in the Sybase Central editor, you should use one of the other comment delimiters.
Page 224
Allowed values ON, OFF Default The default in Adaptive Server Anywhere is ON. The default in Adaptive Server Enterprise is OFF. Description Qualifying owners in Adaptive Server Enterprise setups is rarely needed because it is common for objects to be owned by dbo. When qualification is not needed in Adaptive Server Anywhere setups, messages will be slightly smaller with the option OFF.
Page 225
(ON) or as literal strings (OFF). The QUOTED_IDENTIFIER option is included for Transact-SQL compatibility. Sybase Central sets QUOTED_IDENTIFER temporarily to ON if it is set to OFF. A message is displayed informing you of this change. The change is in effect only for the Sybase Central connection.
Page 226
This option is used with the "CHECKPOINT_TIME option" on page 177 to decide when checkpoints should be done. Adaptive Server Anywhere uses a heuristic to estimate the recovery time based on the operations that have been performed since the last checkpoint.
Page 227
Chapter 5 Database Options Description This option is used by the LTM only. When it is set to ON, the entire database is set to act as a primary site in a Replication Server installation. All changes to the database are sent to Replication Server by the LTM. REPLICATION_ERROR option Function For SQL Remote, allows you to specify a stored procedure to be called by...
Page 228
Alphabetical list of options RI_TRIGGER_TIME option Function Controls the relative timing of referential integrity checks and trigger actions. Allowed values BEFORE, AFTER Scope Can be set for the PUBLIC option only. DBA authority is required to set this option. Default AFTER Description The option can be set to either BEFORE or AFTER.
Page 229
Chapter 5 Database Options ♦ Flag syntax that is not intermediate-level SQL/92 syntax ♦ Flag syntax that is not full-SQL/92 syntax ♦ Allow all supported syntax SQL_FLAGGER_WARNING_LEVEL option Function Controls the response to any SQL that is not part of a specified set of SQL/92.
Page 230
Alphabetical list of options When you set the STATISTICS option to 0, no information appears in the Messages pane after you execute a SQL statement. When you set the option to any other number, both the execution time and the default plan appear in the Messages pane after you execute a statement.
Page 231
Chapter 5 Database Options TIME_FORMAT option Function Sets the format for times retrieved from the database. Allowed values A string composed of the symbols listed below. Scope Can be set for an individual connection or for the PUBLIC group. Takes effect immediately.
Page 232
Alphabetical list of options Symbol Description Two digit year Yyyy Four digit year Two digit month, or two digit minutes if following a colon (as in ’hh:mm’) Mmm[m...] Character short form for months—as many characters as there are Two digit day of month Ddd[d...] Character short form for day of the week Two digit hours...
Page 233
TIMESTAMP value to three decimal places, you can set the TRUNCATE_TIMESTAMP_VALUES option to ON to limit the number of decimal places Adaptive Server Anywhere stores. The Default_timestamp_increment option determines the number of decimal places to which the TIMESTAMP value is truncated.
Page 234
Alphabetical list of options There are some cases where a fast TRUNCATE cannot be done: ♦ If there are foreign keys either to or from the table ♦ If the TRUNCATE TABLE statement is executed within a trigger ♦ If the TRUNCATE TABLE statement is executed within an atomic statement TRUNCATION_LENGTH option [ISQL] Function...
Page 235
Chapter 5 Database Options Default ON for Open Client and JDBC connections Description When this options set to ON, you can use the @ sign instead of the colon as a prefix for host variable names in Embedded SQL. This is implemented primarily for Transact-SQL compatibility.
Page 236
Alphabetical list of options Default Description If this option is set to ON, the database does not check foreign key integrity until the next COMMIT statement. Otherwise, all foreign keys that are not created with the CHECK ON COMMIT option are checked as they are inserted, updated or deleted.
C H A P T E R SQL Language Elements About this chapter This chapter describes the elements and conventions of the SQL language. Contents Topic Page Keywords Identifiers Strings Operators Expressions Search conditions Special values Variables Comments NULL value...
A string requires quotes if it is a reserved word or if it contains a character not ordinarily allowed in an identifier. The SQL keywords in Adaptive Server Anywhere 7 are as follows:...
Page 239
Chapter 6 SQL Language Elements alter backup begin between bigint binary bottom break call capability cascade case cast char char_convert character check checkpoint close comment commit connect constraint continue convert create cross cube current cursor date dbspace deallocate decimal declare default delete desc...
Chapter 6 SQL Language Elements Identifiers Function Identifiers represent names of objects in the database, such as user IDs, tables, and columns. Description Identifiers consist of any string of alphabetic characters or digits. The first character of an identifier must be an alphabetic character, not a digit. Alternatively, any string of characters can be used as an identifier by enclosing it in quotation marks ("double quotes") as long as the QUOTED_IDENTIFIER database option is set to ON.
Strings Strings Strings are of the following types: ♦ literal strings ♦ expressions with CHAR or VARCHAR data types. An expression with a CHAR data type may be a built-in or user-defined function, or one of the many other kinds of expressions available. For more information on expressions, see "Expressions"...
Any trailing blanks in character data are ignored for Compatibility Trailing blanks comparison purposes by Adaptive Server Enterprise. The behavior of Adaptive Server Anywhere when comparing strings is controlled the –b command-line switch that is set when creating the database.
Adaptive Server Enterprise databases are created as case sensitive. Comparisons are carried out with the same attention to case as the database they are operating on. You can control the case sensitivity of Adaptive Server Anywhere databases when creating the database. Logical operators Search conditions can be combined using AND, OR and NOT.
Page 245
The || operator is the SQL/92 string concatenation operator. SQL/92 compatibility ♦ Sybase The + operator is supported by Adaptive Server Enterprise. Bitwise operators The following operators can be used on bit data types, in both Adaptive Server Anywhere and Adaptive Server Enterprise.
Page 246
Server Anywhere, in addition to the SQL/92 join syntax that uses a table expression in the FROM clause. ♦ Compatibility Modulo The % operator can be used in Adaptive Server Anywhere only if the PERCENT_AS_COMMENT option is set to OFF. The default value is ON. ♦ String concatenation...
Page 247
Chapter 6 SQL Language Elements When you use more than one operator in an expression, it is recommended that you make the order of operation explicit using parentheses rather than relying on an identical operator precedence between Adaptive Server Enterprise and Adaptive Server Anywhere.
Page 249
Chapter 6 SQL Language Elements operator: { + | - | * | / | || | % } Usage Anywhere. Authorization Must be connected to the database. Side effects None. See also "Constants in expressions" on page 231 "Special values" on page 247 "Column names in expressions"...
Expressions address "date hired" "salary"."date paid" For more information on identifiers, see "Identifiers" on page 223. Subqueries in expressions A subquery is a SELECT statement enclosed in parentheses. The SELECT statement must contain one and only one select list item. When used as an expression, a subquery is generally allowed to return only one value.
Page 251
Chapter 6 SQL Language Elements IF statement is different from IF expression Do not confuse the syntax of the IF expression with that of the IF statement. For information on the IF statement, see "IF statement" on page 545. CASE expressions The CASE expression provides conditional SQL expressions.
Expressions For example, the following statement uses a case expression as the third clause of a SELECT statement to associate a string with a search-condition. SELECT id, name, ( CASE WHEN name=’Tee Shirt’ then ’Sale’ WHEN quantity >= 50 then ’Big Sale’ ELSE ’Regular price’...
Page 253
Chapter 6 SQL Language Elements The NEW SQL operator performs the same operation as the new keyword in Java code: invoke a constructor method of a Java class. The data type of the NEW expression is a Java class, specifically the Java class that is being constructed.
Page 254
Both host-variable Adaptive Server Anywhere Default By default, Adaptive Server Enterprise and Adaptive Server Anywhere give interpretation of different meanings to delimited strings: that is, strings enclosed in delimited strings apostrophes (single quotes) and in quotation marks (double quotes).
Page 255
The quoted_identifier option Both Adaptive Server Enterprise and Adaptive Server Anywhere provide a quoted_identifier option that allows the interpretation of delimited strings to be changed. By default, the quoted_identifier option is set to OFF in Adaptive Server Enterprise, and to ON in Adaptive Server Anywhere.
Page 256
Expressions VALUES ( ’abcde’ ) ; If you choose to operate with the quoted_identifier option off (the default Adaptive Server Enterprise setting), then the following statements are valid for both DBMSs. SELECT * FROM employee WHERE emp_lname = "Chin"...
Chapter 6 SQL Language Elements Search conditions Function To specify a search condition for a WHERE clause, a HAVING clause, a CHECK clause, a JOIN clause, or an IF expression. Syntax search condition: expression compare expression | expression compare { [ ANY | SOME ] | ALL }( subquery ) | expression IS [ NOT ] NULL | expression [ NOT ] BETWEEN expression AND expression | expression [ NOT ] LIKE expression [ ESCAPE expression ]...
Page 258
The keyword SOME can be used instead of ANY. ♦ Compatibility ANY and ALL subqueries are compatible between Adaptive Server Enterprise and Adaptive Server Anywhere. Only Adaptive Server Anywhere supports SOME as a synonym for ANY. BETWEEN conditions The syntax for BETWEEN conditions is as follows:...
Chapter 6 SQL Language Elements ... expr [ NOT ] BETWEEN start-expr AND end-expr The BETWEEN condition can evaluate as TRUE, FALSE, or UNKNOWN. Without the NOT keyword, the condition evaluates as TRUE if expr is between start-expr and end-expr. The NOT keyword reverses the meaning of the condition but leaves UNKNOWN unchanged.
Page 260
Search conditions If an escape-expr is specified, it must evaluate to a single character. The character can precede a percent, an underscore, a left square bracket, or another escape character in the pattern to prevent the special character from having its special meaning. When escaped in this manner, a percent will match a percent, and an underscore will match an underscore.
The expression [a^b] finds one of a, ^, or b. ♦ Compatibility The ESCAPE clause is supported by Adaptive Server Anywhere only. IN conditions The syntax for IN conditions is as follows: ... expression [ NOT ] IN ( subquery )
TRUE, FALSE, or UNKNOWN. Otherwise, the value is FALSE. The NOT keyword reverses the meaning of the condition, but leaves UNKNOWN unchanged. ♦ Compatibility Adaptive Server Anywhere only supports truth-valued conditions.
Page 263
TRUE UNKNOWN Explicit selectivity estimates The Adaptive Server Anywhere optimizer uses statistical information to decide upon the best strategy for executing each statement. Adaptive Server Anywhere automatically gathers and updates these statistics. These statistics are stored permanently in the database in the column statistics registry.
Page 264
Search conditions In this situation, the best approach is to execute statements that allow Adaptive Server Anywhere to scan the new rows sequentially. The internal statistics are automatically updated as a side effect, allowing the optimizer to choose better plans for subsequent queries.
Chapter 6 SQL Language Elements Special values Special values can be used in expressions, and as column defaults when creating tables. CURRENT DATE special value Function CURRENT DATE returns the current year, month, and day. Data type DATE See also "Expressions"...
Special values SQLCODE special value Function Current SQLCODE value. Data type String. Description The SQLCODE value is set after each statement. You can check the SQLCODE to see whether or not the statement succeeded. See also "Expressions" on page 230 "Database Error Messages"...
CURRENT PUBLISHER can be used as a default value in columns with character data types. See also "Expressions" on page 230 "SQL Remote Design for Adaptive Server Anywhere" on page 385 of the book Replication and Synchronization Guide LAST USER special value Function The name of the user who last modified the row.
Variables Variables Adaptive Server Anywhere supports three levels of variables: ♦ These are defined inside a compound statement in a Local variables procedure or batch using the DECLARE statement. They exist only inside the compound statement. ♦ These are defined with a CREATE Connection-level variables VARIABLE statement.
Adaptive Server Enterprise and Adaptive Server Anywhere Names both support local variables. In Adaptive Server Enterprise, all variables must be prefixed with an @ sign. In Adaptive Server Anywhere, the @ prefix is optional. To write compatible SQL, prefix all of your variables with @.
Page 270
Variables The syntax for the CREATE VARIABLE statement is as follows: CREATE VARIABLE variable-name data-type When a variable is created, it is initially set to NULL. The value of connection-level variables can be set in the same way as local variables, using the SET statement or using a SELECT statement with an INTO clause.
Page 271
Chapter 6 SQL Language Elements CREATE PROCEDURE VersionProc ( OUT ver VARCHAR( 100 ) ) BEGIN SELECT @@version INTO ver; In Embedded SQL, global variables can be selected into a host variable list. List of global The following table lists the global variables available in Adaptive Server variables Anywhere Variable name...
Page 272
The following list includes all Adaptive Server Enterprise global variables supported in Adaptive Server Anywhere. Adaptive Server Enterprise global variables not supported by Adaptive Server Anywhere are not included in the list. In contrast to the above table, this list includes all global variables that return a value, including those for which the value is fixed at NULL, 1, -1, or 0, and may not be meaningful.
Page 273
@@idle In Adaptive Server Enterprise, the amount of time, in ticks, that Adaptive Server Enterprise has been idle since it was last started. In Adaptive Server Anywhere, returns 0 @@io_busy In Adaptive Server Enterprise, the amount of time, in ticks, that Adaptive Server Enterprise has spent doing input and output operations since it was last started.
Page 274
Global variable Returns @@ncharsize In Adaptive Server Enterprise, average length, in bytes, of a national character. In Adaptive Server Anywhere, returns 1 @@nestlevel In Adaptive Server Enterprise, nesting level of current execution (initially 0). Each time a stored procedure or trigger calls another stored procedure or trigger, the nesting level is incremented.
Page 275
Chapter 6 SQL Language Elements Global variable Returns to activate a threshold. In Adaptive Server Anywhere, returns 0 @@timeticks In Adaptive Server Enterprise, number of microseconds per tick. The amount of time per tick is machine-dependent. In Adaptive Server Anywhere, returns 0...
Page 276
Variables @@identity and When an insert causes referential integrity actions or fires a trigger, triggers @@identity behaves like a stack. For example, if an insert into a table (with an identity or autoincrement column) fires a trigger that inserts a row into table (also with an identity or autoincrement column), then the value returned to the application or procedure which carried out the insert is the...
Comments Comments are used to attach explanatory text to SQL statements or statement blocks. The database server does not execute comments. Several comment indicators are available in Adaptive Server Anywhere. ♦ The database server ignores any remaining -- (Double hyphen) characters on the line.
NULL value NULL value Function To specify a value that is unknown or not applicable. Syntax NULL Usage Anywhere. Permissions Must be connected to the database. Side effects None. See also "Expressions" on page 230 "Search conditions" on page 239 Description The NULL value is a special value which is different from any valid value for any data type.
Page 279
You should use IS NULL rather than a comparison operator for compatibility. Unique indexes in Adaptive Server Anywhere can hold rows that hold NULL and are otherwise identical. Adaptive Server Enterprise does not permit such entries in unique indexes.
Page 280
NULL value INSERT INTO Borrowed_book ( date_borrowed, date_returned, book ) VALUES ( CURRENT DATE, NULL, ’1234’ )
C H A P T E R SQL Data Types About this chapter This chapter describes the data types supported by Adaptive Server Anywhere. Contents Topic Page Character data types Numeric data types Money data types Bit data type Date and time data types Binary data types Domains Java class data types...
For storing strings of letters, numbers and symbols. Description Adaptive Server Anywhere treats CHAR, VARCHAR, and LONG VARCHAR columns all as the same type. Values up to 254 characters are stored as short strings, with a preceding length byte. Any values that are longer than 255 bytes are considered long strings.
Page 283
Compatibility The CHARACTER (n) alternative for CHAR is not supported in Adaptive Server Enterprise. ♦ Adaptive Server Anywhere does not support the NCHAR and NVARCHAR data types provided by Adaptive Server Enterprise. CHAR data type [Character] Function Character data of maximum length max-length bytes.
Page 284
SQL/92 Compatible with SQL/92. compatibility ♦ Compatible with Adaptive Server Enterprise. The maximum Sybase max-length for Adaptive Server Enterprise is 255. "CHAR data type" on page 265 See also "LONG VARCHAR data type" on page 266 LONG VARCHAR data type [Character] Function Arbitrary length character data.
Page 285
Chapter 7 SQL Data Types See also "LONG VARCHAR data type" on page 266...
For Adaptive Server Enterprise, REAL is used for p less than or equal to 15, and DOUBLE for p greater than 15. For Adaptive Server Anywhere, the cutoff is platform-dependent, but on all platforms the cutoff value is greater than 15.
Page 287
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. See also "INT or INTEGER data type" on page 271 "TINYINT data type" on page 273 "SMALLINT data type" on page 273 DECIMAL data type [Numeric]...
Page 288
♦ Standards and Compatible with SQL/92. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "FLOAT data type" on page 270 "REAL data type" on page 272 "DECIMAL data type" on page 269 FLOAT data type [Numeric] Function A floating point number, which may be single or double precision.
Page 289
SQL/92 Compatible with SQL/92. compatibility ♦ You can tune the behavior of the FLOAT data type for Sybase compatibility with Adaptive Server Enterprise, using the "FLOAT_AS_DOUBLE option" on page 187. See also "DECIMAL data type" on page 269 "REAL data type" on page 272 "DOUBLE data type"...
Page 290
Standards and Compatible with SQL/92, if the SCALE option is set to zero. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "FLOAT data type" on page 270 "REAL data type" on page 272 "DOUBLE data type" on page 270...
Page 291
Chapter 7 SQL Data Types ♦ Standards and Compatible with SQL/92.. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. SMALLINT data type [Numeric] Function Integer value requiring 2 bytes of storage. Syntax [ UNSIGNED ] SMALLINT Usage The SMALLINT data type is an exact numeric data type; its accuracy is preserved after arithmetic operations.
Page 292
Numeric data types ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "BIGINT data type" on page 268 "TINYINT data type" on page 273 "SMALLINT data type" on page 273...
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Monetary data types in Adaptive Server Anywhere are Sybase implemented as domains, and are primarily intended for compatibility with Adaptive Server Enterprise. See also "SMALLMONEY data type" on page 275 SMALLMONEY data type [Money]...
By default, columns of BIT data type do not allow NULL. This behavior is different from other data types. You can explicitly allow NULL if desired. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise.
♦ As a string interpreted according to the DATE_ORDER database option Transact-SQL compatibility of string-to-date/time conversions There are some differences in behavior between Adaptive Server Anywhere and Adaptive Server Enterprise, when converting strings to date and time data types. If a string containing only a time value (no date) is converted to a date/time data type, Adaptive Server Enterprise uses a default date of January 1, 1900, but Adaptive Server Anywhere uses the current date.
Page 296
12.34.56.78 to 12:34:56.780 12.34.56:78 to 12:34:56.078 12:34:56.789 to 12:34:56.789 12:34:56:789 to 12:34:56.789 Adaptive Server Anywhere converts the milliseconds value in the manner that Adaptive Server Enterprise does for values preceded by a period, in both cases: 12:34:56.7 to 12:34:56.700 12:34:56:7 to 12:34:56.700 12.34.56.78 to 12:34:56.780...
Page 297
Chapter 7 SQL Data Types ♦ timestamp + integer Add the specified number of days to a date or timestamp. ♦ timestamp - integer Subtract the specified number of days from a date or timestamp. ♦ Compute the number of days between two dates or date - date timestamps.
Page 298
Date and time data types For combinations of dates and times, any unambiguous date and any unambiguous time yield an unambiguous date-time value. Also, the form YYYY-MM-DD HH.MM.SS.SSS is an unambiguous date-time value. Periods can be used in the time only in combination with a date.
Page 299
Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase See also "DATE_FORMAT option" on page 181 "DATE_ORDER option" on page 183 "DATETIME data type" on page 281 "SMALLDATETIME data type" on page 282 "TIMESTAMP data type" on page 283 "TRUNCATE_DATE_VALUES option"...
Page 300
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. For an exception, see "Transact-SQL compatibility of string-to-date/time conversions" on page 277. See also "DATE data type" on page 281 "SMALLDATETIME data type" on page 282 "TIMESTAMP data type"...
Page 301
Chapter 7 SQL Data Types ♦ Sybase Not supported by Adaptive Server Enterprise. See also "TIMESTAMP data type" on page 283 TIMESTAMP data type [Date and Time] Function The point in time, containing year, month, day, hour, minute, second and fraction of a second.
Standards and SQL/92 Vendor extension. compatibility ♦ Adaptive Server Enterprise supports max-length up to 255. Sybase See also "LONG BINARY data type" on page 284 "VARBINARY data type" on page 285 LONG BINARY data type [BINARY] Function Arbitrary length binary data.
Page 303
IMAGE data type [BINARY] Function LONG BINARY data allowing NULL. Syntax IMAGE Usage IMAGE is implemented in Adaptive Server Anywhere as a domain, as LONG BINARY allowing NULL. It is provided primarily for compatibility with Adaptive Server Enterprise. ♦ Standards and SQL/92 Vendor extension.
DEFAULT values and CHECK conditions. Some domains, such as the monetary data types, are pre- defined in Adaptive Server Anywhere, but you can add more of your own. Domains, sometimes called user-defined data types, allow columns...
Page 305
NOT NULL condition, a default value, and a CHECK condition. Named constraints and named defaults are not supported. ♦ In Adaptive Server Anywhere, you can use the Creating data types sp_addtype system procedure to add a domain, or you can use the CREATE DOMAIN statement.
Users with DBA permission can install compiled Java classes into a database. Not all standard Adaptive Server Anywhere supports JDK 1.1.6, but not all standard Java Java classes are classes from JDK 1.1.6 are supported. This is intentional. Some classes are supported not supported for security reasons.
Page 307
JDBC features" on page 593 of the book ASA User’s Guide. ♦ java.text ♦ java.util ♦ java.util.zip Unsupported Java packages and classes Classes in the following packages are not supported in the Sybase VM: ♦ java.applet ♦ java.awt ♦ java.awt.datatransfer ♦...
Page 308
, type the following at a command prompt: javac MyFirstClass.java Once you have a compiled Java class file, you can install it into the database. Installing a class You can do this conveniently using either Sybase Central or Interactive SQL.
Page 309
Chapter 7 SQL Data Types v To install a class, using Sybase Central: From Sybase Central, connect to the database as a user ID with DBA permissions. Open the Java Objects folder, and double-click Add Java Class or Jar. Follow the instructions in the wizard to install the class.
Page 310
Java class data types id INT NOT NULL PRIMARY KEY, mycol MyClass ) In this statement, the data type is a SQL data type, but is case- MyClass sensitive, as Java is a case-sensitive language. Inserting Java You can insert a Java object into a table just as you would any other row, objects using the INSERT statement.
Chapter 7 SQL Data Types Data type conversions Type conversions can happen automatically, or they can be explicitly requested using the CAST or CONVERT function. If a string is used in a numeric expression or as an argument to a function that expects a numeric argument, the string is converted to a number.
Java / SQL data type conversion Java / SQL data type conversion When a Java class field or method is invoked within a SQL statement, a Java data type is returned by the Java object. This must be converted into a SQL data type for use within the SQL statement, for example in comparisons.
Page 313
Chapter 7 SQL Data Types Java type SQL type java.lang.Double DOUBLE java.lang.Float REAL java.lang.Integer INTEGER java.lang.Long INTEGER void this* * The method returns the object itself SQL-to-Java data type conversion SQL type Java type CHAR String VARCHAR String TEXT String NUMERIC java.math.BigDecimal DECIMAL...
Page 314
Java / SQL data type conversion SQL type Java type LONG VARBINARY byte[ ] IMAGE byte[ ] DATE java.sql.Date TIME java.sql.Time TIMESTAMP java.sql.Timestamp...
Server Anywhere, and how Adaptive Server Anywhere handles ambiguous date information, such as the conversion of a two digit year string value. Users of Sybase Adaptive Server Anywhere and its predecessors can be assured that dates are handled and stored internally in a manner not adversely effected by the transition from the 20th century to the 21st century.
Page 316
"Date and time data types" on page 277. Sending and retrieving date values Date values are stored within Adaptive Server Anywhere as either a DATE or TIMESTAMP data type, but they are passed to and retrieved from Adaptive Server Anywhere using one of the following methods: ♦...
Page 317
The following SQL statement results in a return value of "Tuesday": SELECT DAYNAME(’2000-02-29’); Adaptive Server Anywhere accepts Feb 29, 2000 — a leap year — as a date, and using this date determines the day of the week. However, the following statement is rejected by Adaptive Server Anywhere: SELECT DAYNAME(’2001-02-29’);...
Page 318
Date to string conversions Adaptive Server Anywhere provides several functions for converting Adaptive Server Anywhere date and time values into a wide variety of strings and other expressions. It is possible in converting a date value into a string to reduce the year portion into a two digit number representing the year, thereby losing the century portion of the date.
Page 319
AS Wrong_year; Although the unambiguous date string 2000-01-01 is automatically and correctly converted by Adaptive Server Anywhere into a date value, the ’Mmm dd/yy’ formatting of the inner, or nested, DATEFORMAT function drops the century portion of the date when it is converted back to a string and passed to the outer DATEFORMAT function.
C H A P T E R SQL Functions About this chapter Functions are used to return information from the database. They are allowed anywhere an expression is allowed. NULL parameters Unless otherwise stated, any function that receives NULL as a parameter returns NULL.
"SUM function" on page 370 Data type conversion functions These functions convert arguments from one data type to another. ♦ The Adaptive Server Anywhere cast function is not currently supported Compatibility by Adaptive Server Enterprise. List of functions The following data type conversion functions are available: ♦...
Page 323
Chapter 8 SQL Functions In this chapter, the term datetime is used to mean date or time or timestamp. The specific data type DATETIME is indicated as DATETIME. For more information on datetime data types, see "Date and time data types"...
Page 324
Function types ♦ "YMD function" on page 376 Date parts Many of the date functions use dates built from date parts. The following table displays allowed values of date-parts. Date Part Abbreviation Values Year 1753 – 9999 Quarter 1 - 4 Month 1 - 12 Week...
Chapter 8 SQL Functions User-defined You can implement your own functions in SQL using the "CREATE functions in SQL FUNCTION statement" on page 445. The RETURN statement inside the CREATE FUNCTION statement determines the data type of the function. Once a SQL user-defined function is created, it can be used anywhere a built-in function of the same data type is used.
Page 326
Function types ♦ "PLAN function" on page 356 ♦ "TRACEBACK function" on page 371 Numeric functions Numeric functions perform mathematical operations on numerical data types or return numeric information. List of functions The following numeric functions are available: ♦ "ABS function" on page 313 ♦...
Page 327
Chapter 8 SQL Functions ♦ "TAN function" on page 370 ♦ "TRUNCATE function" on page 372 ♦ "TRUNCNUM function" on page 373 String functions String functions perform conversion, extraction or manipulation operations on strings, or return information about strings. When working in a multi-byte character set, check carefully whether the function being used returns information concerning characters or bytes.
"PROPERTY function" on page 357 ♦ "PROPERTY_DESCRIPTION function" on page 356 ♦ "PROPERTY_NAME function" on page 358 ♦ "PROPERTY_NUMBER function" on page 358 Compatibility The following table shows the Adaptive Server Enterprise system functions and their status in Adaptive Server Anywhere:...
Page 329
Chapter 8 SQL Functions Function Status Col_length Implemented Col_name Implemented Curunreservedpgs Not implemented Data_pgs Not implemented Datalength Implemented Db_id Implemented Db_name Implemented Host_id Not implemented Host_name Not implemented Index_col Implemented Lct_admin Not implemented Object_id Implemented Object_name Implemented Proc_role Always returns 0 Reserved_pgs Not implemented Rowcnt...
Page 330
Text and image functions operate on text and image data types. Adaptive Server Adaptive Server Anywhere supports only the text and image textptr function. ♦ Adaptive Server Anywhere does not currently support the Adaptive Compatibility Server Enterprise textvalid function. List of functions The following text and image function is available: ♦...
The following statement returns the value 66. SELECT ABS( -66 ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. ACOS function [Numeric] Function Returns the arc-cosine, in radians, of a numeric expression. Syntax ACOS ( numeric-expression ) Parameters numeric expression The cosine of the angle.
Page 332
NULL is returned. Multiple expressions are separated by a comma. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ASCII function [String] Function Returns the integer ASCII value of the first byte in a string-expression. Syntax ASCII ( string-expression ) Parameters string-expression The string.
Page 333
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "ACOS function" on page 313 "ATAN function" on page 315 "ATN2 function" on page 315 "SIN function" on page 365 ATAN function [Numeric] Function Returns the arc-tangent, in radians, of a number.
Page 334
Standards and SQL/92 Vendor extension. compatibility ♦ ATN2 is compatible with Adaptive Server Enterprise. Sybase ATAN2 is not supported by Adaptive Server Enterprise. See also "ACOS function" on page 313 "ASIN function" on page 314 "ATAN function" on page 315 "TAN function"...
Page 335
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase See also "CHAR_LENGTH function" on page 320 "DATALENGTH function" on page 325 "LENGTH function" on page 344 BYTE_SUBSTR function [String] Function Returns a substring of a string. The substring is calculated using bytes, not characters.
Page 336
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. See also "SUBSTRING function" on page 369 CAST function [Data type conversion] Function Returns the value of an expression converted to a supplied data type.
Page 337
Chapter 8 SQL Functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "FLOOR function" on page 338 CHAR function [String] Function Returns the character with the ASCII value of a number. Syntax...
Page 338
If the string being searched does not contain the other string, then CHARINDEX returns 0. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "SUBSTRING function" on page 369 CHAR_LENGTH function [String] Function Returns the number of characters in a string. Syntax...
Page 339
SELECT COALESCE( NULL, 34, 13, 0 ) ♦ Standards and SQL/92. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. CONNECTION_PROPERTY function [System] Function Returns the value of a given connection property as a string. Syntax CONNECTION_PROPERTY ( { integer-expression | string-expression } ...
Page 340
Alphabetical list of functions CONVERT function [Data type conversion] Returns an expression converted to a supplied data type. Function Syntax CONVERT ( data type , expression [ , format-style ] ) Parameters data type The data type to which the expression will be converted. expression The expression to be converted.
Page 341
5: SELECT CONVERT( integer, 5.2 ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "CAST function" on page 318 COS function [Numeric] Returns the cosine of a number. Function Syntax COS ( numeric-expression )
Page 342
0.86781. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "ACOS function" on page 313 "COT function" on page 324 "SIN function" on page 365 "TAN function" on page 370 COT function [Numeric] Returns the cotangent of a number.
Page 343
SQL/92 compatible. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "AVG function " on page 316 "SUM function" on page 370 DATALENGTH function [System] Returns the length in bytes of the underlying storage for the result of an Function expression.
Page 344
Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase DATEADD function [Date and time] Returns the date produced by adding a number of the date parts to a date. Function Syntax DATEADD ( date-part , numeric-expression , date-expression )
Page 345
Chapter 8 SQL Functions date-expression1 The starting date for the interval. This value is subtracted from date-expression2 to return the number of date-parts between the two arguments. date-expression2 The ending date for the interval. Date-expression1 is subtracted from this value to return the number of date-parts between the two arguments.
Page 346
The function returns an overflow error if you exceed these limits. ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. DATEFORMAT function [Date and time] Returns a string representing a date-expression in the specified format. Function Syntax DATEFORMAT ( datetime-expression , string-expression )
Page 347
♦ Standards and SQL/92 Transact-SQL extension. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase DATEPART function [Date and time] Returns the value of part of a datetime value. Function Syntax DATEPART ( date-part , date-expression ) Parameters date-part The date-part to be returned.
Page 348
Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase DAY function [Date and time] Returns an integer from 1 to 31 corresponding to the day of the month of a Function date. Syntax DAY ( date-expression )
Page 349
SELECT DAYS( CAST(’1998-07-13’ AS DATE ), 366 ) ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase DB_ID function [System] Returns the database ID number. Function Syntax DB_ID ( [ database-name ] ) Parameters database-name A string containing the database name.
Page 350
Alphabetical list of functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. DB_NAME function [System] Returns the name of a database with a given ID number. Function Syntax DB_NAME ( [ database-id ] )
Page 351
Chapter 8 SQL Functions ♦ Sybase Not supported by Adaptive Server Enterprise. See also "DB_ID function" on page 331 "DB_NAME function " on page 332 "Database-level properties" on page 1101 DEGREES function [Numeric] Converts a number from radians to degrees.
Page 352
Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ESTIMATE function [Miscellaneous] Function Provides selectivity estimates for the query optimizer, based on specified parameters. Syntax ESTIMATE ( column-name [ , value [, relation-string ] ] )
Page 353
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. See also "Query Optimization" on page 835 of the book ASA User’s Guide EVENT_CONDITION function [System] To specify when an event handler is triggered. Function...
Page 354
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase See also "CREATE EVENT statement" on page 435 EVENT_CONDITION_NAME function [System] Can be used to list the possible parameters for EVENT_CONDITION. Function Syntax EVENT_CONDITION_NAME ( integer )
Page 355
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. See also "EVENT_CONDITION function" on page 335 "CREATE EVENT statement" on page 435 EXP function [Numeric] Returns the exponential function, e to the power of a number.
Page 356
Alphabetical list of functions ♦ Sybase Compatible with Adaptive Server Enterprise. EXPERIENCE_ESTIMATE function [Miscellaneous] This function is the same as the ESTIMATE function, except that it always Function looks in the frequency table. Syntax EXPERIENCE_ESTIMATE ( column-name [ , value [, relation-string ] ] )
Page 357
The following statement returns the system date and time. SELECT GETDATE( ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. HEXTOINT function [Data type conversion] Returns the decimal integer equivalent of a hexadecimal string. Function Syntax HEXTOINT ( hexadecimal-string ) Parameters hexadecimal-string The string to be converted to an integer.
Page 358
Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. IFNULL function [Miscellaneous] If the first expression is the NULL value, then the value of the second Function expression is returned. If the first expression is not NULL, the value of the third expression is returned.
Page 359
SELECT IFNULL( -66, -66 ) ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. INDEX_ESTIMATE function [Miscellaneous] This function is the same as the ESTIMATE function, except that it always Function looks only in an index. Syntax...
Page 360
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported in Adaptive Server Enterprise. Sybase See also "STUFF function" on page 368 INTTOHEX function [Data type conversion] Function Returns a string containing the hexadecimal equivalent of an integer. Syntax INTTOHEX ( integer-expression )
Page 361
SQL/92 Vendor extension. compatibility ♦ LCASE is not supported in Adaptive Server Enterprise; you Sybase can use LOWER to get the same functionality. See also "LOWER function" on page 346 "UCASE function" on page 373 "UPPER function" on page 374 LEFT function [String] Returns a number of characters from the beginning of a string.
Page 362
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase See also "BYTE_LENGTH function" on page 316 "International Languages and Character Sets" on page 287 of the book ASA User’s Guide LIST function [Aggregate] Function...
Page 363
LIST(X) returns the empty string. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported in Adaptive Server Enterprise. Sybase LOCATE function [String] Function Returns the position of one string within another. Syntax LOCATE ( string-expression-1 , string-expression-2 [, integer-expression ] ) Parameters string-expression-1 The string to be searched.
Page 364
The following statement returns the value 3.912023. SELECT LOG( 50 ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "LOG10 function" on page 346 LOG10 function [Numeric] Returns the base 10 logarithm of a number. Function Syntax...
Page 365
Standards and SQL/92 Vendor extension. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "RTRIM function" on page 363 "TRIM function" on page 372 MAX function [Aggregate] Returns the maximum expression value found in each group of rows. Function...
Page 366
Standards and SQL/92 SQL/92 compatible. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "MAX function" on page 347 MINUTE function [Date and time] Returns a number from 0 to 59 corresponding to the minute component of a Function datetime value.
Page 367
AS DATETIME ), 5) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase MOD function [Numeric] Returns the remainder when one whole number is divided by another. Function Syntax MOD ( dividend , divisor ) Parameters dividend The dividend, or numerator of the division.
Page 368
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. The % operator is used as a modulo operator in Adaptive Server Enterprise. See also "REMAINDER function" on page 360 MONTH function [Date and time] Returns a number from 1 to 12 corresponding to the month of the given date.
Page 369
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase NEXT_CONNECTION function [System] Returns an identifying number for a connection. Function Syntax NEXT_CONNECTION ( [ connection-id ] [, database-id ] ) Parameters connection-id An integer, usually returned from a previous call to NEXT_CONNECTION.
Page 370
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase NEXT_DATABASE function [System] Returns an identifying number for a database. Function Syntax NEXT_DATABASE ( { NULL | database-id } ) Parameters database-id An integer that specifies the ID number of the database.
Page 371
♦ Standards and SQL/92 Transact-SQL extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase NOW function [Date and time] Returns the current date and time. This is the historical syntax for Function CURRENT TIMESTAMP. Syntax NOW ( * ) Examples The following statement returns the current date and time.
Page 372
Generates numbers starting at 1 for each successive row in the results of the query. Deprecated feature The NUMBER function is deprecated. It will not be supported in future versions of Adaptive Server Anywhere. Syntax NUMBER ( * ) Examples The following statement returns a numbered list.
Page 373
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Compatible with Adaptive Server Enterprise, except that the Sybase USING clause is not supported. See also "LIKE conditions" on page 241 "LOCATE function" on page 345 PI function [Numeric] Function Returns the numeric value PI.
Page 374
Standards and SQL/92 Vendor extension. compatibility ♦ The PI() function is supported in Adaptive Server Enterprise, Sybase but PI(*) is not. PLAN function [Miscellaneous] Returns the optimization strategy of a SQL statement, as a string. Function Syntax PLAN ( string-expression )
Page 375
Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase See also "Database Performance and Connection Properties" on page 1081 PROPERTY function [System] Function Returns the value of the specified server-level property as a string. Syntax...
Page 376
SELECT PROPERTY_NAME( 126 ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. See also "Database properties" on page 1090 PROPERTY_NUMBER function [System] Function Returns the property number of the property with the supplied property- name.
Page 377
July 1 to September 30 October 1 to December 31 ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. RADIANS function [Numeric] Converts a number from degrees to radians. Function RADIANS ( numeric-expression ) Syntax Parameters numeric-expression A number, in degrees.
Page 378
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. The % (modulo) operator and the division operator can be used to produce a remainder. See also "MOD function" on page 349 REPEAT function [String] Concatenates a string a specified number of times.
Page 379
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "SUBSTRING function" on page 369 REPLICATE function [String] Function Concatenates a string a specified number of times. Syntax REPLICATE ( string-expression , integer-expression )
Page 380
Alphabetical list of functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. See also "REPEAT function" on page 360 RIGHT function [String] Function Returns the rightmost characters of a string. Syntax RIGHT ( string-expression , integer-expression )
Page 381
SELECT ROUND( 123.234, 1 ) ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "TRUNCNUM function" on page 373 RTRIM function [String] Returns a string with trailing blanks removed. Function Syntax RTRIM ( string-expression )
Page 382
AS TIMESTAMP ), 5) ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase SIGN function [Numeric] Returns the sign of a number. Function Syntax SIGN ( numeric-expression ) Parameters numeric-expression The number for which the sign is to be returned.
Page 383
Chapter 8 SQL Functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. SIMILAR function [String] Returns a number indicating the similarity between two strings. Function Syntax SIMILAR ( string-expression-1 , string-expression-2 ) Parameters string-expression-1 The first string to be compared.
Page 384
Standards and Vendor extension. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise, except that Sybase Adaptive Server Enterprise returns a CHAR(4) result and Adaptive Server Anywhere returns an integer. SPACE function [Miscellaneous] Returns a specified number of spaces. Function Syntax...
Page 385
Chapter 8 SQL Functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. SQRT function [Miscellaneous] Returns the square root of a number. Function Syntax SQRT ( numeric-expression ) Parameters numeric-expression The number for which the square root is to be calculated.
Page 386
Alphabetical list of functions ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Compatible with Adaptive Server Enterprise. STRING function [String] Concatenates one or more strings into one large string. Function Syntax STRING ( string-expression [, ...] ) Parameters string-expression A string.
Page 387
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "INSERTSTR function" on page 341 SUBSTRING function [String] Function Returns a substring of a string. Syntax { SUBSTRING | SUBSTR }( string-expression , start [, length ] )
Page 388
Returns NULL for a group containing no rows. ♦ Standards and SQL/92 SQL/92 compatible. compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase See also "COUNT function " on page 324 "AVG function " on page 316 TAN function [Numeric] Function Returns the tangent of a number. Syntax...
Page 389
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Compatible with Adaptive Server Enterprise. Sybase TODAY function [Date and time] Function Returns the current date. This is the historical syntax for CURRENT DATE. Syntax TODAY ( * ) Examples The following statement returns the current day according to the system clock.
Page 390
This is useful for debugging procedures and triggers Usage ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. TRIM function [String] Function Removes leading and trailing blanks from a string. Syntax TRIM ( string-expression ) Parameters string-expression The string to be trimmed.
Page 391
QUOTED_IDENTIFIER option is set to OFF. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. See also "QUOTED_IDENTIFIER option" on page 207 "TRUNCNUM function" on page 373 TRUNCNUM function [Numeric] Function Truncates a number at a specified number of places after the decimal point.
Page 392
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase UCASE is not supported by Adaptive Server Enterprise, but UPPER provides the same feature in a compatible manner. See also "UPPER function" on page 374 "LCASE function" on page 343 UPPER function [String] Function Converts all characters in a string to upper case.
Page 393
Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase YEARS function [Date and time] Function Returns the number of years since an arbitrary date and time, between two specified times, or adds the specified integer-expression amount of years to a datetime.
Page 394
Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase YMD function [Date and time] Function Returns a date value corresponding to the given year, month, and day of the month. Syntax YMD ( integer-expression , integer-expression , integer-expression )
About this chapter This chapter presents detailed descriptions of the SQL statements that are available to users of Adaptive Server Anywhere. This chapter contains an alphabetical listing of SQL statements, including some that can only be used from embedded SQL or Interactive SQL.
Using the SQL statement reference Using the SQL statement reference This section describes some conventions used in documenting the SQL statements. Common elements in SQL syntax This section lists language elements that are found in the syntax of many SQL statements. For more information on the elements described here, see "Identifiers"...
Page 397
Chapter 9 SQL Statements ♦ role-name An identifier representing the role name of a foreign key. ♦ An identifier that represents the name of a savepoint. savepoint-name ♦ search-condition A condition that evaluates to TRUE, FALSE, or UNKNOWN. ♦ One of the special values described in "Special values" special-value on page 247.
Page 398
Using the SQL statement reference ♦ Optional portions Optional portions of a statement are enclosed by square brackets. RELEASE SAVEPOINT [ savepoint-name ] These square brackets indicate that the savepoint-name is optional. The square brackets should not be typed. ♦ Options When none or only one of a list of items can be chosen, vertical bars separate the items and the list is enclosed in square...
C code prior to using this statement: struct sqlda * descriptor_name ♦ Standards and Entry-level feature. SQL/92 compatibility ♦ Sybase Supported by Open Client/Open Server. Example The following sample program includes an example of ALLOCATE DESCRIPTOR statement usage. #include <stdio.h> #include <stdlib.h> #include <string.h>...
Page 400
ALLOCATE DESCRIPTOR statement [ESQL] if( !db_init( &sqlca ) ) { return 1; db_string_connect( &sqlca, "UID=dba;PWD=sql;DBF=d:\\asa6\\sample.db"); EXEC SQL ALLOCATE DESCRIPTOR sqlda1 WITH MAX 25; EXEC SQL PREPARE :stmt FROM ’SELECT * FROM employee’; EXEC SQL DECLARE curs CURSOR FOR :stmt; EXEC SQL OPEN curs; EXEC SQL DESCRIBE :stmt into sqlda1;...
You cannot use ALTER DATABASE to just add Java or jConnect features if the database was created with the current version of the software. In order to add these features to a database created with the current version of the software, you must use Sybase Central or Interactive SQL.
Page 402
613 of the book ASA User’s Guide. Parameters JAVA clause The JAVA clause adds the entries for the Sybase runtime Java classes to the system tables (JAVA ON) or does not (JAVA OFF). By default, the classes are added during the upgrade. Setting JAVA OFF does not remove Java support from a database.
Adaptive Server Anywhere where to find the main database file. The main database file (which has the dbspace name SYSTEM) holds the system tables. Adaptive Server Anywhere looks in these system tables to find the location of the other dbspaces, and Adaptive Server Anywhere then opens each of the other dbspaces.
Page 404
♦ Standards and SQL/92 Vendor extension compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Examples Increase the size of the SYSTEM dbspace by 200 pages. ALTER DBSPACE system ADD 200 ♦ Rename the file for dbspace...
Chapter 9 SQL Statements ALTER EVENT statement Function Use this statement to change the definition of an event or its associated handler for automating predefined actions. Also, to alter the definition of scheduled actions. Syntax ALTER EVENT event-name [ DELETE TYPE | TYPE event-type ] WHERE { trigger-condition | NULL } | { ADD | [ MODIFY ] | DELETE } SCHEDULE schedule-spec [ ENABLE | DISABLE ]...
Page 406
ALTER EVENT statement "CREATE EVENT statement" on page 435 Description This statement allows you to alter an event definition created with CREATE EVENT. Possible uses include the following: ♦ You can use ALTER EVENT to change an event handler during development.
Syntax 2 If a procedure is to be replicated to other sites using Sybase Replication Server, you must set REPLICATE ON for the procedure. Syntax 2 of the ALTER PROCEDURE statement has the same effect as the sp_setreplicate sp_setrepproc ’table’...
ALTER SERVER statement ALTER SERVER statement Function Use this statement to modify the attributes of a remote server. ALTER SERVER server-name Syntax [ CLASS ’ server-class ’ ] [ USING ’ connection-info ’ ] [ CAPABILITY ’ cap-name ’ { ON | OFF } ] server-class : { ASAJDBC | ASEJDBC | ASAODBC | ASEODBC...
Page 409
At the first connection, Adaptive Server Anywhere interrogates the server about its capabilities and then populates the syscapability table. For subsequent connections, the server’s capabilities are obtained from this table.
ALTER TABLE statement ALTER TABLE statement Function Use this statement to modify a table definition or to enable a table to take part in Replication Server replication. Syntax 1 ALTER TABLE [ owner .] table-name … ADD column-definition [ column-constraint … ] | ADD table-constraint | MODIFY column-definition | MODIFY column-name DEFAULT default-value...
Page 412
If the column has a default value, all rows of the new column are populated with that default value. NULL values Adaptive Server Anywhere optimizes the creation of columns that are allowed to contain NULL. The first column allowed to contain NULL allocates room for eight such columns, and initializes all eight to be NULL.
Page 413
Chapter 9 SQL Statements If PRIMARY KEY is specified, the table must not already have a primary key that was created by the CREATE TABLE statement or another ALTER TABLE statement. MODIFY column-definition Change the length or data type of an existing column in a table.
Page 414
♦ Standards and Intermediate level feature. MODIFY are not SQL/92 SQL/92 compatibility compliant. ♦ Sybase Some clauses are supported by Adaptive Server Enterprise. ♦ Examples Add a new column to the employee table showing which office they work in.
Page 415
Chapter 9 SQL Statements ♦ Drop the office column from the employee table. ALTER TABLE employee DELETE office ♦ The address column in the customer table can currently hold up to 35 characters. Allow it to hold up to 50 characters. ALTER TABLE customer MODIFY address CHAR(50) ♦...
"CREATE TRIGGER statement" on page 477 and "CREATE TRIGGER statement" on page 480. Either the Transact-SQL or Watcom-SQL form of the CREATE TRIGGER syntax can be used. ♦ Standards and SQL/92 Vendor extension compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase...
VIEW is used, instead of ALTER VIEW, permissions on the view would have to be reassigned. For information on the keywords and options, see "CREATE VIEW statement" on page 482. ♦ Standards and Vendor extension SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase...
"Strings" on page 224. ♦ Standards and SQL/92 Vendor extension compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement changes the existing write file c:\readwrite.wrt to point to the database file h:\readonly.db ALTER WRITEFILE ’c:\\readwrite.wrt’...
Chapter 9 SQL Statements BACKUP statement Function Use this statement to back up a database and transaction log. Syntax 1 (image BACKUP DATABASE DIRECTORY backup-directory backup) [ WAIT BEFORE START ] [ DBFILE ONLY ] [ TRANSACTION LOG ONLY ] [ TRANSACTION LOG RENAME [ MATCH ] ] [ TRANSACTION LOG TRUNCATE ] backup-directory: string...
Page 420
BACKUP statement There can be only one backup on a given tape. The file records backup.syb the BACKUP and RESTORE operations that have been performed on a given server. The tape is ejected at the end of the backup. Archive backup is not supported on the Windows 95/98 operating system. Archive backups to disk are supported by all versions of NetWare, but archive backups to tape are not supported on versions of NetWare earlier than NetWare 5.
Page 421
Chapter 9 SQL Statements ATTENDED The clause applies only when backing up to a tape device. ATTENDED ON (the default) indicates that someone is available to monitor the status of the tape drive and to place a new tape in the drive when needed. A message is sent to the application that issued the BACKUP statement if the tape drive requires intervention.
BEGIN statement BEGIN statement Function Use this statement to group SQL statements together. Syntax [ statement-label : ] … BEGIN [ [ NOT ] ATOMIC ] … [ local-declaration ; … ] … statement-list … [ EXCEPTION [ exception-case … ] ] …...
Page 423
Persistent Stored Module feature. SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise. This does not mean that all statements inside a compound statement are supported. The BEGIN and END keywords are not required in Transact-SQL. BEGIN and END are used in Transact-SQL to group a set of statements into a single compound statement, so that control statements such as IF …...
Page 424
BEGIN statement CREATE PROCEDURE TopCustomer (OUT TopCompany CHAR(35), OUT TopValue INT) BEGIN DECLARE err_notfound EXCEPTION FOR SQLSTATE ’02000’; DECLARE curThisCust CURSOR FOR SELECT company_name, CAST( sum(sales_order_items.quantity * product.unit_price) AS INTEGER) VALUE FROM customer LEFT OUTER JOIN sales_order LEFT OUTER JOIN sales_order_items LEFT OUTER JOIN product GROUP BY company_name;...
You can control the mode by setting the CHAINED database option. The default setting for ODBC and embedded SQL connections in Adaptive Server Anywhere is ON, in which case Adaptive Server Anywhere runs in chained mode. (ODBC users should also check the AutoCommit ODBC setting).
Page 426
When Adaptive Server Enterprise starts a transaction implicitly, the @@trancount variable is set to 1. Adaptive Server Anywhere does not set the @@trancount value to 1 when a transaction is started implicitly. Consequently, the Adaptive Server Anywhere @@trancount variable has a...
Page 427
If a transaction is implicitly started with a different statement, and a BEGIN TRANSACTION statement is then executed, @@trancount has a value of 1 in Adaptive Server Anywhere, and a value of 2 in Adaptive Server Enterprise after the BEGIN TRANSACTION statement.
For information on returning non-integer values, see "CREATE FUNCTION statement" on page 445. ♦ Standards and Persistent Stored Module feature. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. For an Sybase alternative that is supported, see "EXECUTE statement" on page 516.
Page 429
Chapter 9 SQL Statements ♦ Examples Call the sp_customer_list procedure. This procedure has no parameters, and returns a result set. CALL sp_customer_list() ♦ The following Interactive SQL example creates a procedure to return the number of orders placed by the customer whose ID is supplied, creates a variable to hold the result, calls the procedure, and displays the result.
Persistent Stored Module feature. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase Example The following procedure using a case statement classifies the products listed in the product table of the sample database into one of shirt, hat, shorts, or unknown.
Page 431
Chapter 9 SQL Statements SELECT name INTO prod_name FROM "DBA"."product" WHERE id = product_id; CASE prod_name WHEN ’Tee Shirt’ THEN SET type = ’Shirt’ WHEN ’Sweatshirt’ THEN SET type = ’Shirt’ WHEN ’Baseball Cap’ THEN SET type = ’Hat’ WHEN ’Visor’ THEN SET type = ’Hat’...
It is not normally required for applications issue the CHECKPOINT statement. For a full description of checkpoints, see "Backup and Data Recovery" on page 645 of the book ASA User’s Guide. ♦ Standards and SQL/92 Vendor extension compatibility ♦ Supported by Adaptive Server Enterprise. Sybase...
Use this statement to clear the Interactive SQL Data window. Syntax CLEAR Permissions None. Side effects Closes the cursor associated with the data being cleared. Description The CLEAR statement is used to clear the Interactive SQL Data window. ♦ Standards and Vendor extension SQL/92 compatibility ♦ Sybase Not applicable...
This statement closes the named cursor. ♦ Standards and Entry-level feature. SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise. Examples The following examples close cursors in embedded SQL. EXEC SQL CLOSE employee_cursor; EXEC SQL CLOSE :cursor_var; The following procedure uses a cursor.
Page 435
Chapter 9 SQL Statements CustomerLoop: LOOP FETCH NEXT curThisCust INTO ThisCompany, ThisValue; IF SQLSTATE = err_notfound THEN LEAVE CustomerLoop; END IF; IF ThisValue > TopValue THEN SET TopValue = ThisValue; SET TopCompany = ThisCompany; END IF; END LOOP CustomerLoop; CLOSE curThisCust;...
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. Examples The following examples show how to add and remove a comment. ♦ Add a comment to the employee table. COMMENT ON TABLE employee IS ’Employee information’...
Page 437
Chapter 9 SQL Statements ♦ Remove the comment from the employee table. COMMENT ON TABLE employee IS NULL...
COMMIT statement COMMIT statement Function Use this statement to make changes to the database permanent, or to terminate a user-defined transaction. Syntax 1 COMMIT [ WORK ] Syntax 2 COMMIT TRAN[SACTION] [ transaction-name ] Permissions None. Side effects Closes all cursors except those opened WITH HOLD. Deletes all rows of declared temporary tables on this connection, unless they were declared using ON COMMIT PRESERVE ROWS..
Page 439
Chapter 9 SQL Statements For more information on transaction nesting in Adaptive Server Enterprise and Adaptive Server Anywhere, see "BEGIN TRANSACTION statement" on page 407. For more information on savepoints, see "SAVEPOINT statement" on page 600. You can use a set of options to control the detailed behavior of the COMMIT statement.
COMMIT. If you do not choose Permanent, and instead click OK, the options are set temporarily and remain in effect for the current database connection only. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase...
Chapter 9 SQL Statements CONNECT statement [ESQL] [Interactive SQL] Function Use this statement to establish a connection to a database. Syntax 1 CONNECT … [ TO engine-name ] … [ DATABASE database-name ] … [ AS connection-name ] … [ USER ] userid [ IDENTIFIED BY password ] engine-name | database-name | connection-name | userid | password : { identifier | string | host-variable } Syntax 2...
Page 442
CONNECT statement [ESQL] [Interactive SQL] Interactive SQL behavior If no database or server is specified in the CONNECT statement, Interactive SQL remains connected to the current database, rather than to the default server and database. If a database name is specified without a server name, Interactive SQL attempts to connect to the specified database on the current server.
Page 443
Syntax 1 is a full SQL feature; syntax 2 is a vendor extension. SQL/92 compatibility ♦ Open Client Embedded SQL supports a different syntax for Sybase the CONNECT statement. ♦ Examples The following are examples of CONNECT usage within Embedded SQL.
You cannot use this statement on files other than the main database file. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement creates a compressed database file named compress.db in the directory from a database file named full.db in the current working directory of the server.
Chapter 9 SQL Statements CREATE DATABASE statement Function Use this statement to create a database. The database is stored as an operating-system file. Syntax CREATE DATABASE db-file-name … [ … [ [ TRANSACTION ] LOG OFF | [ TRANSACTION ] LOG ON [ log-file-name-string ] [ MIRROR mirror-file-name-string ] …...
Page 446
A transaction log mirror is an identical copy of a transaction log, usually maintained on a separate device, for greater protection of your data. By default, Adaptive Server Anywhere does not use a mirrored transaction log. If you do wish to use a transaction log mirror, this option allows you to provide a filename.
Page 447
JAVA clause If you wish to use Java in your database, you must install entries for the Sybase runtime Java classes into the system tables. By default, these entries are installed. You can specify JAVA OFF if you are sure you will not be using Java, to avoid installing these entries.
Page 448
ENCRYPTED OFF BLANK PADDING OFF JAVA ON JCONNECT OFF ♦ The following statement creates a database with no Sybase runtime Java classes. All database operations will execute normally, except for those involving Java classes or objects. CREATE DATABASE ’C:\\nojava’ JAVA OFF...
(not a drive letter) when an absolute directory is specified. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example Create a dbspace called library to hold the LibraryBooks table and its indexes.
Page 450
CREATE DBSPACE statement CREATE TABLE LibraryBooks ( title char(100), author char(50), isbn char(30), ) IN library;...
Chapter 9 SQL Statements CREATE DOMAIN statement Function Use this statement to create a domain in a database. CREATE { DOMAIN | DATATYPE } [ AS ] domain-name data-type Syntax … [ [ NOT ] NULL ] … [ DEFAULT default-value ] …...
Page 452
♦ Standards and Intermediate level feature. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Transact-SQL Sybase provides similar functionality using the sp_addtype system procedure and the CREATE DEFAULT and CREATE RULE statements. ♦ Example The following statement creates a data type named address, which holds a 35-character string, and which may be NULL.
Chapter 9 SQL Statements CREATE EVENT statement Function Use this statement to define an event and its associated handler for automating predefined actions. Also, to define scheduled actions. Syntax CREATE EVENT event-name … [ TYPE event-type [ WHERE trigger-condition [ AND trigger-condition ], … ] | SCHEDULE schedule-spec , …...
Page 454
CREATE EVENT statement Event handlers execute on a separate connection, with the permissions of the event owner. To execute with permissions other than DBA, you can call a procedure from within the event handler: the procedure executes with the permissions of its owner. The separate connection does not count towards the ten-connection limit of the personal database server.
Page 455
Chapter 9 SQL Statements TYPE clause The event-type is one of the listed set of system-defined event types. The event types are case insensitive. To specify the conditions under which this event-type triggers the event, use the WHERE clause. ♦ DiskSpace event types If the database contains an event handler for one of the DiskSpace types, the database server checks the available...
Page 456
CREATE EVENT statement SCHEDULE clause This clause specifies when scheduled actions are to take place. The sequence of times acts as a set of triggering conditions for the associated actions defined in the event handler. You can create more than one schedule for a given event and its associated handler.
Page 457
Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. ♦ Examples Instruct the database server to carry out an automatic backup to tape using the first tape drive on a Windows NT machine, every day at 1 am.
Page 458
CREATE EVENT statement CREATE EVENT HourlyLogBackup SCHEDULE hourly_log_backup BETWEEN ’8:00AM’ EVERY 1 HOURS ON (’Mon’,’Tue’,’Wed’,’Thu’,’Fri’) HANDLER BEGIN BACKUP DATABASE TO ’c:\\database\\backup’ TRANSACTION LOG ONLY TRANSACTION LOG RENAME For more examples see "Defining trigger conditions for events" on page 501 of the book ASA User’s Guide.
Adaptive Server Anywhere. This establishes the remote table as a visible entity to Adaptive Server Anywhere users. Adaptive Server Anywhere verifies that the table exists at the external location before it creates the table.
Page 460
. Adaptive Server Anywhere derives the column list from the metadata it obtains from the remote table. CREATE EXISTING TABLE blurbs AT ’server_a.db1.joe.blurbs’ ♦ Create a proxy table named for the...
"DROP EXTERNLOGIN statement" on page 509 Description By default, Adaptive Server Anywhere uses the names and passwords of its clients whenever it connects to a remote server on behalf of those clients. CREATE EXTERNLOGIN assigns an alternate login name and password to be used when communicating with a remote server.
Page 462
CREATE EXTERNLOGIN statement ♦ Examples Map the local user named dba to the user sa with password Plankton when connecting to the server sybase1. CREATE EXTERNLOGIN dba TO sybase1 REMOTE LOGIN sa IDENTIFIED BY Plankton...
Chapter 9 SQL Statements CREATE FUNCTION statement Function Use this statement to create a new function in the database. CREATE FUNCTION [ owner .] function-name ( [ parameter , … ] ) Syntax RETURNS data-type EXTERNAL NAME library-call | EXTERNAL NAME java-call LANGUAGE JAVA | [ ON EXCEPTION RESUME ] …...
Page 464
For more information, see "CREATE PROCEDURE statement" on page 453. ♦ Standards and Persistent Stored Module feature. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. ♦ Example The following function concatenates a firstname string and a lastname string.
Page 465
Chapter 9 SQL Statements fullname (emp_fname, emp_lname) Fran Whitney Matthew Cobb Philip Chin Julie Jordan Robert Breault …...
CREATE INDEX statement CREATE INDEX statement Function Use this statement to create an index on a specified table. Indexes can improve database performance. Syntax CREATE [ UNIQUE ] INDEX index-name … ON [ owner .] table-name … ( column-name [ ASC | DESC ], … ) …[ WITH [ MAX | MAXIMUM ] HASH SIZE hash-size ] …...
Page 467
Chapter 9 SQL Statements ♦ Automatically created indexes Adaptive Server Anywhere automatically creates indexes for primary keys and for unique constraints. These automatically created indexes are held in the same database file as the table. Parameters UNIQUE keyword The UNIQUE attribute ensures that there will not be two rows in the table with identical values in all the columns in the index.
Page 468
♦ Adaptive Server Enterprise has a more complex CREATE Sybase INDEX statement than Adaptive Server Anywhere. While the Adaptive Server Enterprise syntax is permitted in Adaptive Server Anywhere, some clauses and keywords are ignored. The full syntax for Adaptive Server Enterprise 11.5 is as follows: CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] …...
Page 469
Physical placement of an index is carried out differently in Adaptive Server Enterprise and Adaptive Server Anywhere. The ON segment- name clause is supported in Adaptive Server Anywhere, but segment- name refers to a dbspace. Unique indexes in Adaptive Server Anywhere permit entries that contain NULL, and are otherwise identical.
"%2!" is the second argument, and so on. There is no parameter corresponding to the language argument for sp_addmessage. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase The functionality of CREATE MESSAGE is provided by the sp_addmessage procedure in Adaptive Server Enterprise.
Chapter 9 SQL Statements CREATE PROCEDURE statement Function Use this statement to create a procedure in the database. CREATE PROCEDURE [ owner .] procedure-name ( [ parameter , … ] ) Syntax { [ RESULT ( result-column , … ) ] …...
Page 472
CREATE PROCEDURE statement "GRANT statement" on page 540 "Using Procedures, Triggers, and Batches" on page 435 of the book ASA User’s Guide Description The CREATE PROCEDURE statement creates a procedure in the database. Users with DBA authority can create procedures for other users by specifying an owner.
Page 473
Chapter 9 SQL Statements Some procedures can more than one result set, with different numbers of columns, depending on how they are executed. For example, the following procedure returns two columns under some circumstances, and one in others. CREATE PROCEDURE names( IN formal char(1)) BEGIN IF formal = ’n’...
Page 474
CREATE PROCEDURE statement ♦ SELECT @variable = ♦ CASE ♦ LOOP ♦ LEAVE ♦ CONTINUE ♦ CALL ♦ EXECUTE ♦ SIGNAL ♦ RESIGNAL ♦ DECLARE ♦ SET VARIABLE You should not use explicit error handling code with an ON EXCEPTION RESUME clause.
Page 475
Chapter 9 SQL Statements DYNAMIC RESULT SETS clause This clause is for use with procedures that are wrappers around Java methods. If the DYNAMIC RESULT SETS clause is not provided, it is assumed that the method returns no result set. EXTERNAL NAME LANGUAGE JAVA clause A procedure that uses EXTERNAL NAME with a LANGUAGE JAVA clause is a wrapper around...
Page 476
577 of the book ASA User’s Guide. ♦ Standards and Persistent Stored Module feature. SQL/92 compatibility ♦ Sybase The Transact-SQL CREATE PROCEDURE statement is different. ♦ The syntax extensions for Java result sets are as specified in the SQLJ proposed SQLJ1 standard.
Page 477
Chapter 9 SQL Statements LEFT OUTER JOIN sales_order_items LEFT OUTER JOIN product GROUP BY company_name; DECLARE ThisValue INT; DECLARE ThisCompany CHAR(35); SET TopValue = 0; OPEN curThisCust; CustomerLoop: LOOP FETCH NEXT curThisCust INTO ThisCompany, ThisValue; IF SQLSTATE = err_notfound THEN LEAVE CustomerLoop;...
IN, OUT, or INOUT, while Transact-SQL procedure parameters are INPUT parameters by default or can be specified as OUTPUT. Those parameters that would be declared as INOUT or as OUT in Adaptive Server Anywhere should be declared with OUTPUT in Transact-SQL. ♦...
Page 479
CREATE PROCEDURE statement syntax. If the Transact-SQL WITH RECOMPILE optional clause is supplied, it is ignored. Adaptive Server Anywhere always recompiles procedures the first time they are executed after a database is started, and stores the compiled procedure until the database is stopped.
♦ Standards and SQL/92 Entry level feature. compatibility ♦ Adaptive Server Anywhere does not support the use of Sybase REVOKE statements within the CREATE SCHEMA statement, and does not allow its use within Transact-SQL batches or procedures.
Page 481
Chapter 9 SQL Statements ♦ Examples The following CREATE SCHEMA statement creates a schema consisting of two tables. The statement must be executed by the user ID sample_user, who must have RESOURCE authority. If the statement creating table t2 fails, neither table is created. CREATE SCHEMA AUTHORIZATION sample_user CREATE TABLE t1 ( id1 INT PRIMARY KEY ) CREATE TABLE t2 ( id2 INT PRIMARY KEY );...
♦ is the TCP/IP port number the remote server listens on. portnumber The default port number for Adaptive Server Anywhere is 2638. ♦ For Adaptive Server Anywhere remote servers, if you do not dbname specify a dbname, then the default database is used. For Adaptive Server...
Page 483
Entry-level feature. compatibility ♦ Supported by Open Client/Open Server. Sybase ♦ Examples Create an Adaptive Server Anywhere remote server named testasa, located on the machine apple and listening on port number 2638, use: CREATE SERVER testasa CLASS ’asajdbc’ USING ’apple:2638’...
CREATE TABLE statement CREATE TABLE statement Function Use this statement to create a new table in the database and, optionally, to create a table on a remote server. Syntax CREATE [ GLOBAL TEMPORARY ] TABLE [ owner .] table-name … ( { column-definition | table-constraint }, … ) …...
Page 485
Chapter 9 SQL Statements Permissions Must have RESOURCE authority. Must have DBA authority to create a table for another user. The AT clause to create proxy tables is supported on Windows 95 and Windows NT only. Side effects Automatic commit. See also "ALTER TABLE statement"...
Page 486
CREATE TABLE statement For example, the following statement maps the table a1 to the MS Access file mydbfile.mdb CREATE TABLE a1 AT ’access;d:\mydbfile.mdb;;a1’ For information on remote servers, see "CREATE SERVER statement" on page 464. For information on proxy tables, see "CREATE EXISTING TABLE statement"...
Page 487
Chapter 9 SQL Statements On inserts into the table, if a value is not specified for the AUTOINCREMENT column, a unique value larger than any other value in the column is generated. If an INSERT specifies a value for the column, it is used; if the specified value is larger than the current maximum value for the column, that value will be used as a starting point for subsequent inserts.
Page 488
CREATE TABLE statement When using this default, the value of the public option Global_database_id in each database must be set to a unique, positive integer. This value uniquely identifies the database and indicates from which partition default values are to be assigned. The range of allowed values is n p + 1 to (n + 1) p, where n is the value of the public option Global_database_id and p is the partition size.
Page 489
Chapter 9 SQL Statements Columns declared with DEFAULT TIMESTAMP contain unique values, so that applications can detect near-simultaneous updates to the same row. If the current timestamp value is the same as the last value, it is incremented by the value of the DEFAULT_TIMESTAMP_INCREMENT option.
Page 490
CREATE TABLE statement Column constraints are normally used unless the constraint references more than one column in the table. In these cases, a table constraint must be used. Constraints include the following: ♦ This allows arbitrary conditions to be verified. For example, a CHECK check constraint could be used to ensure that a column called Sex only contains the values M or F.
Page 491
Chapter 9 SQL Statements ♦ PRIMARY KEY This is the same as a unique constraint, except that a table can have only one primary key constraint. The primary key usually identifies the best identifier for a row. For example, the customer number might be the primary key for the customer table.
Page 492
CREATE TABLE statement ♦ NOT NULL Disallow NULL in the foreign key columns. A NULL in a foreign key means that no row in the primary table corresponds to this row in the foreign table. ♦ role-name The role name is the name of the foreign key. The main function of the role name is to distinguish two foreign keys to the same table.
Page 493
♦ By default, columns in Adaptive Server Enterprise NULL default default to NOT NULL, whereas in Adaptive Server Anywhere the default setting is NULL. This setting can be controlled using the ALLOW_NULLS_BY_DEFAULT database option. You should explicitly specify NULL or NOT NULL to make your data definition statements transferable between Adaptive Server Anywhere and Adaptive Server Enterprise.
Page 494
CREATE TABLE statement CREATE TABLE library_books ( -- NOT NULL is assumed for primary key columns isbn CHAR(20) PRIMARY KEY, copyright_date DATE, title CHAR(100), author CHAR(50), -- column(s) corresponding to primary key of room -- are created automatically FOREIGN KEY location REFERENCES room ♦...
Chapter 9 SQL Statements CREATE TRIGGER statement Function Use this statement to create a new trigger in a database. CREATE TRIGGER trigger-name trigger-time trigger-event [, trigger-event,.. ] Syntax … [ ORDER integer ] ON table-name … [ REFERENCING [ OLD AS old-name ] [ NEW AS new-name ] ] [ REMOTE AS remote-name ] ] …...
Page 496
CREATE TRIGGER statement ♦ UPDATE OF column-list Invoked whenever a row of the associated table is updated and a column in the column-list has been modified. trigger-time Row-level triggers can be defined to execute BEFORE or AFTER the insert, update, or delete. Statement-level triggers execute AFTER the statement.
Page 497
Standards and SQL/92 Persistent stored module feature. Some clauses are vendor compatibility extensions. ♦ Sybase This syntax is different to that supported by Adaptive Server Enterprise. ♦ Example When a new department head is appointed, update the manager_id column for employees in that department.
CREATE TRIGGER statement, these rows are accessed using the REFERENCING clause. Trigger names must be unique in the database. Transact-SQL triggers are executed AFTER the triggering statement. ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Anywhere supports a subset of the Adaptive Server Enterprise syntax.
Local variables in procedures and triggers are declared within a compound statement (see "Using compound statements" on page 460 of the book ASA User’s Guide). ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase Example For an example, see "SET statement" on page 605...
CREATE VIEW statement CREATE VIEW statement Function Use this statement to create a view on the database. Views are used to give a different perspective on the data, even though it is not stored that way. Syntax CREATE VIEW … [ owner .] view-name [( column-name , … )] …...
Page 501
Standards and SQL/92 Entry level feature. compatibility ♦ Supported by Adaptive Server Enterprise. Sybase ♦ Examples Create a view showing information for male employees only. This view has the same column names as the base table. CREATE VIEW male_employee AS SELECT * FROM Employee WHERE Sex = ’M’...
You cannot create a write file for a database that is currently loaded. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement creates a write file.. CREATE WRITEFILE ’c:\\sybase\\my_db.wrt’ FOR DATABASE ’c:\\sybase\\my_db.db’ LOG ON ’e:\\logdrive\\my_db.log’...
Frees all memory associated with a descriptor area, including the data items, indicator variables, and the structure itself. ♦ Standards and Entry-level feature. SQL/92 compatibility ♦ Supported by Open Client/Open Server. Sybase ♦ Example For an example, see "ALLOCATE DESCRIPTOR statement" on page 381.
Not all C declarations are valid inside a declaration section. See "Using host variables" on page 20 of the book ASA Programming Interfaces Guide for more information. ♦ Standards and SQL/92 compatibility ♦ Sybase Examples EXEC SQL BEGIN DECLARE SECTION; char *emp_lname, initials[5]; int dept; EXEC SQL END DECLARE SECTION;...
In Adaptive Server Enterprise, a variable that is declared in a procedure or trigger exists for the duration of the procedure or trigger. In Adaptive Server Anywhere, if a variable is declared inside a compound statement, it exists only for the duration of that compound statement (whether it is declared in a Watcom-SQL or Transact-SQL compound statement).
DECLARE CURSOR statement [ESQL] [SP] DECLARE CURSOR statement [ESQL] [SP] Function Use this statement to declare a cursor. Cursors are the primary means for manipulating the results of queries. Syntax DECLARE cursor-name … [ UNIQUE | NO SCROLL | DYNAMIC SCROLL | SCROLL | INSENSITIVE …...
Page 507
If you fetch the row at this hole with a SCROLL cursor, Adaptive Server Anywhere returns the error SQLE_NO_CURRENT_ROW indicating that the row has been deleted, and leaves the cursor positioned on the hole.
Page 508
DECLARE CURSOR statement [ESQL] [SP] An update to any column causes the warning/error, even if the column is not referenced by the cursor. For example, a cursor on Surname and Initials would report the update even if only the Birthdate column were modified. These update warning and error conditions will not occur in bulk operations mode ( database server statement line switch) when row locking is...
Page 509
♦ Standards and Entry level feature. SQL/92 compatibility ♦ Sybase Supported by Open Client/Open Server. ♦ Examples The following example illustrates how to declare a scroll cursor in Embedded SQL: EXEC SQL DECLARE cur_employee SCROLL CURSOR FOR SELECT * FROM employee;...
Page 510
DECLARE CURSOR statement [ESQL] [SP] ♦ The following example illustrates the use of cursors in a stored procedure: BEGIN DECLARE cur_employee CURSOR FOR SELECT emp_lname FROM employee; DECLARE name CHAR(40); OPEN cur_employee; LOOP FETCH NEXT cur_employee INTO name; END LOOP CLOSE cur_employee;...
See also "DECLARE CURSOR statement" on page 488 Description Adaptive Server Anywhere supports a DECLARE CURSOR syntax that is not supported in Adaptive Server Enterprise. For information on the full DECLARE CURSOR syntax, see "DECLARE CURSOR statement" on page 488.
Page 512
DECLARE CURSOR statement [T-SQL] ♦ CURSOR type (UNIQUE, NO SCROLL, and so on) and CURSOR FOR statement-name are not supported in Adaptive Server Anywhere.
Standards and Conforms to the SQL/92 standard. SQL/92 compatibility ♦ Adaptive Server Enterprise does not support DECLARE Sybase TEMPORARY TABLE. ♦ Examples The following example illustrates how to declare a temporary table in Embedded SQL: EXEC SQL DECLARE LOCAL TEMPORARY TABLE MyTable ( number INT ♦...
DELETE statement DELETE statement Function Use this statement to delete rows from the database. DELETE [ FIRST | TOP n ] Syntax … [FROM] [ owner .] table-name … [FROM table-list ] … [WHERE search-condition ] Permissions Must have DELETE permission on the table. Side effects None.
Page 515
Standards and Entry level compliant. The use of more than one table in the SQL/92 compatibility FROM clause is a vendor extension. ♦ Sybase Supported by Adaptive Server Enterprise, including the vendor extension. ♦ Examples Remove employee 105 from the database.
DELETE (positioned) statement [ESQL] [SP] DELETE (positioned) statement [ESQL] [SP] Function Use this statement to delete the data at the current location of a cursor. DELETE [ FROM table-spec ] Syntax …WHERE CURRENT OF cursor-name cursor-name : identifier | host-variable table-spec : [ owner .] correlation-name owner : identifier Permissions...
Page 517
ANSI_UPDATE_CONSTRAINTS option is set to OFF. ♦ Embedded SQL use is supported by Open Client/Open Server. Sybase Procedure and trigger use is supported only in Adaptive Server Anywhere. ♦ Example The following statement removes the current row from the database.
DESCRIBE statement [ESQL] DESCRIBE statement [ESQL] Function Use this statement to get information about the host variables required to store data retrieved from the database, or host variables required to pass data to the database. Syntax DESCRIBE … [ USER TYPES ] …...
Page 519
Chapter 9 SQL Statements If you specify a cursor name, the cursor must have been previously declared and opened. The default action is to describe the OUTPUT. Only SELECT statements and CALL statements have OUTPUT. A DESCRIBE OUTPUT on any other statement, or on a cursor that is not a dynamic cursor, indicates no output by setting the sqld field of the SQLDA to zero.
Page 520
DESCRIBE statement [ESQL] OUTPUT The DESCRIBE OUTPUT statement fills in the data type and length for each select list item in the SQLDA. The name field is also filled in with a name for the select list item. If an alias is specified for a select list item, the name will be that alias.
Page 521
Part of the SQL/92 standard. Some clauses are vendor compatibility extensions. ♦ Some clauses supported by Open Client/Open Server. Sybase ♦ Example The following example shows how to use the DESCRIBE statement: sqlda = alloc_sqlda( 3 ); EXEC SQL DESCRIBE OUTPUT FOR employee_statement INTO sqlda;...
♦ Standards and Intermediate level feature. SQL/92 compatibility ♦ Supported by Open Client/Open Server. Sybase ♦ Examples The following statement shows how to use DISCONNECT in Embedded SQL: EXEC SQL DISCONNECT :conn_name ♦ The following statement shows how to use DISCONNECT from...
Chapter 9 SQL Statements DROP statement Function Use this statement to remove objects from the database. Syntax DROP { DATATYPE | DOMAIN } datatype-name | DBSPACE dbspace-name | EVENT event-name | FUNCTION [ owner .] function-name | INDEX [ [ owner ]. table-name .] index-name | MESSAGE msgnum | PROCEDURE [ owner .] procedure-name | TABLE [ owner .] table-name...
Page 524
ANSI/ISO SQL3 draft. ♦ Standards and SQL/92 Entry level feature. compatibility ♦ Supported by Adaptive Server Enterprise for those objects Sybase that exist in Adaptive Server Enterprise. ♦ Examples Drop the department table from the database. DROP TABLE department ♦ Drop the emp_dept view from the database.
♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Examples Drop the database , in the directory.. temp.db C:\temp DROP DATABASE ’c:\temp\temp.db’...
ID of the current connection: SELECT connection_property( ’number’ ) ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement drops the connection with ID number 4. DROP CONNECTION 4...
Specifies the name of the remote server. The local user’s alternate login name and password for that server is the external login that is deleted. ♦ Standards and SQL/92 Entry-level feature. compatibility ♦ Sybase Supported by Open Client/Open Server. Example DROP EXTERNLOGIN dba TO sybase1...
In this situation, the best approach is to execute statements that allow Adaptive Server Anywhere to scan the new rows sequentially. The internal statistics are automatically updated as a side effect, allowing the optimizer to choose better plans for subsequent queries.
Anywhere catalogs. You must drop all the proxy tables that have been defined for the remote server before this statement will succeed. ♦ Standards and SQL/92 Entry-level feature. compatibility ♦ Sybase Supported by Open Client/Open Server. Example DROP SERVER ase_prod...
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported in Open Client/Open Server Sybase ♦ Example The following are examples of DROP STATEMENT use: EXEC SQL DROP STATEMENT S1; EXEC SQL DROP STATEMENT :stmt;...
Variables are often used for large objects, so eliminating them after use or setting them to NULL may free up significant resources (primarily disk space). ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise.
EXECUTE statement [ESQL] EXECUTE statement [ESQL] Function Use this statement to execute a prepared SQL statement. EXECUTE statement Syntax 1 … [ USING { DESCRIPTOR sqlda-name | host-variable-list ] … [ INTO { DESCRIPTOR into-sqlda - name | into-host - variable-list ] …...
Page 533
0 to (columns per row)-1, and so on. ♦ Standards and Intermediate level feature. SQL/92 compatibility ♦ Sybase Supported in Open Client/Open Server. ♦ Examples Execute a DELETE. EXEC SQL EXECUTE IMMEDIATE ’DELETE FROM employee WHERE emp_id = 105’;...
EXECUTE statement [T-SQL] EXECUTE statement [T-SQL] Function Use this statement to invoke a procedure, as an Adaptive Server Enterprise- compatible alternative to the CALL statement. Syntax EXECUTE [ @return_status = ] [ creator .] procedure_name … | [ @parameter-name = ] expression , | [ @parameter-name =] @variable [ output ] |, …...
Page 535
Chapter 9 SQL Statements The following statement executes the procedure, and stores the return value in a variable for checking return status. EXECUTE @status = p1 23...
Standards and Intermediate level feature. SQL/92 compatibility ♦ Sybase Supported in Open Client/Open Server. Example The following procedure creates a table, where the table name is supplied as a parameter to the procedure. The EXECUTE IMMEDIATE statement must all be on a single line.
Page 537
Chapter 9 SQL Statements EXECUTE IMMEDIATE ’CREATE TABLE ’ || tablename || ’ ( column1 INT PRIMARY KEY)’ To call the procedure and create a table mytable: CALL CreateTableProc( ’mytable’ )
COMMIT_ON_EXIT option is set to ON. If this option is set to OFF, Interactive SQL instead performs a ROLLBACK. By default, the COMMIT_ON_EXIT option is set to ON. ♦ Standards and SQL/92 Vendor extension compatibility ♦ Not applicable in Adaptive Server Enterprise. Sybase...
Chapter 9 SQL Statements EXPLAIN statement [ESQL] Function Use this statement to retrieve a text specification of the optimization strategy used for a particular cursor. Syntax EXPLAIN PLAN FOR CURSOR cursor-name INTO host-variable … INTO host-variable | USING DESCRIPTOR sqlda-name cursor-name : identifier or host-variable sqlda-name :...
Page 540
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported in Adaptive Server Enterprise. Sybase ♦ Example The following example illustrates use of EXPLAIN: EXEC SQL BEGIN DECLARE SECTION; char plan[300]; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE employee_cursor CURSOR FOR...
Chapter 9 SQL Statements FETCH statement [ESQL] [SP] Function Use this statement to reposition a cursor and then get data from it. Syntax FETCH … cursor-position … cursor-name … [ INTO { host-variable-lis t | variable-list } | USING DESCRIPTOR sqlda-name ] …...
Page 542
FETCH statement [ESQL] [SP] The server returns in SQLCOUNT the number of records fetched, and always returns a SQLCOUNT greater than zero unless there is an error or warning. A SQLCOUNT of zero with no error condition indicates that one valid row has been fetched.
Page 543
Chapter 9 SQL Statements ♦ RELATIVE RELATIVE positioning is used to move the cursor by a specified number of rows in either direction before fetching. A positive number indicates moving forward and a negative number indicates moving backwards. Thus, a NEXT is equivalent to RELATIVE 1 and PRIOR is equivalent to RELATIVE -1.
Page 544
Standards and Entry level feature. Use in procedures is a Persistent Stored SQL/92 compatibility Module feature. ♦ Sybase Supported in Adaptive Server Enterprise. ♦ Example The following is an Embedded SQL example. EXEC SQL DECLARE cur_employee CURSOR FOR SELECT emp_id, emp_lname FROM employee;...
Page 545
Chapter 9 SQL Statements FETCH NEXT cur_employee into name; END LOOP CLOSE cur_employee;...
♦ Standards and SQL/92 Persistent Stored Module feature. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following fragment illustrates the use of the FOR loop. FOR names AS curs CURSOR FOR SELECT emp_lname FROM employee CALL search_for_name( emp_lname );...
Send a single statement to a remote server. Syntax 1 ♦ Place Adaptive Server Anywhere into passthrough mode for Syntax 2 sending a series of statements to a remote server. All subsequent statements are passed directly to the remote server. To turn passthrough mode off, issue FORWARD TO without a server-name specification.
Page 549
Chapter 9 SQL Statements ♦ Example The following example shows a passthrough session with the remote server ase_prod FORWARD TO aseprod SELECT * from titles SELECT * from authors FORWARD TO...
FROM clause FROM clause Function Use this statement to specify the database tables or views involved in a SELECT or UPDATE statement. Syntax … FROM table-expression , … table-expression : table-spec | table-expression join-type table-spec [ ON condition ] | ( table-expression , … ) table-spec : [ userid .] table-name [ [AS] correlation-name ] | select-statement [ AS ] correlation-name [ ( column-name, …...
Page 551
♦ Standards and Entry level feature. SQL/92 compatibility ♦ Sybase The JOIN clause is not supported in Adaptive Server Enterprise. Instead, you must use the WHERE clause to build joins. ♦ Examples The following are valid FROM clauses: FROM employee...
Page 552
FROM clause KEY JOIN sales_order KEY JOIN sales_order_items KEY JOIN product ♦ The following query illustrates how to use derived tables in a query: SELECT lname, fname, number_of_orders FROM customer JOIN ( SELECT cust_id, count(*) FROM sales_order GROUP BY cust_id ) AS sales_order_counts ( cust_id, number_of_orders ) ON ( customer.id = sales_order_counts.cust_id )
Chapter 9 SQL Statements GET DATA statement [ESQL] Function Use this statement to get string or binary data for one column of the current row of a cursor. GET DATA is usually used to fetch LONG BINARY or LONG VARCHAR fields. See "SET statement" on page 605. Syntax GET DATA cursor-name …...
Page 554
Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Open Client/Open Server. An alternative is Sybase the Transact-SQL READTEXT statement. ♦ Example The following example uses GET DATA to fetch a binary large object (often called a blob). EXEC SQL BEGIN DECLARE SECTION;...
If an error occurs, it is returned in the SQLCA. ♦ Standards and Entry level feature. SQL/92 compatibility ♦ Sybase Supported by Open Client/Open Server. ♦ Example For an example, see "ALLOCATE DESCRIPTOR statement" on page 381.
If option-name does not exist, GET OPTION returns the warning SQLE_NOTFOUND. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement illustrates use of GET OPTION. EXEC SQL GET OPTION ’date_format’ INTO :datefmt;...
Standards and Persistent Stored Module feature. SQL/92 compatibility ♦ Adaptive Server Enterprise supports the GOTO statement. Sybase ♦ Example The following Transact-SQL batch prints the message "yes" on the server window four times: declare @count smallint select @count = 1 restart: print ’yes’...
GRANT statement GRANT statement Function Use this statement to create new user IDs, to grant or deny permissions to specific users, and to create or change passwords. Syntax 1 GRANT CONNECT TO userid , … [ AT starting-id } IDENTIFIED BY password , … Syntax 2 GRANT { DBA,...
Page 559
Chapter 9 SQL Statements ♦ You own the procedure ♦ You have DBA authority Syntax 5 The following condition must be met: ♦ You have DBA authority Side effects Automatic commit. See also "REVOKE statement" on page 595 Description The GRANT statement is used to grant database permissions to individual user IDs and groups.
Page 560
ALL to grant all six permissions at once. RESOURCE Allows the user to create tables and views. In syntax 2, ALL is a synonym for RESOURCE that is compatible with Sybase Adaptive Server Enterprise. In Syntax 3, this grants all of the permissions outlined below.
Page 561
♦ Sybase Syntaxes 2 and 3 are supported in Adaptive Server Enterprise. The security model is different in Adaptive Server Enterprise and Adaptive Server Anywhere, so other syntaxes differ. ♦ Examples Make two new users for the database. GRANT...
The topic for help can be optionally specified. If topic is not specified, the help system is entered at the index. If topic is a reserved word, it must be enclosed in single quotes. ♦ Standards and Vendor extension SQL/92 compatibility ♦ Sybase Not applicable...
♦ SQL/92 Persistent Stored Module feature. Standards and compatibility ♦ The Transact-SQL IF statement has a slightly different syntax. Sybase ♦ Example The following procedure illustrates the use of the IF statement: CREATE PROCEDURE TopCustomer (OUT TopCompany CHAR(35), TopValue INT)
Page 564
IF statement LEFT OUTER JOIN product GROUP BY company_name; DECLARE ThisValue INT; DECLARE ThisCompany CHAR(35); SET TopValue = 0; OPEN curThisCust; CustomerLoop: LOOP FETCH NEXT curThisCust INTO ThisCompany, ThisValue; IF SQLSTATE = err_notfound THEN LEAVE CustomerLoop; END IF; IF ThisValue > TopValue THEN SET TopValue = ThisValue;...
END IF keywords. ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Adaptive Server Enterprise supports the Transact-SQL IF statement. ♦ Example The following example illustrates the use of the Transact-SQL IF statement: IF (SELECT max(id) FROM sysobjects) < 100...
Page 566
IF statement [T-SQL] IF v1 = 0 THEN PRINT ’0’ ELSEIF v1 = 1 THEN PRINT ’1’ ELSE PRINT ’other’ END IF...
(invisible to the programmer), which are declared by the SQL preprocessor at the position of the SQLCA include statement. The SQLDA file must be included if any SQLDAs are used. ♦ Standards and Entry level feature. SQL/92 compatibility ♦ Supported by Open Client/Open Server. Sybase...
INPUT statement [Interactive SQL] INPUT statement [Interactive SQL] Function Use this statement to import data into a database table from an external file or from the keyboard. Syntax INPUT INTO [ owner .] table-name … [ FROM filename | PROMPT ] …...
Page 569
Chapter 9 SQL Statements Parameters ESCAPE CHARACTER clause The default escape character for hexadecimal codes and symbols is a backslash (\), so \x0A is the linefeed character, for example. The escape character can be changed, using the ESCAPE CHARACTER clause. For example, to use the exclamation mark as the escape character, you would enter: ...
Page 570
INPUT statement [Interactive SQL] Certain file formats contain information about column names and types. Using this information, the INPUT statement will create the database table if it does not already exist. This is a very easy way to load data into the database.
Page 571
♦ Vendor extension Standards and SQL/92 compatibility ♦ Sybase Not applicable ♦ The following is an example of an INPUT statement from an ASCII text Example file. INPUT INTO employee FROM new_emp.inp...
INSERT statement INSERT statement Function Use this statement to insert a single row (syntax 1) or a selection of rows from elsewhere in the database (syntax 2) into a table. Syntax 1 INSERT [ INTO ] [ owner .] table-name [( column-name , … )] …...
Page 573
INSERT statements. ♦ Entry level feature. Standards and SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise. ♦ Examples Add an Eastern Sales department to the database. INSERT INTO department ( dept_id, dept_name ) VALUES ( 230, ’Eastern Sales’ ) ♦...
INSTALL statement INSTALL statement Use this statement to make Java classes available for use within a database. Function Syntax INSTALL JAVA [ NEW | UPDATE ] [ JAR jar-name ] FROM { FILE filename | expression } Permissions DBA permissions are required to execute the INSTALL statement. All installed classes can be referenced in any way by any user.
Page 575
For example, the following statement uses the class installed in the previous statement. CREATE VARIABLE d Demo If the Demo class was a member of the package sybase.work, the fully qualified name of the class must be used, for example: CREATE VARIABLE d sybase.work.Demo ♦...
Persistent Stored Module feature. Standards and SQL/92 compatibility ♦ Not supported in Adaptive Server Enterprise. The BREAK Sybase statement provides a similar feature for Transact-SQL compatible procedures. ♦ Examples The following fragment shows how the LEAVE statement is used to leave a loop.
Page 577
Chapter 9 SQL Statements SET i = i + 1; IF i >= 10 THEN LEAVE outer_loop END IF END LOOP inner_loop END LOOP outer_loop...
LOAD TABLE statement LOAD TABLE statement Function Use this statement to import bulk data into a database table from an external ASCII-format file. Inserts are not recorded in the log file, raising the risk that data will be lost in the event of a crash and making this statement unusable with SQL Remote or with MobiLink client databases.
Page 579
Chapter 9 SQL Statements You can use LOAD TABLE on a global temporary table, but the temporary table must have been created with the ON COMMIT PRESERVE ROWS clause, because LOAD TABLE does a COMMIT after the load. LOAD TABLE cannot be used on declared temporary tables. If the ASCII file has entries such that a column appears to be NULL, LOAD TABLE treats it as null.
Page 580
LOAD TABLE statement Setting CHECK CONSTRAINTS to off disables check constraints. This can be useful, for example, during database rebuilding. If a table has check constraints that call user-defined functions that are not yet created, the rebuild would fail unless this option was set to OFF. DEFAULTS option By default, DEFAULTS is OFF.
Page 581
Chapter 9 SQL Statements QUOTES option With QUOTES turned on (the default), the LOAD statement expects strings to be enclosed in quote characters. The quote character is either an apostrophe (single quote) or a quotation mark (double quote). The first such character encountered in a string is treated as the quote character for the string.
Page 582
For more information, see CONVERSION_ERROR option. The data files are required, regardless of this option, if the database becomes corrupt and you need to use a backup and apply the current log file. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not applicable. Sybase...
Chapter 9 SQL Statements LOCK TABLE statement Function Use this statement to prevent other concurrent transactions from accessing or modifying a table. Syntax LOCK TABLE table-name [ WITH HOLD ] IN { SHARE | EXCLUSIVE } MODE Permissions To lock a table in SHARE mode, SELECT privileges are required. To lock a table in EXCLUSIVE mode;...
Page 584
Vendor extension. Standards and ♦ compatibility Supported in Adaptive Server Enterprise. The WITH HOLD Sybase clause is not supported in Adaptive Server Enterprise. Adaptive Server Enterprise provides a WAIT clause that is not supported in Adaptive Server Anywhere. ♦ Examples...
♦ Persistent Stored Module feature. Standards and SQL/92 compatibility ♦ Sybase Not supported in Adaptive Server Enterprise. The WHILE statement provides looping in Transact-SQL stored procedures. ♦ Examples A While loop in a procedure. SET i = 1; WHILE i <= 10 LOOP INSERT INTO Counters( number ) VALUES ( i );...
Send messages to the server log file specified by the command-line option. ♦ SQL/92 Vendor extension. Standards and compatibility ♦ Not supported in Adaptive Server Enterprise. The Transact- Sybase SQL PRINT statement provides a similar feature, and is also available in Adaptive Server Anywhere. Example...
Page 587
Chapter 9 SQL Statements ♦ The following procedure displays a message on the server message window: CREATE PROCEDURE message_test () BEGIN MESSAGE ’The current date and time: ’, Now(); ♦ The statement: CALL message_test() displays the string The current date and time, and the current date and time, on the database server message window.
OPEN statement [ESQL] [SP] OPEN statement [ESQL] [SP] Function Use this statement to open a previously declared cursor to access information from the database. Syntax OPEN cursor-name … [ USING [ DESCRIPTOR sqlda-name | host-variable , …] ] … [ WITH HOLD ] …...
Page 589
Chapter 9 SQL Statements If cursor-name is specified by an identifier or string, the corresponding DECLARE CURSOR must appear prior to the OPEN in the C program; if the cursor-name is specified by a host variable, the DECLARE CURSOR statement must execute before the OPEN statement. USING DESCRIPTOR clause The USING DESCRIPTOR clause is for Embedded SQL only.
Page 590
OPEN statement [ESQL] [SP] ♦ Sybase The simple OPEN cursor-name syntax is supported by Adaptive Server Enterprise. None of the other clauses are supported in Adaptive Server Enterprise stored procedures. Open Client/Open Server supports the USING descriptor or host variable syntax.
Chapter 9 SQL Statements OUTPUT statement [Interactive SQL] Function Use this statement to output the current query results to a file. OUTPUT TO filename Syntax … [ APPEND ] … [ VERBOSE ] … [ FORMAT output_format ] … [ ESCAPE CHARACTER character ] …...
Page 592
OUTPUT statement [Interactive SQL] CREATE VARIABLE JavaString java.lang.String; SET JavaString = NEW java.lang.String( ’TestVar’ ); SELECT JavaString FROM dummy; If you set DESCRIBE_JAVA_FORMAT to Varchar: ♦ The following command gives the hexadecimal representation of TestVar in the output file. OUTPUT TO filename ♦...
Page 593
Chapter 9 SQL Statements ♦ ASCII The output is an ASCII format file with one row per line in the file. All values are separated by commas, and strings are enclosed in apostrophes (single quotes). The delimiter and quote strings can be changed using the DELIMITED BY and QUOTE clauses.
Page 594
... ESCAPE CHARACTER ’!’ ♦ Vendor extension Standards and SQL/92 compatibility ♦ Sybase Not applicable ♦ Place the contents of the employee table in a file, in ASCII format. Examples SELECT * FROM employee; OUTPUT TO employee.txt FORMAT ASCII ♦...
Interactive SQL prompts for values of the missing parameters. ♦ SQL/92 Vendor extension Standards and compatibility ♦ Not applicable. Sybase ♦ Example The following Interactive SQL command file takes two parameters. PARAMETERS department_id, file; SELECT emp_lname FROM employee WHERE dept_id = {department_id} >#{file}.dat;...
PREPARE statement [ESQL] PREPARE statement [ESQL] Function Use this statement to prepare a statement to be executed later, or used to define a cursor. Syntax PREPARE statement-name FROM statement …[ DESCRIBE describe-type INTO [ [ SQL ] DESCRIPTOR ] descriptor ] …[ WITH EXECUTE ] statement-name : identifier or host-variable statement :...
Page 597
Also, other Embedded SQL systems do not support dynamic transaction management operations. ♦ Entry level feature Standards and SQL/92 compatibility ♦ Sybase Supported by Open Client/Open Server. ♦ Example The following statement prepares a simple query: EXEC SQL PREPARE employee_statement FROM ’SELECT emp_lname FROM employee’;...
Standards and SQL/92 Vendor extension. compatibility ♦ Not supported in Adaptive Server Enterprise. Sybase ♦ Examples The following sequence of statements leads to an error because of foreign key checking on the employee table. EXECUTE IMMEDIATE "SET OPTION wait_for_commit = ’on’";...
1 and 20. ♦ Transact-SQL extension. Standards and SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise. ♦ Examples The following statement displays a message: PRINT ’Display this message’ ♦ The following statement illustrates the use of placeholders in the PRINT...
PUT statement [ESQL] PUT statement [ESQL] Function Use this statement to insert a row into the specified cursor. PUT cursor-name Syntax … [ USING DESCRIPTOR sqlda-name | FROM host-variable-list ] … [ INTO { DESCRIPTOR into-sqlda - name | into-host - variable-list } ] …...
Page 601
"SET statement" on page 605. ♦ Standards and Entry level feature. SQL/92 compatibility ♦ Sybase Supported by Open Client/Open Server. ♦ Example The following statement illustrates the use of PUT in Embedded SQL: EXEC SQL PUT cur_employee FROM :emp_id, :emp_lname;...
Adaptive Server Enterprise obtains messages 17000-19999 from the SYSMESSAGES table. In Adaptive Server Anywhere this table is an empty view, so errors in this range should provide a format string. Messages for error numbers of 20000 or greater are obtained from the SYS.SYSUSERMESSAGES table.
Page 603
SQL/92 Transact-SQL extension. compatibility ♦ Supported by Adaptive Server Enterprise. Sybase ♦ Example The following statement raises error 23000, which is in the range for user-defined errors, and sends a message to the client. RAISERROR 23000 ’Invalid entry for this column: %1!’, @val...
If not enough parameters are passed to the command file, Interactive SQL prompts for values for the missing parameters. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not applicable. Sybase ♦ Examples The following are examples of the READ statement. READ status.rpt ’160’ READ birthday.sql [>= ’1988-1-1’] [<= ’1988-1-30’]...
Sybase Supported by Adaptive Server Enterprise. Adaptive Server Enterprise supports the following clause, which is not supported by Adaptive Server Anywhere: USING { BYTES | CHARS | CHARACTERS } These options are identical for all single-byte character sets. Adaptive Server Anywhere uses bytes only, which is the Adaptive Server Enterprise default setting.
Releasing a savepoint does not do any type of COMMIT. It simply removes the savepoint from the list of currently active savepoints. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not supported by Adaptive Server Enterprise. A similar Sybase feature is available in an Adaptive Server Enterprise-compatible manner using nested transactions.
Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Adaptive Server Enterprise. A similar Sybase feature is available in an Adaptive Server Enterprise-compatible manner using nested transactions. ♦ Examples The following statement removes a Java class named Demo from the current database.
Standards and SQL/92 Persistent stored module feature. compatibility ♦ Not supported in Adaptive Server Enterprise. Signaling of Sybase errors in Transact-SQL procedures is carried out using the RAISERROR statement. ♦ Example The following fragment returns all exceptions except Column Not Found to the application.
Specifies a new location to restore each dbspace to. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not supported in Adaptive Server Enterprise. Sybase ♦ Examples Restore a database from a Windows NT tape drive: RESTORE DATABASE ’d:\\dbhome\\cust.db’ FROM ’\\.\tape0’...
RESUME a cursor for a SELECT statement. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. ♦ Examples Embedded SQL example 1. EXEC SQL RESUME cur_employee; 2. EXEC SQL RESUME :cursor_var;...
♦ Standards and Persistent stored module feature. SQL/92 compatibility ♦ Transact-SQL procedures use the RETURN statement to Sybase return an integer error code. ♦ Example The following function returns the product of three numbers: CREATE FUNCTION product ( a numeric,...
Page 612
RETURN statement ♦ The following procedure uses the RETURN statement to avoid executing a complex query if it is meaningless: CREATE PROCEDURE customer_products ( in customer_id integer DEFAULT NULL) RESULT ( id integer, quantity_ordered integer ) BEGIN IF customer_id NOT IN (SELECT id FROM customer) OR customer_id IS NULL THEN RETURN ELSE...
Chapter 9 SQL Statements REVOKE statement Function Use this statement to remove permissions for the specified users. Syntax 1 REVOKE { CONNECT, DBA, INTEGRATED LOGIN, GROUP, MEMBERSHIP IN GROUP userid , … RESOURCE, ..FROM userid , … Syntax 2 REVOKE { ALL [PRIVILEGES] ALTER, DELETE,...
Page 614
Syntax 3 is a Persistent Stored Module feature. ♦ Sybase Syntax 2 and 3 are supported by Adaptive Server Enterprise. Syntax 1 is not supported by Adaptive Server Enterprise. User management and security models are different for Adaptive Server Anywhere and Adaptive Server Enterprise.
COMMIT or ROLLBACK statements. The ROLLBACK statement ends the current transaction and undoes all changes made to the database since the previous COMMIT or ROLLBACK. ♦ Standards and Entry level feature. SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise.
SQL/92 compatibility ♦ Savepoints are not supported by Adaptive Server Enterprise. Sybase To implement similar features in an Adaptive Server Enterprise- compatible manner, you can use nested transactions. For more information on nested transactions, see "BEGIN TRANSACTION statement" on page 407.
If a ROLLBACK TRIGGER statement is used within a nested trigger and without a RAISERROR statement, only the innermost trigger and the statement which caused it to fire are undone. ♦ Standards and SQL/92 Transact-SQL extension. compatibility ♦ Supported by Adaptive Server Enterprise. Sybase...
♦ Standards and SQL/92 Vendor extension. Included in the SQL/3 draft specification. compatibility ♦ Not supported in Adaptive Server Enterprise. To implement Sybase similar features in an Adaptive Server Enterprise-compatible manner, you can use the SAVE TRANSACTION statement.
Chapter 9 SQL Statements SELECT statement Function Use this statement to retrieve information from the database. SELECT [ ALL | DISTINCT ] [ FIRST | TOP n ] select-list Syntax …[ INTO { host-variable-list | variable-list } ] …[ FROM table-expression ] …[ WHERE search-condition ] …[ GROUP BY group-by-list ] …[ HAVING search-condition ]...
Page 620
SELECT statement The FIRST and TOP keywords cannot be used in a derived table query. You should not use the keywords in view definitions. select list The select list is a list of expressions, separated by commas, specifying what will be retrieved from the database. An asterisk (*) means to select all columns of all tables in the FROM clause.
Page 621
Entry level feature. The complexity of the SELECT statement SQL/92 compatibility means that you should check individual clauses against the standard. ♦ Sybase Supported by Adaptive Server Enterprise, with some differences in syntax. ♦ Examples How many employees are there? SELECT count(*) FROM Employee;...
Page 622
SELECT statement SELECT company_name, CAST( sum(sales_order_items.quantity * product.unit_price) AS INTEGER) VALUE FROM customer JOIN sales_order JOIN sales_order_items JOIN product GROUP BY company_name ORDER BY VALUE DESC ♦ The following statement shows an Embedded SQL SELECT statement: SELECT count(*) INTO :size FROM employee...
Not supported. In Adaptive Server Enterprise, variables are Sybase assigned using the SELECT statement with no table, a Transact-SQL syntax that is also supported by Adaptive Server Anywhere. The SET statement is used to set database options in Adaptive Server Enterprise. ♦...
Page 624
SET statement EXEC SQL BEGIN DECLARE SECTION; DECL_LONGVARCHAR( 500 ) buffer; EXEC SQL END DECLARE SECTION; EXEC SQL CREATE VARIABLE hold_blob LONG VARCHAR; EXEC SQL SET hold_blob = ’’; for(;;) { /* read some data into buffer ... */ size = fread( buffer, 1, 5000, fp ); if( size <= 0 ) break;...
TRANSACTION ISOLATION LEVEL 0 | 1 | 2 | 3 Database options in Adaptive Server Anywhere are set using the SET OPTION statement. However, Adaptive Server Anywhere also provides support for the Adaptive Server Enterprise SET statement for options that are particularly useful for compatibility.
Page 626
DELETE. ♦ The default behavior in SET CLOSE_ON_ENDTRANS { ON | OFF } Adaptive Server Anywhere and Adaptive Server Enterprise for closing cursors at the end of a transaction is different. Setting CLOSE_ON_ENDTRANS to OFF provides Transact-SQL compatible behavior. ♦...
Page 627
"Isolation levels and consistency" on page 386 of the book ASA User’s Guide. For Adaptive Server Enterprise, only 1 and 3 are valid options. For Adaptive Server Anywhere, any of 0, 1, 2, or 3 is a valid option. In addition, the SET statement is allowed by Adaptive Server Anywhere for the PREFETCH option, for compatibility, but has no effect: ♦...
SQL/92 Interactive SQL use is a vendor extension. Embedded SQL is compatibility a Full level feature. ♦ Supported by Open Client/Open Server. Sybase ♦ Example The following example is in Embedded SQL. EXEC SQL SET CONNECTION :conn_name; ♦ From Interactive SQL, set the current connection to the connection named conn1.
If an error occurs, the code is returned in the SQLCA. ♦ Standards and SQL/92 Intermediate level feature. compatibility ♦ Supported by Open Client/Open Server. Sybase ♦ Example For an example, see "ALLOCATE DESCRIPTOR statement" on page 381.
SET OPTION statement SET OPTION statement Function Use this statement to change the values of database options. Syntax SET [ EXISTING ] [ TEMPORARY ] OPTION … [ userid .| PUBLIC.] option-name = [ option-value ] userid: { identifier | string | host-variable } option-name: { identifier | string | host-variable } option-value:...
Page 631
Chapter 9 SQL Statements If you specify a user ID, the option value applies to that user (or, for a group user ID, the members of that group). If you specify PUBLIC, the option value applies to all users who don’t have an individual setting for the option. By default, the option value applies to the currently logged on user ID that issued the SET OPTION statement..
Page 632
♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not supported by Adaptive Server Enterprise. Adaptive Server Anywhere does support some Adaptive Server Enterprise options using the SET statement. ♦ Examples Set the date format option to on.
Standards and Vendor extension. SQL/92 compatibility ♦ Not supported by Open Client/Open Server. Sybase ♦ Example The owning function could be found in a Windows DLL. Each application that uses the DLL has its own SQLCA. an_sql_code FAR PASCAL ExecuteSQL( an_application *app, char *com ) EXEC SQL BEGIN DECLARE SECTION;...
♦ Standards and SET SESSION AUTHORIZATION is SQL 92 compliant. SQL/92 compatibility SETUSER is a vendor extension. ♦ Adaptive Server Enterprise supports SETUSER, but not the Sybase WITH OPTIONS keywords.
Page 636
SETUSER statement ♦ Examples The following statements, executed by a user named DBA, change the user ID to be Joe, then Jane, and then back to DBA SETUSER ’Joe’ // ... operations... SETUSER WITH OPTIONS ’Jane’ // ... operations... SETUSER...
Standards and Persistent Stored Module feature. SQL/92 compatibility ♦ Sybase SIGNAL is not supported by Adaptive Server Enterprise. Examples The following compound statement declares and signals a user-defined exception. If you execute this example from Interactive SQL, the message is displayed in the Message window.
START DATABASE statement START DATABASE statement Function Use this statement to start a database on the current database server. START DATABASE database-file Syntax … [ AS database-name ] … [ ON engine-name ] … [ AUTOSTOP { ON | OFF } ] Permissions The required permissions are specified by the database server command-...
Page 639
Chapter 9 SQL Statements ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not applicable. ♦ Example Start the database file c:\asa6\sample_2.db on the current server. START DATABASE ’c:\asa6\sample_2.db’ ♦ From Interactive SQL, start the database file c:\asa6\sample_2.db sam2 on the server named sample.
14. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not applicable. ♦ Start a database server, named sample, without starting any databases on Example START ENGINE AS sample ♦ The following example shows the use of a STARTLINE clause.
Java VM at a convenient time so that when the user starts to use Java functionality there is no initial pause while the Java VM is loaded. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Not applicable. Sybase ♦ Start the Java VM. Example START JAVA...
START LOGGING statement [Interactive SQL] START LOGGING statement [Interactive SQL] Function Use this statement to start logging executed SQL statements to a log file. START LOGGING ’ filename ’ ’ Syntax Permissions None. Side effects None. See also "STOP LOGGING statement" on page 628 Description The START LOGGING statement starts copying all subsequent executed SQL statements to the log file that you specify.
By default, the database is not stopped if there are connections to it. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not applicable. Sybase ♦ Examples Stop the database named on the current server. sample STOP DATABASE sample...
UNCONDITIONALLY keyword. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not applicable. ♦ Example Stop the current database server, as long as there are no other connections. STOP ENGINE...
The STOP JAVA statement unloads the Java VM when it is not in use. The main use is to economize on the use of system resources. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase Not applicable. ♦ Stop the Java VM. Example STOP JAVA...
STOP LOGGING statement [Interactive SQL] STOP LOGGING statement [Interactive SQL] Function Use this statement to stop logging of SQL statements in the current session. Syntax STOP LOGGING Permissions None. Side effects None. See also "START LOGGING statement" on page 624 Description The STOP LOGGING statement stops the database server from writing each SQL statement you execute to a log file.
The SYSTEM statement must be entirely contained on one line. ♦ Comments are not allowed at the end of a SYSTEM statement. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ Not applicable. Sybase ♦ Example The following statement executes the system command date. SYSTEM date...
TRIGGER EVENT statement TRIGGER EVENT statement Function Use this statement to trigger a named event. The event may be defined for event triggers or be a scheduled event. Syntax TRIGGER EVENT event-name [ ( parm = value , … ) ] Permissions Must have DBA authority.
Chapter 9 SQL Statements TRUNCATE TABLE statement Function Use this statement to delete all rows from a table, without deleting the table definition. Syntax TRUNCATE TABLE [ owner .] table-name Permissions Must be the table owner, or have DBA authority, or have ALTER permissions on the table.
Page 650
If a fast truncation is carried out, then a COMMIT is carried out before and after the operation. ♦ Standards and SQL/92 Transact-SQL extension. compatibility ♦ Supported by Adaptive Server Enterprise. Sybase ♦ Example Delete all rows from the department table. TRUNCATE TABLE department...
SELECT statement. ♦ Standards and SQL/92 Entry level. compatibility ♦ Supported by Adaptive Server Enterprise, which also supports Sybase a COMPUTE clause. ♦ Examples List all distinct surnames of employees and customers. SELECT emp_lname FROM Employee UNION...
Relative filenames specify files relative to the database server's starting directory. To unload data onto a client machine, see "OUTPUT statement" on page 573. ♦ Standards and Vendor extension. SQL/92 compatibility ♦ Sybase UNLOAD is not supported by Adaptive Server Enterprise.
Chapter 9 SQL Statements UNLOAD TABLE statement Function Use this statement to export data from a database table into an external ASCII-format file. Syntax UNLOAD [ FROM ] TABLE [ owner. ] table-name … TO ' filename - string ' [ unload-option …...
Page 654
With QUOTES turned on (the default), single quotes are placed around all exported strings. ♦ Standards and SQL/92 Vendor extension. compatibility ♦ UNLOAD TABLE is not supported by Adaptive Server Sybase Enterprise. Similar functionality is provided by the Adaptive Server Enterprise bulk copy utility (bcp).
Chapter 9 SQL Statements UPDATE statement Function Use this statement to modify existing rows in database tables. UPDATE [ FIRST | TOP n ] table-list Syntax 1 … SET set-item , … … [ FROM table-list ] … [ WHERE search-condition ] …...
Page 656
UPDATE statement It provides a full list of SUBSCRIBE BY values any time the list changes. It is placed in SQL Remote triggers so that the database server can compute the current list of SUBSCRIBE BY values. Both lists are placed in the transaction log.
Page 657
Chapter 9 SQL Statements SET JProd.setName( ’Tank Top’ ) FROM clause The optional FROM clause allows tables to be updated based on joins. If the FROM clause is present, the WHERE clause qualifies the rows of the FROM clause. Data is updated only in the table list of the UPDATE clause.
Page 658
♦ Sybase Subject to the expressions being compatible, the syntax of the UPDATE statement (syntax 1) is compatible between Adaptive Server Enterprise and Adaptive Server Anywhere. Syntax 2 and 3 are not supported. ♦ Examples Transfer employee Philip Chin (employee 129) from the sales department to the marketing department.
Chapter 9 SQL Statements UPDATE (positioned) statement Function Use this statement to modify the data at the current location of a cursor. UPDATE WHERE CURRENT OF cursor-name Syntax 1 … { USING DESCRIPTOR sqlda-name | FROM host-variable-list } UPDATE table-list Syntax 2 …...
Page 660
UPDATE (positioned) statement ♦ Sybase Embedded SQL use is supported by Open Client/Open Server, and procedure and trigger use is supported in Adaptive Server Anywhere. ♦ Example The following is an example of an UPDATE statement WHERE CURRENT OF cursor: UPDATE Employee SET emp_lname = ’Jones’...
Chapter 9 SQL Statements VALIDATE INDEX statement Function Use this statement to validate an index. VALIDATE INDEX [ [ owner .] table-name .]{ index-name | table-name } Syntax Permissions Must be the owner of the table on which the index is created, have DBA authority, or have REMOTE DBA authority (SQL Remote).
VALIDATE TABLE statement VALIDATE TABLE statement Function Use this statement to validate a table in the database. VALIDATE TABLE [ owner .] table-name Syntax [ WITH { DATA | FULL | INDEX } CHECK ] Permissions Must be the owner of the table, have DBA authority, or have REMOTE DBA authority (SQL Remote).
Page 663
Chapter 9 SQL Statements ♦ Sybase VALIDATE TABLE is not supported in Adaptive Server Enterprise. The procedure dbcc checktable provides a similar function.
♦ Standards and SQL/92 Entry-level feature. compatibility ♦ Supported by Open Client/Open Server. Sybase ♦ Examples The following are examples of the WHENEVER statement: EXEC SQL WHENEVER NOTFOUND GOTO done; EXEC SQL WHENEVER SQLERROR PrintError( &sqlca ); return( FALSE );...
CONTINUE. ♦ Standards and Transact-SQL extension. SQL/92 compatibility ♦ Sybase Supported by Adaptive Server Enterprise. ♦ Example The following code illustrates the use of WHILE: WHILE (SELECT AVG(unit_price) FROM product) < $30 BEGIN...
SQL/92 Transact-SQL extension. compatibility ♦ Supported by Adaptive Server Enterprise. Sybase ♦ Example The following code fragment illustrates the use of the WRITETEXT statement. The SELECT statement in this example returns a single row. The example replaces the contents of the...
SQLCODE in the alphabetic or SQLSTATE listing. Contents Topic Page Error messages indexed by Adaptive Server Anywhere SQLCODE Error messages indexed by SQLSTATE Error messages indexed by Sybase error code Alphabetic list of error messages Internal errors (assertion failed)
Error messages indexed by Adaptive Server Anywhere SQLCODE Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -835 "Event ’%1’ in use" on page 788 -834 "Column ’%1’ not found in table ’%2’" on page 757 -833 "Row in table ’%1’...
Page 669
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE clause." on page 749 -813 "FOR UPDATE has been incorrectly specified for a READ ONLY cursor." on page 792 -812 "The Select list for the derived table ’%1’ has no expression to match %2"...
Page 670
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE exhausted" on page 744 -789 "Cannot register ’%1’ since registration cookie exhausted" on page 743 -788 "Another connection has already registered as ’%1’" on page 723 -787 "Current connection is already registered to ’%1’...
Page 671
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -767 "Cannot find synchronization %1 with name equal ’%2’" on page 738 -766 "View references ’%1’, which is a temporary object. Views can only refer to permanent objects." on page 925 -765 "Synchronization message type ’%1’...
Page 672
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -745 "Cannot initialize IQ memory manager: %1" on page 738 -744 "Invalid IQ database command line option or paramater value: %1" on page 811 -743 "Seek absolute 0 was attempted on a JDBC SAResultSet" on...
Page 673
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -723 "The length specified for column ’%1’ is different than the actual length" on page 891 -722 "The column ’%1’ does not exist in the remote table" on page 886 -721 "The data type specified for column ’%1’...
Page 674
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE page 870 -699 "Cannot update member fields qualified with "final" modifier" on page 750 -698 "The remote server does not support an auto-incrementing data type" on page 894 -697 "Error during backup: %1"...
Page 675
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -676 "The specified transaction isolation is invalid" on page 897 -675 "Java virtual machine could not be started" on page 825 -674 "statement’s size limit is invalid." on page 873 -673 "Database upgrade not possible"...
Page 676
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -649 "Field ’%1’ of class ’%2’ cannot be null" on page 791 -648 "Cannot create item (%1) in the specified dbspace." on page 731 -647 "Could not execute store DLL (%1) entry point." on page 765 -646 "Could not load the store DLL %1"...
Page 677
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -623 "Data definition statements not allowed in procedures or triggers" on page 771 -622 "Could not allocate resources to call external function" on page 763 -621 "Could not find ’%1’ in dynamic library ’%2’" on page 765 -620 "Could not load dynamic library ’%1’"...
Page 678
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -313 "The login ID ’%1’ has not been mapped to any database user ID" on page 891 -312 "User ’%1’ already has membership in group ’%2’" on page 916 -311 "Internal rollback log corrupted"...
Page 679
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -282 "Subscription to ’%1’ for ’%2’ already exists" on page 875 -281 "Table ’%1’ has publications" on page 882 -280 "Publication ’%1’ not found" on page 850 -275 "Triggers and procedures not supported in runtime server" on page 905 -274 "Procedure or trigger calls have nested too deeply"...
Page 680
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE database user ID" on page 890 -246 "Integrated logins are not supported for this database" on page 803 -245 "Integrated login failed" on page 802 -244 "Transaction log was truncated"...
Page 681
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -205 "Integrated logins are not permitted" on page 802 -204 "Only the DBA can set the option %1" on page 842 -203 "Cannot set a temporary option for user ’%1’" on page 746 -202 "Only PUBLIC settings are allowed for option ’%1’"...
Page 682
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -171 "Error opening cursor" on page 786 -170 "Cursor has not been declared" on page 769 -165 "Java VM Heap Exhausted at Internal fn: %1" on page 825 -164 "Namespace Heap Exhausted at Internal fn: %1"...
Page 683
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE -138 "Dbspace ’%1’ not found" on page 780 -137 "Table ’%1’ requires a unique correlation name" on page 884 -136 "Table ’%1’ is in an outer join cycle" on page 882 -135 "Language extension"...
Page 684
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE -108 "Connection not found" on page 760 -107 "Error writing to transaction log file" on page 787 -106 "Cannot open transaction log file -- %1" on page 742 -105 "Database cannot be started -- %1"...
Page 685
CHAPTER 10 Database Error Messages Adaptive Error message Server Anywhere SQLCODE "Invalid database server command line" on page 807 "Unable to start database server" on page 909 "Invalid local database switch" on page 813 "Dynamic memory exhausted" on page 785 "Database name not unique"...
Page 686
Error messages indexed by Adaptive Server Anywhere SQLCODE Adaptive Error message Server Anywhere SQLCODE "Unsupported character set ’%1’ and unsupported language; language used is ’%2’ instead" on page 912 "Illegal user selectivity estimate specified" on page 798 "Unable to open backup log ’%1’" on page 908 "Warning"...
CHAPTER 10 Database Error Messages Error messages indexed by SQLSTATE Adaptive Server Anywhere supports the SQLSTATE error code defined by SQL/92. Each SQLSTATE value is a 5- character string containing a 2- character class followed by a 3-character subclass. Each character can be one of the uppercase letters A through Z or the digits 0 through 9.
Page 688
Error messages indexed by SQLSTATE SQLSTATE Error message 01W17 "’%1’ is an unknown option" on page 714 02000 "Row not found" on page 862 04W07 "A dbspace has reached its maximum file size" on page 718 04W08 "The server attempted to access a page beyond the end of the maximum allowable dbspace file size"...
Page 689
CHAPTER 10 Database Error Messages SQLSTATE Error message 08W12 "Communication error" on page 758 08W13 "Not enough memory to start" on page 837 08W14 "Database name required to start server" on page 774 08W15 "Client/server communications protocol version mismatch" on page 754 08W16 "Database server not running in multi-user mode"...
Page 690
Error messages indexed by SQLSTATE SQLSTATE Error message 08W43 "Database upgrade not possible" on page 778 08W44 "Could not load the backup/restore DLL %1" on page 766 08W45 "Could not execute backup/restore DLL (%1) entry point." on page 764 08W46 "Error during backup: %1"...
Page 691
CHAPTER 10 Database Error Messages SQLSTATE Error message 0AW04 "Triggers and procedures not supported in runtime server" on page 905 0AW05 "Statement is not allowed in passthrough mode" on page 873 0AW06 "Computed columns are not supported in this database" on page 759 0AW07 "Feature not available with UltraLite"...
Page 692
Error messages indexed by SQLSTATE SQLSTATE Error message 23W01 "Primary key for table ’%1’ is not unique" on page 847 23W05 "Primary key for row in table ’%1’ is referenced in another table" on page 847 24501 "Cursor not open" on page 770 24502 "Cursor already open"...
Page 693
CHAPTER 10 Database Error Messages SQLSTATE Error message 3BW02 "Result set not allowed from within an atomic compound statement" on page 857 40000 "Run time SQL error -- %1" on page 862 40001 "Deadlock detected" on page 781 40W01 "Internal database error %1 -- transaction rolled back" on page 803 40W02 "Terminated by user -- transaction rolled back"...
Page 694
Error messages indexed by SQLSTATE SQLSTATE Error message 42W20 "CHECKPOINT statement requires a rollback log" on page 753 42W21 "Table in use" on page 885 42W22 "Attempted two active database requests" on page 724 42W23 "Procedure in use by "%1"" on page 849 42W24 "Label ’%1’...
Page 695
CHAPTER 10 Database Error Messages SQLSTATE Error message 42W45 "Cannot set a temporary option for user ’%1’" on page 746 42W46 "Only the DBA can set the option %1" on page 842 42W47 "Parameter ’%1’ not found in procedure ’%2’" on page 843 42W48 "Syntax error, cannot specify IQ specific options without specifying IQ PATH"...
Page 696
Error messages indexed by SQLSTATE SQLSTATE Error message 52010 "Item ’%1’ already exists" on page 823 52012 "More than one table is identified as ’%1’" on page 831 52W02 "Correlation name ’%1’ not found" on page 762 52W03 "Cannot find index named ’%1’" on page 737 52W04 "Index name ’%1’...
Page 697
CHAPTER 10 Database Error Messages SQLSTATE Error message 52W41 "too many temporary tables in connection" on page 902 53002 "Wrong number of values for INSERT" on page 927 53003 "Function or column reference to ’%1’ in the select list must also appear in a GROUP BY"...
Page 698
Error messages indexed by SQLSTATE SQLSTATE Error message 55W06 "Cannot drop a user that owns objects involved in replication" on page 735 55W07 "db_init has not been called or the call to db_init failed" on page 779 55W08 "Modifications not permitted for read-only database" on page 830 55W09 "Cannot commit or rollback while enlisted in a transaction"...
Page 699
CHAPTER 10 Database Error Messages SQLSTATE Error message primary key" on page 747 5RW17 "Must include primary key for table ’%1’ in the synchronization" on page 832 5RW18 "Cannot create synchronization entry for table ’%1’ with BLOB primary key" on page 732 5RW19 "Cannot update primary key for table ’%1’...
Page 700
Error messages indexed by SQLSTATE SQLSTATE Error message WB001 "Unknown backup operation" on page 910 WB002 "Database backup not started" on page 772 WB003 "Incomplete transactions prevent transaction log renaming" on page 798 WB004 "Unable to delete database file" on page 906 WB005 "Transaction log was truncated"...
Page 701
CHAPTER 10 Database Error Messages SQLSTATE Error message WJ003 "The specified transaction isolation is invalid" on page 897 WJ004 "The cursor name ’%1’ already exists" on page 887 WJ005 "Input parameter index out of range" on page 801 WJ006 "Return value cannot be set" on page 858 WJ007 "JDBC feature ’%1’...
Page 702
Error messages indexed by SQLSTATE SQLSTATE Error message page 911 WL005 "Unable to enlist transaction; DTC may be down" on page 907 WL006 "Unable to reenlist transaction; DTC may be down" on page 908 WO001 "Unable to connect to server ’%1’: %2" on page 906 WO003 "Remote server %1 is currently configured as read only"...
Page 703
CHAPTER 10 Database Error Messages SQLSTATE Error message WO022 "The data type of column ’%1’ is not supported" on page 888 WO023 "OMNI cannot handle expressions involving remote tables inside stored procedures" on page 841 WP000 "Argument %1 of procedure ’%2’ cannot be null" on page 723 WP001 "Procedure ’%1’...
Page 704
Error messages indexed by SQLSTATE SQLSTATE Error message WW015 "Field ’%1’ of class ’%2’ cannot be null" on page 791 WW016 "Index type specification of ’%1’ is invalid" on page 801 WW017 "An attempt to delete database ’%1’ failed" on page 721 WW018 "Cannot deserialize Java object"...
CHAPTER 10 Database Error Messages Error messages indexed by Sybase error code Sybase error codes are a set of error codes for use by all Sybase products, including Adaptive Server Enterprise. For every Sybase error code returned by Adaptive Server Anywhere, there is a matching Adaptive Server Anywhere error code.
Page 706
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE -262 "Label ’%1’ not found" on page 827 -261 "There is already a variable named ’%1’" on page 899 -260 "Variable ’%1’ not found" on page 924 -623 "Data definition statements not allowed in...
Page 707
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE -158 "Value %1 out of range for destination" on page 923 -191 "Cannot modify column ’%1’ in table ’%2’" on page 740 -190 "Cannot update an expression" on...
Page 708
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE -135 "Language extension" on page 827 -156 "Invalid expression near ’%1’" on page 810 "Null value eliminated in aggregate function" on page 839 "Argument %1 of procedure ’%2’ cannot be null"...
Page 709
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE -208 "Row has changed since last read -- operation cancelled" on page 861 -170 "Cursor has not been declared" on page 769 -172 "Cursor already open" on page 768 -180 "Cursor not open"...
Page 710
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE "The selected database is currently inactive" on page 896 1205 -306 "Deadlock detected" on page 781 1205 -307 "All threads are blocked" on page 720...
Page 711
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 2706 -141 "Table ’%1’ not found" on page 883 2715 -613 "User-defined type %1 not found" on page 921 2727 -189 "Unable to find in index ’%1’ for table ’%2’"...
Page 712
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 3819 -160 "Can only describe a SELECT statement" on page 727 4001 -105 "Database cannot be started -- %1" on page 772 4001 "Specified database is invalid" on...
Page 713
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 5849 -201 "Invalid setting for option ’%1’" on page 817 5864 "Invalid database server command line" on page 807 5864 -735 "Invalid parameter" on page 815 5864 "Invalid local database switch"...
Page 714
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 7301 -192 "Update operation attempted on non- updatable query" on page 914 7301 -813 "FOR UPDATE has been incorrectly specified for a READ ONLY cursor." on...
Page 715
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 9526 -187 "Illegal cursor operation attempt" on page 797 9819 -268 "Trigger ’%1’ not found" on page 904 10356 -624 "Expression has unsupported data type" on...
Page 716
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 11227 -706 "Remote server does not have the ability to support this statement" on page 853 11248 -658 "Remote server %1 is currently configured as read only"...
Page 717
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13617 "Illegal user selectivity estimate specified" on page 798 13618 "Procedure has completed" on page 849 13619 "Warning" on page 925 13620 "Authentication violation" on page 725...
Page 718
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13638 -188 "Not enough values for host variables" on page 838 13639 -266 "%1" on page 713 13640 -267 "COMMIT/ROLLBACK not allowed within atomic operation" on page 757...
Page 719
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13660 -243 "Unable to delete database file" on page 906 13661 -244 "Transaction log was truncated" on page 903 13662 -297 "User-defined exception signaled" on page 921...
Page 720
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13681 -626 "A thread used internally could not be started" on page 718 13682 -634 "Unterminated C string" on page 913 13683 "Transaction log backup page only partially full"...
Page 721
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13702 -648 "Cannot create item (%1) in the specified dbspace." on page 731 13703 "Class ’%1’ has no public field ’%2’" on page 753 13704 -650 "Index type specification of ’%1’...
Page 722
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13721 -700 "SQLDA fields inconsistent for a multi- row SQLDA" on page 870 13722 -709 "Computed columns are not supported in this database" on page 759...
Page 723
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13740 -165 "Java VM Heap Exhausted at Internal fn: %1" on page 825 13741 -649 "Field ’%1’ of class ’%2’ cannot be null" on page 791...
Page 724
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13759 -746 "Cannot allocate System V resources" on page 728 13760 -747 "Invalid JDBC resultset type" on page 812 13761 -748 "Invalid JDBC resultset concurrency" on...
Page 725
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13777 -767 "Cannot find synchronization %1 with name equal ’%2’" on page 738 13778 -768 "Cannot subscribe to ’%1’" on page 747 13779 -769 "Cannot modify synchronization entry using ALTER PUBLICATION"...
Page 726
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13797 -787 "Current connection is already registered to ’%1’ as ’%2’" on page 768 13798 -788 "Another connection has already registered as ’%1’" on page 723...
Page 727
CHAPTER 10 Database Error Messages Sybase Adaptive Server Error message error code Anywhere SQLCODE 13816 -806 "System event type ’%1’ not found" on page 880 13817 -807 "Host variables may not be used within a batch" on page 795 13818 -808 "An internal error was generated by the...
Page 728
Error messages indexed by Sybase error code Sybase Adaptive Server Error message error code Anywhere SQLCODE 13834 -828 "A conflict with the DBMLSync download phase was detected" on page 717 13836 -830 "Alias ’%1’ is not unique" on page 719...
ODBC applications, as the ODBC driver carries out the required actions. (no message) Item Value SQLCODE Constant SQLE_NOERROR SQLSTATE 00000 Sybase error code 13600 ODBC 2 State 00000 ODBC 3 State 00000 Probable cause This code indicates that there was no error or warning. (no message) Item...
Page 730
Alphabetic list of error messages (no message) Item Value SQLCODE -504 Constant SQLE_RETRY SQLSTATE WI008 Sybase error code 13693 ODBC 2 State ERROR ODBC 3 State ERROR Item Value SQLCODE -121 Constant SQLE_PERMISSION_DENIED SQLSTATE 42501 Sybase error code ODBC 2 State...
Page 731
Item Value SQLCODE -266 Constant SQLE_OLD_DBINIT SQLSTATE 42W27 Sybase error code 13639 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The database is missing some system table definitions required for this statement. These system table definitions are normally created when a database is initialized.
Page 732
’%1’ is an unknown option Item Value SQLCODE Constant SQLE_UNKNOWN_OPTION SQLSTATE 01W17 Sybase error code 13751 ODBC 2 State 01004 ODBC 3 State 01004 Probable cause You attempted to set the value of an option which is not known to the server.
Page 733
’%1’ is not a public java class, and cannot be referenced from SQL Item Value SQLCODE -762 Constant SQLE_NON_PUBLIC_JAVA_CLASS SQLSTATE WJ023 Sybase error code 13772 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Java class name Probable cause Only public java classes installed into the database are accessible from SQL.
Page 734
Alphabetic list of error messages ’%1’ is not a valid class file Item Value SQLCODE Constant SQLE_BAD_CLASS_FILE SQLSTATE WP002 Sybase error code 13736 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the invalid file. Probable cause A file passed to the INSTALL JAVA statement was not a valid Java class file.
Page 735
A conflict with the DBMLSync download phase was detected Item Value SQLCODE -828 Constant SQLE_RECORDING_CONFLICT_DETECTED SQLSTATE WW027 Sybase error code 13834 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause DBMLSync uses this error to detect download phase conflicts with rows modified by other connections.
Page 736
Item Value SQLCODE -604 Constant SQLE_DBSPACE_FULL SQLSTATE 04W07 Sybase error code 5006 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A dbspace has grown to its maximum number of disk pages, which is usually limited by the maximum operating system file size. This is a fatal error.
Page 737
Aggregate functions not allowed on this statement Item Value SQLCODE -150 Constant SQLE_AGGREGATES_NOT_ALLOWED SQLSTATE 42W06 Sybase error code 13204 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You used an UPDATE statement with an aggregate function. Alias ’%1’ is not unique...
Page 738
Item Value SQLCODE -307 Constant SQLE_THREAD_DEADLOCK SQLSTATE 40W06 Sybase error code 1205 ODBC 2 State 40001 ODBC 3 State 40001 Probable cause You attempted to read or write a row and it is locked by another user. Also, all other threads (see database option THREAD_COUNT) are blocked waiting for a lock to be released.
Page 739
Item Value SQLCODE -651 Constant SQLE_DROP_DATABASE_FAILED SQLSTATE WW017 Sybase error code 13705 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause Your attempt to delete a database file failed. You may have attempted to delete a running database. Some parts of the database may have been deleted before failure.
Page 740
Parameter 1 Java class of the object in error Probable cause This is an internal native Java object error. If it can be reproduced, it should be reported to Sybase. An internal error was generated by the test harness Item Value...
Page 741
Another connection has already registered as ’%1’ Item Value SQLCODE -788 Constant SQLE_NOT_UNIQUE_CONN_REG_LABEL SQLSTATE 5RW27 Sybase error code 13798 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Registered connection label Probable cause You attempted to register a connection with a label already in use for the same application.
Page 742
Item Value SQLCODE -310 Constant SQLE_BEYOND_EOF SQLSTATE WI001 Sybase error code 13666 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause While reading the database file, an attempt was made to read beyond the end of the file. This is a fatal internal error.
Page 743
CHAPTER 10 Database Error Messages Authentication failed Item Value SQLCODE -218 Constant SQLE_AUTHENTICATION_FAILED SQLSTATE 08W48 Sybase error code 13621 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause You set the database_authentication or connection_authentication option incorrectly. Authentication violation Item...
Page 744
Item Value SQLCODE -716 Constant SQLE_RESTORE_INVALID_FORMAT SQLSTATE WB007 Sybase error code 13725 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The format of an archive file to be used during a RESTORE is invalid. Backwards scrolling cursors are not supported for remote objects...
Page 745
Value SQLCODE -160 Constant SQLE_DESCRIBE_NONSELECT SQLSTATE 07005 Sybase error code 3819 ODBC 2 State ODBC 3 State Probable cause In the C language interface, you attempted to describe the select list of a statement other than a SELECT statement. Cannot access file ’%1’ -- %2...
Page 746
Cannot access instance member through a class Item Value SQLCODE -701 Constant SQLE_CANNOT_ACCESS_INSTANCE_MEMBER SQLSTATE WJ011 Sybase error code 13607 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause Non-static fields or methods must be accessed through an object instance. Cannot allocate System V resources...
Page 747
Item Value SQLCODE -127 Constant SQLE_COLUMN_IN_INDEX SQLSTATE 53W05 Sybase error code 4939 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You may have attempted to delete or modify the definition of a column that is part of a primary or foreign key. You may have attempted to delete a column that has an index on it.
Page 748
Value SQLCODE -800 Constant SQLE_CANNOT_COMMIT_OR_ROLLBACK_WHIL E_ENLISTED SQLSTATE 55W09 Sybase error code 13810 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You tried to explicitly commit or rollback on a connection that is enlisted in a transaction. You must use the Commit/Abort protocol of the transaction instead.
Page 749
Cannot create an index on Java class ’%1’ Item Value SQLCODE -704 Constant SQLE_CANNOT_INDEX_ON_JAVA_CLASS SQLSTATE WW022 Sybase error code 13748 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the class. Probable cause An operation requiring an index was attempted in which at attempt was made to create an index on a Java class type.
Page 750
Item Value SQLCODE -779 Constant SQLE_BLOB_IN_SYNC_TABLE_PK SQLSTATE 5RW18 Sybase error code 13789 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the table Probable cause You attempted to create a synchronization on a table with BLOB primary key.
Page 751
Cannot deregister ’%1’ since active registered connection exists Item Value SQLCODE -786 Constant SQLE_DEREG_APP_IN_USE SQLSTATE 5RW25 Sybase error code 13796 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the application Probable cause You attempted to deregister an application while there are still active connection registered to that application.
Page 752
Item Value SQLCODE -663 Constant SQLE_JAVA_DESERIALIZATION_ERROR SQLSTATE WW018 Sybase error code 13745 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The persisted Java object cannot be read from the database column. Possibly, the class of the object has been removed or modified.
Page 753
Item Value SQLCODE -731 Constant SQLE_USER_OWNS_REPLICATED_OBJECTS SQLSTATE 55W06 Sybase error code 13633 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You attempted to drop a user who is the creator of a database object involved in replication. For example. the user may own a table that is part of a publication.
Page 754
Item Value SQLCODE -128 Constant SQLE_USER_OWNS_TABLES SQLSTATE 55W03 Sybase error code 13731 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You attempted to drop a user who owns tables, while running the runtime server. This operation would result in dropping tables, which is not permitted in the runtime server.
Page 755
Item Value SQLCODE -802 Constant SQLE_CANNOT_ENLIST_WITH_UNCOMMITTED_ DATA SQLSTATE 55W11 Sybase error code 13812 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You tried to enlist a transaction on a connection that has pending uncommitted data. Cannot find index named ’%1’...
Page 756
Cannot find synchronization %1 with name equal ’%2’ Item Value SQLCODE -767 Constant SQLE_SYNCHRONIZATION_NOT_FOUND SQLSTATE 5RW12 Sybase error code 13777 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Definition, template or site Parameter 2 Name of the synchronization...
Page 757
Cannot insert or update computed column ’%1’ Item Value SQLCODE -703 Constant SQLE_COMPUTED_COLUMN_WRITE_ATTEMPTE SQLSTATE WW023 Sybase error code 4406 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the column. Probable cause Computed column values cannot be modified explicitly. Their value is determined implicitly from the computed expression value.
Page 758
Item Value SQLCODE -248 Constant SQLE_INTEGRATED_LOGON_SYSMAP SQLSTATE 28W07 Sybase error code 13696 ODBC 2 State 28000 ODBC 3 State 28000 Probable cause You attempted to map a login ID to either sys or public Cannot modify column ’%1’ in table ’%2’...
Page 759
Cannot modify publication entry using ALTER SYNCHRONIZATION Item Value SQLCODE -770 Constant SQLE_CANNOT_MODIFY_PUB_AS_SYNC SQLSTATE 5RW15 Sybase error code 13780 ODBC 2 State 42000 ODBC 3 State 42S02 Probable cause You attempted to modify a publication entry using an alter synchronization statement.
Page 760
Cannot open transaction log file -- %1 Item Value SQLCODE -106 Constant SQLE_CANNOT_OPEN_LOG SQLSTATE 08W05 Sybase error code 2561 ODBC 2 State 08003 ODBC 3 State 08003 Parameter 1 Reason why transaction log file cannot be opened. Probable cause The database server was unable to open the named transaction log file. The log file name may include an invalid device or directory.
Page 761
Cannot register ’%1’ since registration cookie exhausted Item Value SQLCODE -789 Constant SQLE_APP_REG_COOKIE_EXHAUSTED SQLSTATE 5RW28 Sybase error code 13799 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the application Probable cause Cannot register until someone deregistered.
Page 762
Item Value SQLCODE -784 Constant SQLE_CANNOT_REG_CONN SQLSTATE 5RW23 Sybase error code 13794 ODBC 2 State 42000 ODBC 3 State 42S02 Probable cause Application registration cannot be found for the given cookie. Cannot register connection to ’%1’ since automatic label exhausted...
Page 763
Cannot remove class ’%1’: member of Jar Item Value SQLCODE -653 Constant SQLE_CLASS_MEMBER_OF_JAR SQLSTATE WP004 Sybase error code 13743 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the class file that can’t be removed Probable cause You attempted to remove a class file which is still part of a Jar.
Page 764
Cannot set a temporary option for user ’%1’ Item Value SQLCODE -203 Constant SQLE_TEMPORARY_NOT_ALLOWED SQLSTATE 42W45 Sybase error code 13687 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 user ID whose option was to be changed. Probable cause TEMPORARY options are set on a connection basis.
Page 765
Cannot subscribe to ’%1’ Item Value SQLCODE -768 Constant SQLE_CANNOT_SUBSCRIBE SQLSTATE 5RW13 Sybase error code 13778 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the publication. Probable cause Some publications are not subscribable such as a synchronization publication.
Page 766
Cannot uniquely identify column ’%2’ of table ’%1’ in the current jdbc resultset Item Value SQLCODE -756 Constant SQLE_JDBC_TBL_COL_NOT_FOUND_IN_RESULT SQLSTATE WJ021 Sybase error code 13766 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Table name Parameter 2 Column name...
Page 767
Value SQLCODE -190 Constant SQLE_NON_UPDATEABLE_COLUMN SQLSTATE 53W02 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You tried to update a column in a query that is a database expression rather than a column in a table.
Page 768
Cannot update column ’%1’ since it does not appear in the SELECT clause. Item Value SQLCODE -815 Constant SQLE_UPDATE_NOT_IN_SELECT SQLSTATE 42W38 Sybase error code 7740 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Name of the column that does not appear in the SELECT clause. Probable cause You attempted to update a column that does not explicitly appear in the SELECT list.
Page 769
Cannot update or delete an all-NULL row from table ’%1’ Item Value SQLCODE -734 Constant SQLE_CANNOT_UPDATE_NULL_ROW SQLSTATE 09W08 Sybase error code 13750 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 The name of the table which cannot be modified. Probable cause You attempted to modify or delete a row in the specified table, which is part of the null-supplying side of an outer join.
Page 770
Item Value SQLCODE -780 Constant SQLE_SYNC_ARTICLE_PK_CANNOT_BE_UPDAT SQLSTATE 5RW19 Sybase error code 13790 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the table. Probable cause The primary key of a table involved in a synchronization publication cannot be updated.
Page 771
Item Value SQLCODE -212 Constant SQLE_CHECKPOINT_REQUIRES_UNDO SQLSTATE 42W20 Sybase error code 13653 ODBC 2 State 40001 ODBC 3 State 40001 Probable cause You cannot use a CHECKPOINT statement when the database server is running in bulk mode without a rollback log.
Page 772
Item Value SQLCODE -231 Constant SQLE_DBLIB_ENGINE_MISMATCH SQLSTATE 08W19 Sybase error code 13658 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause Your executable uses a database interface library that does not match the version number of the database server.
Page 773
Column %1 in foreign key has a different definition than primary Item Value SQLCODE -113 Constant SQLE_INVALID_FOREIGN_KEY_DEF SQLSTATE 53030 Sybase error code 1721 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Name of the problem column. Probable cause The data type of the column in the foreign key is not the same as the data type of the column in the primary key.
Page 774
Column ’%1’ in table ’%2’ cannot be NULL Item Value SQLCODE -195 Constant SQLE_COLUMN_CANNOT_BE_NULL SQLSTATE 23502 Sybase error code ODBC 2 State 23000 ODBC 3 State 23000 Parameter 1 Name of the column that cannot be NULL. Parameter 2 Name of the table containing the column.
Page 775
Column ’%1’ not found in table ’%2’ Item Value SQLCODE -834 Constant SQLE_COLUMN_NOT_FOUND_IN_TABLE SQLSTATE 52005 Sybase error code 13840 ODBC 2 State S0002 ODBC 3 State 42S22 Parameter 1 Name of the column that could not be found. Parameter 2 Name of the table that was supposed to contain the column.
Page 776
Value SQLCODE -273 Constant SQLE_INVALID_TRIGGER_STATEMENT SQLSTATE 2D501 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You attempted to execute a statement that is not allowed while performing a trigger action. COMMIT and ROLLBACK statements cannot be executed from a trigger.
Page 777
Item Value SQLCODE -709 Constant SQLE_COMPUTED_COLUMNS_NOT_SUPPORTED SQLSTATE 0AW06 Sybase error code 13722 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause The current database is an older database and does not have catalog support for computed (materialized) columns. To use this feature, upgrade your database to the most recent version.
Page 778
Connection not found Item Value SQLCODE -108 Constant SQLE_CONNECTION_NOT_FOUND SQLSTATE 08W02 Sybase error code 4224 ODBC 2 State 08003 ODBC 3 State 08003 Probable cause The specified connection name on a DISCONNECT or SET CONNECTION statement is invalid. Connection was terminated...
Page 779
Connections to database have been disabled Item Value SQLCODE Constant SQLE_CONNECTIONS_DISABLED SQLSTATE 08W04 Sybase error code 4224 ODBC 2 State 08005 ODBC 3 State 08005 Probable cause Connections to the network database server have been disabled. You will receive this error until they have been reenabled on the server console.
Page 780
Item Value SQLCODE -142 Constant SQLE_CORRELATION_NAME_NOT_FOUND SQLSTATE 52W02 Sybase error code ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the invalid correlation name. Probable cause You misspelled a correlation name, or you used a table name instead of the correlation name.
Page 781
Item Value SQLCODE -622 Constant SQLE_ERROR_CALLING_FUNCTION SQLSTATE WW008 Sybase error code 13679 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The external function could not be called due to a shortage of operating system resources. If the operating system supports threads, the maximum thread count should be increased.
Page 782
Could not decompress class ’%1’ from Jar. Item Value SQLCODE -652 Constant SQLE_CANNOT_DECOMPRESS_CLASS SQLSTATE WP003 Sybase error code 13742 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the class file in the Jar Probable cause The Java runtime library must be installed to extract class files from .ZIPs or...
Page 783
Item Value SQLCODE -647 Constant SQLE_STORE_ENTRY_NOT_FOUND SQLSTATE 08W35 Sybase error code 13700 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause An attempt to locate or execute the store DLL entry point failed. Could not find ’%1’ in dynamic library ’%2’...
Page 784
Could not load dynamic library ’%1’ Item Value SQLCODE -620 Constant SQLE_COULD_NOT_LOAD_LIBRARY SQLSTATE WW006 Sybase error code 13677 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the dynamic library which could not be loaded. Probable cause This error is usually caused by a failure to load a dynamic library named in an external function call.
Page 785
Could not load the store DLL %1 Item Value SQLCODE -646 Constant SQLE_STORE_NOT_LOADED SQLSTATE 08W34 Sybase error code 13699 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause An attempt to load the store DLL failed. Creating remote tables with computed columns is not supported...
Page 786
Current connection is already registered to ’%1’ as ’%2’ Item Value SQLCODE -787 Constant SQLE_CONN_ALREADY_REGISTERED SQLSTATE 5RW26 Sybase error code 13797 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the application Parameter 2 Registered connection label Probable cause You attempted to register this connection more than once.
Page 787
Item Value SQLCODE -170 Constant SQLE_CURSOR_NOT_DECLARED SQLSTATE 24W01 Sybase error code ODBC 2 State 24000 ODBC 3 State 24000 Probable cause You attempted to OPEN a cursor that has not been declared. Cursor is restricted to FETCH NEXT operations Item...
Page 788
Cursor not open Item Value SQLCODE -180 Constant SQLE_CURSOR_NOT_OPEN SQLSTATE 24501 Sybase error code ODBC 2 State 34000 ODBC 3 State 34000 Probable cause You attempted to OPEN a cursor that has not been declared. Cursor operation conflict Item Value...
Page 789
Value SQLCODE -623 Constant SQLE_DDL_NOT_ALLOWED_IN_PROCEDURES SQLSTATE 52W21 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The procedure or trigger definition contains a data definition statement (such as CREATE, DROP, GRANT, REVOKE, ALTER). These statements are not allowed within procedures or triggers.
Page 790
Item Value SQLCODE -241 Constant SQLE_BACKUP_NOT_STARTED SQLSTATE WB002 Sybase error code 3206 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A database backup could not be started. Either you do not have DBA authority, or another backup has started and not completed.
Page 791
Item Value SQLCODE -645 Constant SQLE_DATABASE_NOT_CREATED SQLSTATE 08W33 Sybase error code ODBC 2 State 08004 ODBC 3 State 08004 Probable cause Your attempt to initialize a file for a database or for a write file failed. Database is active Item...
Page 792
Database name required to start server Item Value SQLCODE Constant SQLE_DATABASE_NAME_REQUIRED SQLSTATE 08W14 Sybase error code ODBC 2 State 08001 ODBC 3 State 08001 Probable cause You did not supply a database name. A database name is required to start the database server.
Page 793
Item Value SQLCODE Constant SQLE_PAGE_SIZE_TOO_BIG SQLSTATE 08W22 Sybase error code ODBC 2 State 08004 ODBC 3 State 08004 Probable cause You attempted to start a database or create a write file for a database with a page size that exceeds the maximum page size of the running server. Either restart the server with this database named on the command line, or restart the server with a larger page size.
Page 794
Item Value SQLCODE -102 Constant SQLE_TOO_MANY_CONNECTIONS SQLSTATE 08W03 Sybase error code 1601 ODBC 2 State 08004 ODBC 3 State 08004 Probable cause You exceeded the number of computers allowed to connect to the server. If you are running the network database server, the limit is spelled out in your license agreement.
Page 795
Database server not running in multi-user mode Item Value SQLCODE Constant SQLE_ENGINE_NOT_MULTIUSER SQLSTATE 08W16 Sybase error code 7203 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause The database server was started for bulk loading (the -b switch) and cannot be used as a network server.
Page 796
Database upgrade not possible Item Value SQLCODE -673 Constant SQLE_DATABASE_UPGRADE_NOT_POSSIBLE SQLSTATE 08W43 Sybase error code 3451 ODBC 2 State 08004 ODBC 3 State 08004 Probable cause An attempt to upgrade a database failed. The database is too old to be upgraded.
Page 797
Item Value SQLCODE -827 Constant SQLE_USER_TABLES_IN_SYSTEM_RANGE SQLSTATE 08W58 Sybase error code 13833 ODBC 2 State 08004 ODBC 3 State 08004 Probable cause An attempt to upgrade a database failed. The RowGenerator table is not owned by user dbo.
Page 798
Dbspace ’%1’ not found Item Value SQLCODE -138 Constant SQLE_DBSPACE_NOT_FOUND SQLSTATE 52W13 Sybase error code 1802 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the dbspace that could not be found. Probable cause You tried to access a dbspace that the database server could not find.
Page 799
Item Value SQLCODE -306 Constant SQLE_DEADLOCK SQLSTATE 40001 Sybase error code 1205 ODBC 2 State 40001 ODBC 3 State 40001 Probable cause You attempted to read or write a row and it is locked by another user. Also, the other user is blocked directly or indirectly on your own transaction. This is a deadlock situation and your transaction has been chosen as the one to rollback.
Page 800
Derived table ’%1’ has no name for column %2 Item Value SQLCODE -163 Constant SQLE_NO_COLUMN_NAME SQLSTATE 52004 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of the derived table. Parameter 2 Number of the column for which there is no name.
Page 801
Disk full ’%1’ -- transaction rolled back Item Value SQLCODE -304 Constant SQLE_DEVICE_FULL SQLSTATE 40W03 Sybase error code 3618 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause Your hard disk is out of space. A ROLLBACK WORK statement has been automatically executed.
Page 802
Duplicate insert column Item Value SQLCODE -637 Constant SQLE_DUPLICATE_INSERT_COLUMN SQLSTATE 42W41 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You supplied a duplicate column name in the list of insert columns. Duplicate referencing column Item...
Page 803
CHAPTER 10 Database Error Messages Dynamic memory exhausted Item Value SQLCODE Constant SQLE_DYNAMIC_MEMORY_EXHAUSTED SQLSTATE 08W26 Sybase error code 9119 ODBC 2 State S1001 ODBC 3 State HY001 Probable cause A failure occurred when trying to allocate dynamic memory. Error during backup: %1...
Page 804
Error number %1 for RAISERROR is less than 17000 Item Value SQLCODE -296 Constant SQLE_ERROR_NUMBER_OUT_OF_RANGE SQLSTATE 53W07 Sybase error code 2732 ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Error number. Probable cause You supplied an invalid error number in a RAISERROR statement. The number must be greater than or equal to 17000.
Page 805
Error parsing connection parameter string Item Value SQLCODE -655 Constant SQLE_GEN_PARSE_ERROR SQLSTATE 08W38 Sybase error code 13707 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause The connection string could not be parsed. The string or connection parameter file contains a syntax error.
Page 806
Event ’%1’ already exists Item Value SQLCODE -772 Constant SQLE_EVENT_ALREADY_EXISTS SQLSTATE WE002 Sybase error code 13782 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the event that already exists. Probable cause You have attempted to create an event with a name that already exists in SYS.SYSEVENT.
Page 807
Event ’%1’ not found Item Value SQLCODE -771 Constant SQLE_EVENT_NOT_FOUND SQLSTATE WE001 Sybase error code 13781 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the event that could not be found. Probable cause You have attempted to reference an event with a name that does not exist in SYS.SYSEVENT.
Page 808
Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The unimplemented feature. Probable cause You attempted to carry out an operation or use a feature that is not implemented in this version of Adaptive Server Anywhere.
Page 809
Item Value SQLCODE -749 Constant SQLE_NOT_SUPPORTED_IN_ULTRALITE SQLSTATE 0AW07 Sybase error code 13762 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You attempted to execute a statement or use a feature that is not supported in an UltraLite database. For example, UltraLite does not support statements that modify the schema of the database.
Page 810
Item Value SQLCODE -813 Constant SQLE_NON_UPDATEABLE_CURSOR SQLSTATE 42W36 Sybase error code 7301 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You attempted to declare a cursor FOR UPDATE on a query that is not updatable. Queries that contain DISTINCT, GROUP BY, HAVING, or UNION, or that contain aggregate functions are read only.
Page 811
Item Value SQLCODE -145 Constant SQLE_FOREIGN_KEY_NAME_NOT_FOUND SQLSTATE 52W07 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of the non-existing foreign key. Probable cause You misspelled the name of a foreign key, or the foreign key does not exist.
Page 812
Item Value SQLCODE -149 Constant SQLE_INVALID_GROUP_SELECT SQLSTATE 53003 Sybase error code 7321 ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of the column referenced directly, or in an expression, that must be in the GROUP BY clause.
Page 813
Value SQLCODE -305 Constant SQLE_DEVICE_ERROR SQLSTATE 40W04 Sybase error code 3013 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause Adaptive Server Anywhere has detected a problem with your hard disk. A ROLLBACK WORK statement has been automatically executed.
Page 814
Identifier ’%1’ too long Item Value SQLCODE -250 Constant SQLE_IDENTIFIER_TOO_LONG SQLSTATE 54003 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 The identifier in error. Probable cause An identifier is longer than 128 characters. Identity attribute mismatch for column ’%1’...
Page 815
Item Value SQLCODE -187 Constant SQLE_CURSOROP_NOT_ALLOWED SQLSTATE 09W02 Sybase error code 9526 ODBC 2 State 07005 ODBC 3 State 07005 Probable cause You attempted an illegal cursor operation. For example, you may be attempting to OPEN a cursor for a statement that is neither a SELECT nor a BATCH.
Page 816
Value SQLCODE Constant SQLE_INVALID_USER_ESTIMATE SQLSTATE 01W16 Sybase error code 13617 ODBC 2 State ODBC 3 State Probable cause You specified a user selectivity estimate that is either not a literal constant or is outside the range 0.0 to 100.0 (estimates are specified as percentages). The estimate has been ignored.
Page 817
Item Value SQLCODE -711 Constant SQLE_STORE_VERSION_MISMATCH SQLSTATE 08W47 Sybase error code 13701 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The store and server DLL versions do not match. Index ’%1’ for table ’%2’ would not be unique...
Page 818
Index name ’%1’ is ambiguous Item Value SQLCODE -678 Constant SQLE_AMBIGUOUS_INDEX_NAME SQLSTATE 52W40 Sybase error code 1921 ODBC 2 State S0011 ODBC 3 State 42S11 Parameter 1 Name of the ambiguous index. Probable cause A statement has referred to an index name which is not unique. Preface the index name by an owner name.
Page 819
Index type specification of ’%1’ is invalid Item Value SQLCODE -650 Constant SQLE_INVALID_INDEX_TYPE SQLSTATE WW016 Sybase error code 13704 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause IQ index types can be specified for IQ indexes only. Input parameter index out of range...
Page 820
Integrated login failed Item Value SQLCODE -245 Constant SQLE_INTEGRATED_LOGON_FAILED SQLSTATE 28W04 Sybase error code 13691 ODBC 2 State 28000 ODBC 3 State 28000 Probable cause The integrated login failed. You may not have a system account on the server machine.
Page 821
ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Identification of the error. Probable cause An internal database error occurred. If it can be reproduced, it should be reported to Sybase. A ROLLBACK WORK statement has been automatically executed.
Page 822
Value SQLCODE -311 Constant SQLE_LOG_CORRUPTED SQLSTATE WI004 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause While processing a COMMIT or ROLLBACK, corruption was found in the internal rollback log. This is a fatal internal error.
Page 823
Item Value SQLCODE -159 Constant SQLE_INVALID_COLUMN_NUMBER SQLSTATE 42W13 Sybase error code ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You gave an invalid column number, or the column you are looking for is in a different table. Invalid comparison...
Page 824
Item Value SQLCODE Constant SQLE_CANNOT_CONVERT SQLSTATE 01W03 Sybase error code ODBC 2 State 07006 ODBC 3 State 07006 Probable cause The database could not convert a value to the required type. The value being converted was either supplied to the database on an insert, update or as a host bind variable, or was a value retrieved from the database into a host variable or SQLDA.
Page 825
ODBC 3 State 42000 Probable cause You attempted to create a database with an invalid page size. The page size for an Adaptive Server Anywhere database must be either 1024, 2048, or 4096 bytes. Invalid database server command line Item...
Page 826
Invalid day of week or month ’%1’ for event ’%2’ Item Value SQLCODE -791 Constant SQLE_INVALID_EVENT_DAY SQLSTATE WE005 Sybase error code 13801 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Day-of-week name or day-of-month number. Parameter 2 Name of the event being scheduled.
Page 827
Invalid escape character ’%1’ Item Value SQLCODE -629 Constant SQLE_INVALID_ESCAPE_CHAR SQLSTATE 22019 Sybase error code 7707 ODBC 2 State S1000 ODBC 3 State 22019 Probable cause The escape character string length must be exactly one. Invalid escape sequence ’%1’ Item...
Page 828
Value SQLCODE -680 Constant SQLE_INVALID_TSQL_OJ_EXPRESSION SQLSTATE 52W23 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause An expression in the WHERE clause of a query which uses Transact-SQL syntax contains a comparison of a column from the null-supplying table with a subquery or an expression which references a column from another table.
Page 829
Item Value SQLCODE -155 Constant SQLE_VARIABLE_INVALID SQLSTATE 42W07 Sybase error code 7201 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You supplied an invalid host variable to the database using the C language interface. You may have supplied the variable as a host variable or through a SQLDA.
Page 830
Item Value SQLCODE -730 Constant SQLE_BAD_JAR_FILE SQLSTATE WP010 Sybase error code 13737 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A file passed to the INSTALL JAVA statement was not a valid jar file. Invalid JDBC resultset concurrency...
Page 831
Item Value SQLCODE -681 Constant SQLE_INVALID_TSQL_JOIN_TYPE SQLSTATE 52W24 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause An invalid join type was used with a query that contains Transact-SQL outer join comparison operators. Invalid local database switch...
Page 832
Invalid operation on a closed ’%1’ Item Value SQLCODE -696 Constant SQLE_JDBC_OBJ_CLOSED SQLSTATE WJ010 Sybase error code 13605 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Java class of the closed object Probable cause An illegal attempt was made to access a closed JDBC object.
Page 833
Item Value SQLCODE -200 Constant SQLE_INVALID_OPTION SQLSTATE 42W16 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of the invalid option. Probable cause You may have misspelled the name of an option in the SET OPTION statement.
Page 834
Invalid prepared statement type Item Value SQLCODE -133 Constant SQLE_INVALID_STATEMENT_TYPE SQLSTATE 07W03 Sybase error code 13630 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause This is an internal error. If it can be reproduced, it should be reported to Sybase.
Page 835
Item Value SQLCODE -820 Constant SQLE_INVALID_POSITION SQLSTATE 24504 Sybase error code 13826 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You attempted to scroll to a position that is not supported. Scroll positions must be between -2147483647 and 2147483646.
Page 836
Invalid SQL descriptor name Item Value SQLCODE -642 Constant SQLE_INVALID_DESCRIPTOR_NAME SQLSTATE 33000 Sybase error code ODBC 2 State 33000 ODBC 3 State 33000 Probable cause You attempted to deallocate a descriptor that has not been allocated. Invalid SQL identifier Item...
Page 837
Invalid start date/time for event ’%1’ Item Value SQLCODE -793 Constant SQLE_INVALID_EVENT_START SQLSTATE WE007 Sybase error code 13803 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the event being scheduled. Probable cause You have specified an event starting date or time which has already passed.
Page 838
Invalid TEXTPTR value used with WRITETEXT or READTEXT Item Value SQLCODE -608 Constant SQLE_INVALID_TEXTPTR_VALUE SQLSTATE 22W03 Sybase error code 7123 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You supplied an invalid value as the TEXTPTR for a WRITETEXT or READTEXT statement.
Page 839
Invalid type for field reference Item Value SQLCODE Constant SQLE_INVALID_FIELD_REFERENCE SQLSTATE WW014 Sybase error code 13738 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause An expression attempted to reference a field or a method of a non-Java value. Field references via ’.’ and ’>>’ are only valid when applied to Java objects.
Page 840
Invalid user ID or password Item Value SQLCODE -103 Constant SQLE_INVALID_LOGON SQLSTATE 28000 Sybase error code 4002 ODBC 2 State 28000 ODBC 3 State 28000 Probable cause You supplied an invalid user ID or an incorrect password. Invalid user ID or password...
Page 841
Item Value SQLCODE -209 Constant SQLE_INVALID_COLUMN_VALUE SQLSTATE 23506 Sybase error code ODBC 2 State 42000 ODBC 3 State 23000 Parameter 1 Name of the column that was assigned an invalid value. Parameter 2 Name of the table containing the column.
Page 842
Jar %1 not found Item Value SQLCODE -811 Constant SQLE_JAR_NOT_FOUND SQLSTATE 42W58 Sybase error code 13821 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Name of the jar. Probable cause The jar with this name does not exist in SYSJAR.
Page 843
Item Value SQLCODE -675 Constant SQLE_JAVA_VM_NOT_STARTED SQLSTATE WP006 Sybase error code 13747 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A problem was encountered starting the Java virtual machine. Possible problems include not enough memory, or incomplete installation of the Java runtime support classes.
Page 844
JDBC feature ’%1’ not supported Item Value SQLCODE -693 Constant SQLE_UNSUPPORTED_JDBC_FEATURE SQLSTATE WJ007 Sybase error code 13602 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the attempted feature Probable cause An attempt was made to use a feature of JDBC that is not supported.
Page 845
Value SQLCODE -135 Constant SQLE_LANGUAGE_EXTENSION SQLSTATE 0AW01 Sybase error code ODBC 2 State 37000 ODBC 3 State ERROR Probable cause You used a SQL statement that may be valid in some versions of SQL, but not in Adaptive Server Anywhere.
Page 846
Language extension detected in syntax Item Value SQLCODE Constant SQLE_SYNTAX_EXTENSION_WARNING SQLSTATE 01W07 Sybase error code 5703 ODBC 2 State ODBC 3 State Probable cause The statement you are executing contains extensions to ANSI 1992 Entry level SQL. Memory error -- transaction rolled back...
Page 847
Method ’%1’ cannot be called at this time Item Value SQLCODE -669 Constant SQLE_METHOD_CANNOT_BE_CALLED SQLSTATE WJ001 Sybase error code 13711 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the method Probable cause The method cannot be called at this time. Check that the method is not being called out of order.
Page 848
Modifications not permitted for read-only database Item Value SQLCODE -757 Constant SQLE_READ_ONLY_DATABASE SQLSTATE 55W08 Sybase error code 13768 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You attempted an update operation on a database that was declared as read- only.
Page 849
Item Value SQLCODE Constant SQLE_MORE_INFO SQLSTATE 01W09 Sybase error code 13686 ODBC 2 State 37000 ODBC 3 State Probable cause More information is required to complete the request. This is used internally in the database interface library to process a unified logon. It should not be returned to an application.
Page 850
Must include primary key for table ’%1’ in the synchronization Item Value SQLCODE -778 Constant SQLE_PK_NOT_IN_SYNC_ARTICLE SQLSTATE 5RW17 Sybase error code 13788 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 Name of the table Probable cause The primary key of the table must be included in the synchonization entry.
Page 851
Need a dynamic library name Item Value SQLCODE -619 Constant SQLE_REQUIRE_DLL_NAME SQLSTATE WW005 Sybase error code 13676 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You must provide a library name specifier in the name of the external function to call.
Page 852
No database file specified Item Value SQLCODE Constant SQLE_NO_DATABASE_FILE SQLSTATE 08W39 Sybase error code 4001 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause The database server was started but there was no specified database file. The server is stopped.
Page 853
No primary key value for foreign key ’%1’ in table ’%2’ Item Value SQLCODE -194 Constant SQLE_INVALID_FOREIGN_KEY SQLSTATE 23503 Sybase error code ODBC 2 State 23000 ODBC 3 State 23000 Parameter 1 Name of the foreign key. Parameter 2 Name of the table with the foreign key.
Page 854
Item Value SQLCODE -101 Constant SQLE_NOT_CONNECTED SQLSTATE 08003 Sybase error code 13622 ODBC 2 State 08003 ODBC 3 State 08003 Probable cause You are not connected to a database, or you executed the DISCONNECT statement and have not connected to a database again.
Page 855
Value SQLCODE -679 Constant SQLE_OMNI_MEMORY_CONFIG SQLSTATE WO009 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The Java heap size and Java name space configuration values in sysoptions must be increased to allow the loading of the Java classes used for remote access.
Page 856
Item Value SQLCODE -188 Constant SQLE_NOT_ENOUGH_HOST_VARS SQLSTATE 07001 Sybase error code 13638 ODBC 2 State 07002 ODBC 3 State 07002 Probable cause You have not provided enough host variables for either the number of bind variables, or the statement, or the number of select list items.
Page 857
Item Value SQLCODE Constant SQLE_NULL_VALUE_ELIMINATED SQLSTATE 01003 Sybase error code ODBC 2 State ODBC 3 State Probable cause The expression argument of the aggregate function evaluated to NULL for one or more rows. Number in ORDER BY is too large...
Page 858
Value SQLCODE -733 Constant SQLE_TOO_MANY_NULL_COLUMNS SQLSTATE 23504 Sybase error code ODBC 2 State 23000 ODBC 3 State 23000 Probable cause You attempted to create or modify a table definition such that the number of columns that allow nulls is now more than the limit on such columns. The limit is a function of database page size and is approximately 8*(page_size - 30).
Page 859
Item Value SQLCODE -823 Constant SQLE_OMNI_EXPRESSION_IN_PROC SQLSTATE WO023 Sybase error code 13829 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause OMNI encountered a complicated expression involving remote tables inside a stored procedure. OMNI cannot always deal with such expressions.
Page 860
Item Value SQLCODE -204 Constant SQLE_OPTION_REQUIRES_DBA SQLSTATE 42W46 Sybase error code 5878 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause The option specified in the SET OPTION statement can only be set by a user having DBA authority.
Page 861
Value SQLCODE -615 Constant SQLE_INVALID_PARAMETER_NAME SQLSTATE 42W47 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You supplied a procedure parameter name that does not match a parameter for this procedure. Check the spelling of the parameter name.
Page 862
Item Value SQLCODE -671 Constant SQLE_PARAM_NOT_REGISTERED SQLSTATE WJ002 Sybase error code 13712 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The parameter must be registered as an output parameter before the value of the parameter can be obtained.
Page 863
Item Value SQLCODE -287 Constant SQLE_PASSTHROUGH_INCONSISTENT SQLSTATE 5RW08 Sybase error code 13649 ODBC 2 State S0002 ODBC 3 State 42S02 Probable cause Passthrough is additive, in that subsequent passthrough statements add to the list of users receiving passthrough. The passthrough statements must all be PASSTHROUGH ONLY or none should be PASSTHROUGH ONLY.
Page 864
Item Value SQLCODE -825 Constant SQLE_PREVIOUS_ERROR_LOST SQLSTATE WP011 Sybase error code 13831 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A RESIGNAL statement in an exception handler of a stored procedure was executed but the context of the previous error was unavailable. A possible cause of this error is a SELECT statement which returns a result set in the exception handler.
Page 865
Primary key for row in table ’%1’ is referenced in another table Item Value SQLCODE -198 Constant SQLE_PRIMARY_KEY_VALUE_REF SQLSTATE 23W05 Sybase error code ODBC 2 State 23000 ODBC 3 State 23000 Parameter 1 The name of the table containing the row being modified. Probable cause You attempted to delete or modify a row whose primary key value is referenced elsewhere in the database.
Page 866
Item Value SQLCODE -265 Constant SQLE_PROCEDURE_NOT_FOUND SQLSTATE 52W09 Sybase error code ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the procedure that could not be found. Probable cause You misspelled the name of a procedure, or you did not qualify a procedure name with a user name.
Page 867
Value SQLCODE Constant SQLE_PROCEDURE_COMPLETE SQLSTATE 01W05 Sybase error code 13618 ODBC 2 State ODBC 3 State Probable cause There are no more result sets available for this procedure. An OPEN or a RESUME statement may have caused the procedure to execute to completion.
Page 868
Procedure or trigger calls have nested too deeply Item Value SQLCODE -274 Constant SQLE_NESTING_TOO_DEEP SQLSTATE 42W29 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You may have defined a procedure or trigger that causes unlimited recursion. Publication ’%1’ not found Item...
Page 869
RAISERROR executed: %1 Item Value SQLCODE -631 Constant SQLE_RAISERROR_STMT SQLSTATE WW012 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 RAISERROR message string Probable cause A RAISERROR statement has been executed. READTEXT or WRITETEXT statement cannot refer to a view...
Page 870
Remote message type ’%1’ not found Item Value SQLCODE -286 Constant SQLE_NOT_REMOTE_TYPE SQLSTATE 5RW07 Sybase error code 13648 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of remote message type. Probable cause You referred to a remote message type that is not defined in this database.
Page 871
Remote server %1 is currently configured as read only Item Value SQLCODE -658 Constant SQLE_OMNI_READONLY SQLSTATE WO003 Sybase error code 11248 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the remote server. Probable cause You attempted to perform an update on an object located on a server that is configured as read only.
Page 872
Item Value SQLCODE -288 Constant SQLE_REMOTE_STATEMENT_FAILED SQLSTATE 5RW09 Sybase error code 13650 ODBC 2 State S0002 ODBC 3 State 42S02 Probable cause This SQLSTATE can be signaled within a trigger to prevent DBREMOTE from displaying an error message in the output. This exception will only occur when a trigger or procedure SIGNALS it.
Page 873
Request to start/stop database denied Item Value SQLCODE Constant SQLE_START_STOP_DATABASE_DENIED SQLSTATE 08W29 Sybase error code 6004 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You do not have permission to start or stop a database. The required permission is determined on the server command line.
Page 874
RESTORE unable to open file ’%1’ Item Value SQLCODE -717 Constant SQLE_RESTORE_UNABLE_TO_OPEN SQLSTATE WB008 Sybase error code 13726 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 File name of database file. Probable cause RESTORE was unable to open one of the database files.
Page 875
RESTORE unable to write to file ’%1’ Item Value SQLCODE -718 Constant SQLE_RESTORE_UNABLE_TO_WRITE SQLSTATE WB009 Sybase error code 13727 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 File name of database file. Probable cause RESTORE was unable to write to one of the database files.
Page 876
Item Value SQLCODE -705 Constant SQLE_PROCEDURE_RETURNS_VOID SQLSTATE 53019 Sybase error code ODBC 2 State 07006 ODBC 3 State 07006 Parameter 1 Name of the procedure. Probable cause The Java type void does not map onto any SQL type, hence a procedure returning void cannot be used in any SQL expression.
Page 877
Right truncation of string data Item Value SQLCODE -638 Constant SQLE_STRING_RIGHT_TRUNCATION SQLSTATE 22001 Sybase error code 9502 ODBC 2 State 22001 ODBC 3 State 22001 Probable cause Non-space characters were truncated upon the assignment of string data. Rollback occurred due to deadlock during prefetch...
Page 878
Item Value SQLCODE -221 Constant SQLE_ROLLBACK_NOT_ALLOWED SQLSTATE 3B002 Sybase error code 13654 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You attempted a ROLLBACK TO SAVEPOINT within an atomic operation to a savepoint established before the atomic operation.
Page 879
Value SQLCODE -208 Constant SQLE_ROW_UPDATED_SINCE_READ SQLSTATE 22W02 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You attempted an UPDATE (positioned) or DELETE (positioned) operation on a cursor declared as a SCROLL cursor, and the row you are changing has been updated since you read it.
Page 880
Value SQLCODE Constant SQLE_NOTFOUND SQLSTATE 02000 Sybase error code ODBC 2 State ODBC 3 State Probable cause You positioned a cursor beyond the beginning or past the end of the query. There is no row at that position. Run time SQL error -- %1...
Page 881
Savepoint ’%1’ not found Item Value SQLCODE -220 Constant SQLE_SAVEPOINT_NOTFOUND SQLSTATE 3B001 Sybase error code 6401 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of savepoint. Probable cause You attempted to rollback to a savepoint that does not exist.
Page 882
Schedule ’%1’ for event ’%2’ already exists Item Value SQLCODE -774 Constant SQLE_SCHEDULE_ALREADY_EXISTS SQLSTATE WE004 Sybase error code 13784 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the schedule that already exists. Parameter 2 Name of the event being scheduled.
Page 883
Item Value SQLCODE -743 Constant SQLE_JDBC_RESULTSET_SEEK_ABSOLUTE_ZER SQLSTATE WJ016 Sybase error code 13756 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause There is no row zero on JDBC resultSets. The valid row numbers are 1, 2, ..., -2, -1.
Page 884
Item Value SQLCODE -185 Constant SQLE_TOO_MANY_RECORDS SQLSTATE 21000 Sybase error code 13637 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You tried to use a SELECT statement without a cursor, but the statement cursor returns more than one row. Only a single row SELECT statement can be used in this context.
Page 885
SYSCAPABILITYNAME table. Item Value SQLCODE -761 Constant SQLE_CAPABILITY_NOT_FOUND SQLSTATE WO014 Sybase error code 13723 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of server capability. Probable cause An ALTER SERVER statement was attempted on a capability that was not defined.
Page 886
Item Value SQLCODE -737 Constant SQLE_SIGNATURE_MISMATCH SQLSTATE 42W54 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 The value of the signature Probable cause The number of types in the signature must match the number of procedure parameters.
Page 887
Specified database is invalid Item Value SQLCODE Constant SQLE_INVALID_DATABASE SQLSTATE 08W11 Sybase error code 4001 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause The database file you specified is invalid. The database server is stopped. Specified database not found...
Page 888
SQL statement error Item Value SQLCODE -132 Constant SQLE_STATEMENT_ERROR SQLSTATE 26501 Sybase error code 13629 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The statement identifier (generated by PREPARE) passed to the database for a further operation is invalid.
Page 889
Item Value SQLCODE -230 Constant SQLE_PP_DBLIB_MISMATCH SQLSTATE 08W18 Sybase error code 13657 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause Your executable has source files with Embedded SQL that were preprocessed with a preprocessor that does not match the database interface library.
Page 890
Value SQLCODE Constant SQLE_CANNOT_EXECUTE_STMT SQLSTATE 01W08 Sybase error code ODBC 2 State ODBC 3 State Probable cause You specified a statement for the PREPARE..WITH EXECUTE statement that cannot be executed. If you specified an output SQLDA, it may contain a DESCRIBE of the prepared statement.
Page 891
Item Value SQLCODE -707 Constant SQLE_STMT_NOT_ALLOWED_IN_PASSTHROUG SQLSTATE 0AW05 Sybase error code 13631 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You tried to execute a statement that cannot be executed while in passthrough mode. For example, you may have executed a batch statement.
Page 892
Value SQLCODE -151 Constant SQLE_SUBQUERY_SELECT_LIST SQLSTATE 53023 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You entered a subquery which has more than one column in the select list. Change the select list to have only one column.
Page 893
CHAPTER 10 Database Error Messages Subscription to ’%1’ for ’%2’ already exists Item Value SQLCODE -282 Constant SQLE_SUBSCRIPTION_NOT_UNIQUE SQLSTATE 5RW03 Sybase error code 13644 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the publication. Parameter 2 Name of the user.
Page 894
Synchronization message type ’%1’ not found Item Value SQLCODE -765 Constant SQLE_NOT_SYNC_TYPE SQLSTATE 5RW11 Sybase error code 13775 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of synchronization message type. Probable cause You referred to a synchronization message type that is not defined in this database.
Page 895
Synchronization option ’%1’ not found Item Value SQLCODE -805 Constant SQLE_SYNC_OPTION_NOT_FOUND SQLSTATE 5RW33 Sybase error code 13815 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 The name of the synchronization option Probable cause You attempted to delete a undefined synchronization option.
Page 896
Item Value SQLCODE -794 Constant SQLE_UPLOAD_FAILED_AT_SERVER SQLSTATE 0AW09 Sybase error code 13804 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You attempted to synchronize an UltraLite database and during the synchronization session, a complete upload stream was sent that could not be commited to the consolidated database.
Page 897
Syntax error near ’%1’ Item Value SQLCODE -131 Constant SQLE_SYNTAX_ERROR SQLSTATE 42W04 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 The word or symbol where the syntax error has been detected. Probable cause The database server cannot understand the statement you are trying to execute.
Page 898
System event type ’%1’ not found Item Value SQLCODE -806 Constant SQLE_EVENT_TYPE_NOT_FOUND SQLSTATE WE008 Sybase error code 13816 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the system event type that could not be found. Probable cause You have attempted to create an event with a system event type name that does not exist in SYS.SYSEVENTTYPE.
Page 899
Item Value SQLCODE -677 Constant SQLE_TABLE_HAS_REFACTION SQLSTATE 56001 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 Name of the table with the referential action Probable cause The table could not be renamed as it has a foreign key with a referential action.
Page 900
Table ’%1’ has publications Item Value SQLCODE -281 Constant SQLE_TABLE_HAS_PUBLICATIONS SQLSTATE 5RW02 Sybase error code 13643 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the publication that has publications. Probable cause You attempted to drop a table that has publications defined.
Page 901
Table ’%1’ is part of a synchronization definition Item Value SQLCODE -819 Constant SQLE_SYNC_CONTAINS_TABLE SQLSTATE 5RW35 Sybase error code 13825 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 The name of the table Probable cause A table belonging to a synchronization definition cannot be dropped or altered except using DBMLSync.
Page 902
Item Value SQLCODE -137 Constant SQLE_CORRELATION_NAME_NEEDED SQLSTATE 52W15 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of the table that needs a unique correlation name. Probable cause You specified a join that joins a table to itself. You need to use unique correlation names in order to have multiple instances of a table.
Page 903
Table cannot have two primary keys Item Value SQLCODE -126 Constant SQLE_PRIMARY_KEY_TWICE SQLSTATE 52W05 Sybase error code 1923 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You specified the primary key twice in a CREATE TABLE statement. Table in use...
Page 904
Terminated by user -- transaction rolled back Item Value SQLCODE -302 Constant SQLE_TERMINATED_BY_USER SQLSTATE 40W02 Sybase error code 3618 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You canceled a statement while the database was executing. A ROLLBACK WORK statement has been automatically executed.
Page 905
Item Value SQLCODE -654 Constant SQLE_NO_PROFILE_FILE SQLSTATE 08W37 Sybase error code 13706 ODBC 2 State 08001 ODBC 3 State 08001 Probable cause An attempt was made to parse a connection string containing a connection profile but the connection parameters file could not be found.
Page 906
The data type of column ’%1’ is not supported Item Value SQLCODE -736 Constant SQLE_OMNI_UNSUPPORTED_DATATYPE SQLSTATE WO022 Sybase error code 11205 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the column. Probable cause The column is defined with a data type that is not supported for remote tables.
Page 907
Item Value SQLCODE -758 Constant SQLE_NO_JAVA_SUPPORT SQLSTATE WJ022 Sybase error code 13769 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The Java virtual machine could not be started because the database does not have the proper support. It may be that the database was created with an older version of the software, or was created with the Java support disabled.
Page 908
Item Value SQLCODE -247 Constant SQLE_INTEGRATED_LOGON_GUESTMAP SQLSTATE 28W06 Sybase error code 13695 ODBC 2 State 28000 ODBC 3 State 28000 Probable cause You attempted to map the guest login ID to something other than guest The JDBC resultset must be positioned on an insert row in order to use the ’%1’...
Page 909
Item Value SQLCODE -723 Constant SQLE_OMNI_LENGTH_MISMATCH SQLSTATE WO017 Sybase error code 11210 ODBC 2 State ODBC 3 State Parameter 1 The name of the column. Probable cause The length of the column specified in the ’CREATE EXISTING’ statement is different than the length of the column in the remote table.
Page 910
The database server was unable to construct a valid access plan for the given request. This is an Adaptive Server Anywhere internal error. If it can be reproduced, it should be reported by Sybase. You may be able to work...
Page 911
The option %1 can only be set as a temporary option Item Value SQLCODE -216 Constant SQLE_OPTION_IS_TEMP_ONLY SQLSTATE 42W52 Sybase error code 5878 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause The option specified in the SET OPTION statement can only be set as a temporary option.
Page 912
Item Value SQLCODE -606 Constant SQLE_PATTERN_TOO_LONG SQLSTATE WW001 Sybase error code 7706 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The pattern for the LIKE operator is too long. All patterns of 126 characters or less are supported. Some patterns as long as 254 characters are supported, depending on their contents.
Page 913
The remote table ’%1’ could not be found Item Value SQLCODE -666 Constant SQLE_OMNI_RMT_TABLE_NOTFOUND SQLSTATE WO007 Sybase error code 11214 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The complete name of the remote table Probable cause The table could not be found on the remote server. Check the remote table name and the user privileges on that table.
Page 914
Item Value SQLCODE Constant SQLE_DATABASE_NOT_ACTIVE SQLSTATE 08W30 Sybase error code ODBC 2 State 08001 ODBC 3 State 08001 Probable cause The selected database is in an inactive state. The database may be in the process of being started or of being shut down.
Page 915
Item Value SQLCODE -729 Constant SQLE_UNENFORCEABLE_FOREIGN_KEY SQLSTATE 23507 Sybase error code ODBC 2 State 23000 ODBC 3 State 23000 Parameter 1 Name of the foreign key. Probable cause You attempted to create a foreign key that can not be enforced. In order to enforceable, the primary and foreign table for the specified key must exist on the same server.
Page 916
Item Value SQLCODE -740 Constant SQLE_FAILED_TO_CREATE_STREAMS_ENV SQLSTATE WW024 Sybase error code 13753 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause The streams environment could not be created. Either there are insufficient resources to create the environment or the language resource file cannot be found.
Page 917
Item Value SQLCODE -109 Constant SQLE_STILL_ACTIVE_CONNECTIONS SQLSTATE 08W06 Sybase error code 6001 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You attempted to shut down a database which still has active connections. There is already a variable named ’%1’...
Page 918
There is more than one way to join ’%1’ to ’%2’ Item Value SQLCODE -147 Constant SQLE_AMBIGUOUS_JOIN SQLSTATE 52W08 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Name of first table that cannot be joined. Parameter 2 Name of second table that cannot be joined.
Page 919
Item Value SQLCODE -616 Constant SQLE_TOO_MANY_COLUMNS_IN_TABLE SQLSTATE 52W20 Sybase error code 1702 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You executed a CREATE TABLE or ALTER TABLE statement, which attempted to add a column to a table. The resulting number of columns in the table would exceed the limit for the current database page size.
Page 920
Transact-SQL feature not supported Item Value SQLCODE -611 Constant SQLE_TSQL_FEATURE_NOT_SUPPORTED SQLSTATE 0AW02 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You attempted to use a Transact-SQL feature that is not supported in Adaptive Server Anywhere.
Page 921
Item Value SQLCODE Constant SQLE_BACKUP_PAGE_INCOMPLETE SQLSTATE 01W10 Sybase error code 13683 ODBC 2 State ODBC 3 State Probable cause A DB_LOG_BACKUP_READ_WAIT was issued against the transaction log and the page returned was not full. The application should reissue the request for the same page.
Page 922
Trigger ’%1’ not found Item Value SQLCODE -268 Constant SQLE_TRIGGER_NOT_FOUND SQLSTATE 52W10 Sybase error code 9819 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the trigger that could not be found. Probable cause You misspelled the name of a trigger, or you did not qualify a trigger name with a user name.
Page 923
Value SQLCODE -275 Constant SQLE_PROCEDURES_NOT_IN_DESKTOP SQLSTATE 0AW04 Sybase error code ODBC 2 State ERROR ODBC 3 State ERROR Probable cause You attempted to call a stored procedure or have modified a row in a table on which a trigger is defined and you are using the runtime server. Triggers and stored procedures are not supported in the runtime server.
Page 924
Unable to connect to server ’%1’: %2 Item Value SQLCODE -656 Constant SQLE_OMNI_CONNECT_ERROR SQLSTATE WO001 Sybase error code 11206 ODBC 2 State ERROR ODBC 3 State ERROR Parameter 1 The name of the server that could not be connected to Parameter 2 A more specific reason returned from the server class driver.
Page 925
Name of table containing the invalid index. Probable cause This is an internal error. If it can be reproduced, it should be reported to Sybase. You should be able to work around the error by dropping and recreating the index.
Page 926
Unable to open backup log ’%1’ Item Value SQLCODE Constant SQLE_UNABLE_TO_OPEN_BACKUP_LOG SQLSTATE WB011 Sybase error code 13776 ODBC 2 State ODBC 3 State Parameter 1 backup log filename Probable cause The server was unable to open the backup log to record the execution of a BACKUP or RESTORE statement.
Page 927
Item Value SQLCODE Constant SQLE_UNABLE_TO_START_ENGINE SQLSTATE 08W07 Sybase error code ODBC 2 State 08001 ODBC 3 State 08001 Probable cause It was not possible to start the database server. There may not be enough memory to run the database server. It may be that the executable cannot be found.
Page 928
Undefined synchronization template ’%1’ Item Value SQLCODE -795 Constant SQLE_SYNC_TEMPLATE_NOT_FOUND SQLSTATE 5RW30 Sybase error code 13805 ODBC 2 State 42000 ODBC 3 State 42S02 Parameter 1 The name of the synchronization template Probable cause You attempted to define a remote synchronization site using an undefined synchronization template.
Page 929
Item Value SQLCODE -148 Constant SQLE_UNKNOWN_FUNC SQLSTATE 42W05 Sybase error code ODBC 2 State 37000 ODBC 3 State 42000 Parameter 1 Function name that is not a database function. Probable cause You misspelled the name of a database function (such as MAXIMUM instead of MAX) in a query definition or in a query column name.
Page 930
Item Value SQLCODE Constant SQLE_UNSUPPORTED_CHARACTER_SET SQLSTATE 01W13 Sybase error code 13614 ODBC 2 State ODBC 3 State Parameter 1 Name of the character set that could not be supported. Probable cause The character set that the application requested is not supported by the server to which the application was attempting a connection.
Page 931
Unsupported language; language used is ’%1’ instead Item Value SQLCODE Constant SQLE_UNSUPPORTED_LANGUAGE SQLSTATE 01W14 Sybase error code 13615 ODBC 2 State ODBC 3 State Parameter 1 Name of the language that the server will use to send language strings. Probable cause The language that the application requested is not supported by the server to which the application is connecting.
Page 932
Update operation attempted on a read-only cursor Item Value SQLCODE -633 Constant SQLE_READ_ONLY_CURSOR SQLSTATE 42W30 Sybase error code 7732 ODBC 2 State S1009 ODBC 3 State HY092 Probable cause You attempted an update operation on a cursor that was explicitly declared as read-only.
Page 933
Item Value SQLCODE -728 Constant SQLE_NON_UPDATEABLE_EXT_TAB SQLSTATE 42W35 Sybase error code 7338 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause You attempted an update, or delete operation on a remote table that is currently not implemented. Examples of such operations include positioned updates and updates that require building of work tables.
Page 934
User ’%1’ already has membership in group ’%2’ Item Value SQLCODE -312 Constant SQLE_ALREADY_HAS_GROUP_MEMBERSHIP SQLSTATE 42W34 Sybase error code 13627 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Name of the user ID that already has membership. Parameter 2 Name of the group.
Page 935
User ’%1’ is already the publisher for this database Item Value SQLCODE -284 Constant SQLE_ONLY_ONE_PUBLISHER SQLSTATE 5RW05 Sybase error code 13646 ODBC 2 State S0002 ODBC 3 State 42S02 Parameter 1 Name of the publisher. Probable cause You attempted to GRANT PUBLISH to a user ID, when a publisher already exists.
Page 936
User ’%1’ is not a user group Item Value SQLCODE -123 Constant SQLE_NOT_A_GROUP SQLSTATE 42W03 Sybase error code 13626 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Name of user you thought was a group. Probable cause You attempted to add a member to group, but the user ID specified as a group has not been granted the GROUP special privilege.
Page 937
User message %1 already exists Item Value SQLCODE -610 Constant SQLE_MESSAGE_ALREADY_EXISTS SQLSTATE 52W16 Sybase error code 13624 ODBC 2 State 42000 ODBC 3 State 42000 Probable cause The message with this error number already exists in the SYSUSERMESSAGES system table.
Page 938
Item Value SQLCODE -750 Constant SQLE_USER_OWNS_PROCEDURES_IN_USE SQLSTATE 42W55 Sybase error code 3702 ODBC 2 State 40001 ODBC 3 State 40001 Probable cause You attempted to REVOKE CONNECT from a user that owns a procedure being used by other active users of the database.
Page 939
Item Value SQLCODE -297 Constant SQLE_USER_DEFINED_EXCEPTION SQLSTATE 99999 Sybase error code 13662 ODBC 2 State ERROR ODBC 3 State ERROR Probable cause A stored procedure or trigger signaled a user-defined exception. This error state is reserved for use within stored procedures or triggers which contain exception handlers, as a way of signaling an exception which can be guaranteed to not have been caused by the database server.
Page 940
Item Value SQLCODE Constant SQLE_TEMPORARY_TABLE SQLSTATE 01W02 Sybase error code 13075 ODBC 2 State ODBC 3 State Probable cause A temporary table has been created in order to satisfy the query. It can only occur on an OPEN statement. VALIDATE TABLE statement must refer to a base table...
Page 941
Item Value SQLCODE -158 Constant SQLE_OVERFLOW_ERROR SQLSTATE 22003 Sybase error code ODBC 2 State 22003 ODBC 3 State 22003 Parameter 1 The value that caused the overflow. Probable cause You supplied to or fetched from the database a value that is out of range for the destination column or host variable.
Page 942
Value truncated Item Value SQLCODE Constant SQLE_TRUNCATED SQLSTATE 01004 Sybase error code 7337 ODBC 2 State 01004 ODBC 3 State 01004 Probable cause You may have tried to insert, update, or select a value in the database that is too large to fit in the destination. You may have fetched data into a host variable or SQLDA variable not large enough to receive the value.
Page 943
Item Value SQLCODE -766 Constant SQLE_VIEW_OVER_TEMP_OBJECT SQLSTATE 42U00 Sybase error code 4412 ODBC 2 State 42000 ODBC 3 State 42000 Parameter 1 Temporary object name Probable cause Views must refer only to permanent objects, not to temporary objects such as local temporary tables.
Page 944
Item Value SQLCODE -632 Constant SQLE_WITH_CHECK_OPTION_VIOLATION SQLSTATE 44000 Sybase error code ODBC 2 State S1000 ODBC 3 State 44000 Parameter 1 Name of the base table being updated. Probable cause You attempted an insert or update operation on the indicated base table through a view (possibly nested).
Page 945
Value SQLCODE -207 Constant SQLE_WRONG_NUM_OF_INSERT_COLS SQLSTATE 53002 Sybase error code ODBC 2 State 21S01 ODBC 3 State 21S01 Probable cause The number of values you are trying to insert does not match the number of columns specified in the INSERT statement, or the number of columns in the table if no columns are specified.
Page 946
Item Value SQLCODE -755 Constant SQLE_UNCOMMITTED_TRANSACTIONS SQLSTATE 0AW08 Sybase error code 13765 ODBC 2 State 37000 ODBC 3 State 42000 Probable cause You attempted to synchronize an UltraLite database and there are changes in the UltraLite database that have not been committed.
CHAPTER 10 Database Error Messages Internal errors (assertion failed) Adaptive Server Anywhere has many internal checks that have been designed to detect possible database corruption as soon as possible. If the database server prints an Assertion Failed message, you should not continue to use it before attempting to determine the cause.
C H A P T E R SQL Preprocessor Error Messages About this chapter This chapter presents a list of all SQL preprocessor errors and warnings. Contents Topic Page SQL Preprocessor error messages indexed by error message value SQLPP errors...
SQL Preprocessor error messages indexed by error message value SQL Preprocessor error messages indexed by error message value Message value Message 2601 "subscript value %1 too large" on page 949 2602 "combined pointer and arrays not supported for hosttypes" on page 941 2603 "only one dimensional arrays supported for char type"...
Page 951
Chapter 11 SQL Preprocessor Error Messages Message value Message 2619 "Cannot find include file ’%1’" on page 937 2620 "host variable ’%1’ is unknown" on page 942 2621 "indicator variable ’%1’ is unknown" on page 944 2622 "invalid type for indicator variable ’%1’"...
Page 952
SQL Preprocessor error messages indexed by error message value Message value Message 2641 "must specify an SQLDA on a DESCRIBE" on page 946 2642 "Two SQLDAs specified of the same type (INTO or USING)" on page 938 2643 "cannot use both DESCRIBE INTO and FETCH INTO on OPEN"...
Page 953
Chapter 11 SQL Preprocessor Error Messages Message value Message 2666 "vendor extension" on page 950 2667 "intermediate SQL feature" on page 944 2668 "full SQL feature" on page 942 2669 "transact SQL extension" on page 949 2680 "no declare section and no INCLUDE SQLCA statement"...
SQLPP errors SQLPP errors This section lists messages generated by the SQL preprocessor. The messages may be errors or warnings, or either depending on which command-line options are set. For more information about the SQL Preprocessor and its command- line options, see "The SQL preprocessor" on page 81 of the book ASA Programming Interfaces Guide.
Page 955
Chapter 11 SQL Preprocessor Error Messages Cannot find include file ’%1’ Message value Message Type 2619 Error Probable cause The specified include file was not found. Note that the preprocessor will use the INCLUDE environment variable to search for include files. FIXCHAR type must have a length Message value Message Type...
Page 956
SQLPP errors Inconsistent number of host variables for this cursor Message value Message Type 2690 Error Into clause not allowed on declare cursor - ignored Message value Message Type 2660 Warning Invalid array dimension Message value Message Type 2648 Error Probable cause The array dimension of the variable is negative.
Page 957
Chapter 11 SQL Preprocessor Error Messages Unknown hostvar type Message value Message Type 2613 Error Probable cause You declared a host variable of a type not understood by the SQL preprocessor. VARCHAR host variables cannot be pointers Message value Message Type 2606 Error Probable cause...
Page 958
SQLPP errors arrays of VARCHAR not supported Message value Message Type 2605 Error Probable cause You have attempted to declare a host variable as an array of VARCHAR or BINARY. This is not a legal host variable type. arrays of decimal not allowed Message value Message Type 2612...
Page 959
Chapter 11 SQL Preprocessor Error Messages combined pointer and arrays not supported for hosttypes Message value Message Type 2602 Error Probable cause You have used an array of pointers as a host variable. This is not legal. cursor ’%1’ not previously declared Message value Message Type 2627...
Page 960
SQLPP errors field used more than once in SET DESCRIPTOR statement Message value Message Type 2651 Error Probable cause The same keyword has been used more than once inside a single SET DESCRIPTOR statement. full SQL feature Message value Message Type 2668 Flag (warning or error) host variable ’%1’...
Page 961
Chapter 11 SQL Preprocessor Error Messages host variables not allowed for this cursor Message value Message Type 2629 Error Probable cause Host variables are not allowed on the declare statement for the specified cursor. If the cursor name is provided through a host variable, then you should use full dynamic SQL and prepare the statement.
Page 962
SQLPP errors incorrect SQL language usage -- that is a ’%1’ extension Message value Message Type 2634 Error indicator variable ’%1’ is unknown Message value Message Type 2621 Error Probable cause You have used a indicator variable in a statement and that indicator variable has not been declared in a declare section.
Page 963
Chapter 11 SQL Preprocessor Error Messages invalid field for SET DESCRIPTOR Message value Message Type 2650 Error Probable cause An invalid or unknown keyword is present in a SET DESCRIPTOR statement. The keywords can only be TYPE, PRECISION, SCALE, LENGTH, INDICATOR, or DATA. invalid host variable type on ’%1’...
Page 964
SQLPP errors invalid type for sql statement variable Message value Message Type 2618 Error Probable cause A host variable used as a statement identifier should be of type a_sql_statement_number. You attempted to use a host variable of some other type as a statement identifier. missing ending quote of string Message value Message Type...
Page 965
Chapter 11 SQL Preprocessor Error Messages Probable cause A cursor is declared and opened, but is never used. no INTO clause on SELECT statement Message value Message Type 2633 Error Probable cause You specified an embedded static SELECT statement but you did not specify an INTO clause for the results.
Page 966
SQLPP errors only one dimensional arrays supported for char type Message value Message Type 2603 Error Probable cause You have attempted to declare a host variable as an array of character arrays. This is not a legal host variable type. precision must be specified for decimal type Message value Message Type...
Page 967
Chapter 11 SQL Preprocessor Error Messages Probable cause You have used a static statement name and preprocessed with the -r reentrancy switch. Static statement names cause static variables to be generated that are filled in by the database. If two threads use the same statement, contention arises over this variable.
Page 968
SQLPP errors unknown sql function ’%1’ Message value Message Type 2662 Warning Probable cause You have used a SQL function that is unknown to the preprocessor and will probably cause an error when the statement is sent to the database engine. unknown statement ’%1’...
Page 969
Chapter 11 SQL Preprocessor Error Messages Probable cause You have used a SQL function with the wrong number of parameters. This will likely cause an error when the statement is sent to the database engine.
C H A P T E R Differences from Other SQL Dialects About this chapter Adaptive Server Anywhere conforms to the ANSI SQL89 standard but has many additional features defined in IBM’s DB2 and SAA specification, and in ANSI SQL/92.
Adaptive Server Anywhere SQL features Adaptive Server Anywhere SQL features The following features of the SQL supported by Adaptive Server Anywhere are not found in many other SQL implementations. Type conversions Full type conversion is implemented. Any data type can be compared with or used in any expression with any other data type.
Page 973
Many SQL implementations only allow subqueries allowed on the right side of a comparison operator. For example, the following command is valid in Adaptive Server Anywhere but not valid in most other SQL implementations. SELECT emp_lname,...
C H A P T E R Physical Limitations About this chapter This chapter describes the limitations on size and number of objects in Adaptive Server Anywhere databases. Contents Topic Page Size and number limitations...
Size and number limitations Size and number limitations The following table lists the physical limitations on size and number of objects in Adaptive Server Anywhere database. The memory, CPU, and disk drive of the computer are more limiting factors in most cases. Item...
System Procedures and Functions About this chapter This chapter documents the system-supplied catalog stored procedures in Adaptive Server Anywhere databases, used to retrieve system information. The chapter also documents system-supplied extended procedures, including procedures for sending e-mail messages on a MAPI e-mail system.
System procedure overview System procedure overview Adaptive Server Anywhere includes the following kinds of system procedures: ♦ Catalog stored procedures, for displaying system information in tabular form. ♦ Extended stored procedures for MAPI e-mail support and other functions. ♦ Transact-SQL system and catalog procedures.
Chapter 14 System Procedures and Functions System and catalog stored procedures System and catalog stored procedures are owned by the user ID . Some of these procedures are for internal system use. This section documents only those not intended solely for system and internal use. You cannot call external functions on Windows CE.
Page 982
System and catalog stored procedures You can use the sa_check_commit system procedure to check whether there are any outstanding referential integrity violations, before attempting to commit your changes. The returned parameters indicate the name of a table containing a row that is currently violating referential integrity, and the name of the corresponding foreign key index.
Page 983
Chapter 14 System Procedures and Functions ♦ LastReqTime ♦ ProcessTime ♦ Port ♦ ReqType ♦ CommLink ♦ NodeAddr ♦ LastIdle ♦ CurrTaskSwitch ♦ BlockedOn ♦ UncmtOps. ♦ LockName In a deadlock situation, the BlockedOn value returned by this procedure allows you to check which users are blocked, and who they are blocked on. sa_locks procedure can be used to display the locks held by the blocking connection;...
Page 984
System and catalog stored procedures sa_conn_properties_by_conn system procedure Function Reports connection property information Syntax sa_conn_properties_by_conn ( [ property-name ] ) None. Permissions Side effects None See also "sa_conn_properties system procedure" on page 965 "Connection-level properties" on page 1090 Description This is a variant on the sa_conn_properties system procedure, and returns the same result columns.It returns results only for connection properties that match the property-name string.
Page 985
Chapter 14 System Procedures and Functions For a listing of available connection properties, see " System " on page 310sa_db_info system procedure functions Function Reports database property information Syntax sa_db_info ( [ database-id ] ) Permissions None. Side effects None See also "sa_db_properties system procedure"...
Page 986
System and catalog stored procedures Description Returns the database ID number and the Number, PropNum, PropName, PropDescription, and Value, for each available database property. sa_eng_properties system procedure Function Reports database server property information Syntax sa_eng_properties Permissions None. Side effects None See also "Server-level properties"...
Page 987
Chapter 14 System Procedures and Functions sa_index_levels system procedure Function To assist in performance tuning by reporting the number of levels in an index. sa_index_levels ( [ ’table_name ’ [, ’owner_name ’ ] ) Syntax Permissions DBA authority required. Side effects None See also "CREATE INDEX statement"...
Page 988
System and catalog stored procedures table_name A char(128) parameter representing a table name. The procedure returns information only about the specified tables. The default value is NULL, in which case information is returned about all tables. If you do not include owner, it is assumed that the table is owned by the caller of the procedure.
Page 989
Chapter 14 System Procedures and Functions Permissions DBA authority required Side effects Causes a checkpoint to occur after the value has been updated. Description The next value generated for a row inserted into the table will be new_identity_value + 1. No checking occurs on the new_identity_value to ensure that it does not conflict with existing rows in the table.
Page 990
System and catalog stored procedures disable_connections When set to ON, no other connections are allowed to any databases on the database server. liveness_timeout A liveness packet is sent periodically across a client/server TCP/IP or SPX communications protocol to confirm that a connection is intact.
Page 991
Chapter 14 System Procedures and Functions ♦ Connections ♦ Disconnections ♦ Beginnings of transactions ♦ DROP STATEMENT statement. ♦ Cursor explanations ♦ Cursor closings ♦ Cursor resume ♦ Errors You can find the current value of this setting using the RequestLogging property function.
Page 992
System and catalog stored procedures Description This procedure is equivalent to calling the VALIDATE TABLE statement for each table in the database. For information, see "VALIDATE TABLE statement" on page 644. tbl-name Validate only the specified table. When NULL (the default), validate all tables.
Page 993
♦ Standards and Supported by Open Client/Open Server. Sybase compatibility ♦ Example To get a list of the columns in the sysobjects table in the production database in an ASE named "asetest".
Page 994
System and catalog stored procedures "CREATE SERVER statement" on page 464 See also "Tables are related by foreign keys" on page 100 of the book Getting Started with ASA Description This procedure provides information about the remote table that has a foreign key on a particular primary key table.
Page 995
Chapter 14 System Procedures and Functions "CREATE SERVER statement" on page 464 See also "Tables are related by foreign keys" on page 100 of the book Getting Started with ASA Description Foreign keys reference a row in a separate table that contains the corresponding primary key.
Page 996
1 if you want the result set to include a column that lists table types. argument is only available for databases created in with_table_type Adaptive Server Anywhere 7.0.2 and higher. If you use this argument with an older database, the following error message is returned: Wrong number of parameters to function ’sp_remote_tables’...
Page 997
Description This procedure displays information about a remote server’s capabilities. Adaptive Server Anywhere uses this capability information to determine how much of a SQL statement can be forwarded to a remote server. The system tables which contain server capabilities are not populated until after Adaptive Server Anywhere first connects to the remote server.
Page 998
System and catalog stored procedures If you wish to change the default behavior, it is recommended that you create new procedures and alter your LOGIN_PROCEDURE option to point to these new procedures. ♦ Example Here is the text of the sp_tsql_environment procedure: create procedure dbo.sp_tsql_environment() begin if db_property(’IQStore’)=’OFF’...
The following sections describe each of the stored procedures. MAPI system extended stored procedures Adaptive Server Anywhere includes three system procedures for sending electronic mail using Microsoft’s Messaging API standard (MAPI). These system procedures are implemented as extended stored procedures: each procedure calls a function in an external DLL.
Page 1000
System extended stored procedures [, mail_password = mail-password ] Permissions None. Description xp_startmail is a system stored procedure that starts an e-mail session. The mail-login-name and mail-password values are strings containing the MAPI login name and password to be used in the mail session. If you are using Microsoft Exchange, the mail_login_name argument is an Exchange profile name, and you should not include a password in the procedure call.
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers