Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 12 Accessing

Catalog Information with CSPs [Table of Contents] Chapter 14 Using SQL

Stored Procedures

Access Service User's Guide DirectConnect Anywhere

[-] Chapter 13 Retrieving information with System Procedures

Chapter 13

Retrieving information with System Procedures

This chapter describes how to use system procedures to retrieve information. It covers the following topics:

General description

System procedures are Sybase-supplied stored procedures that return information about the access service and the target database.

ODBC and ASE/CIS use system procedures to obtain information about DirectConnect Anywhere capabilities.

If the access service cannot support one of these procedures, the procedure returns a correctly formatted result set containing zero rows.

Several procedures either are not supported by Adaptive Server or are defined differently from Adaptive Server. The defined procedures are as follows:

The following procedures have been defined to support ASE/CIS products:

sp_capabilities

Description

Returns the SQL capabilities of an access service.

Syntax

sp_capabilities

Parameters

This procedure does not allow parameters.

Usage

Results

The following table shows the result set:

Result set for sp_capabilities

Column

Datatype

Description

ID

int

Capability ID

CAPABILITY_NAME

char(30)

Capability name

VALUE

int

Capability value

DESCRIPTION

char(128)

Capability description

The following table shows values for the capabilities.

Values for sp_capabilities

Capability Number

Capability

Description

101

SQL syntax

  • 1 = Sybase supported

  • 2 = DB2 supported

102

join handling

  • 0 = unsupported

  • 1 = all but outer join supported

  • 2 = full join supported

103

aggregate handling

  • 0 = unsupported

  • 1 = count not supported

  • 2 = all functions

104

AND predicates

  • 0 = unsupported

  • 1 = supported

105

OR predicates

  • 0 = unsupported

  • 1 = supported

106

LIKE predicates

  • 0 = unsupported

  • 1 = ANSI supported

  • 2 = Sybase supported

107

bulk insert handling

  • 0 = unsupported

  • 1 = supported

108

text/image handling

  • 0 = unsupported

  • 1 = text without textptr supported

  • 2 = text with textptr supported

109

transaction handling

  • 0 = unsupported

  • 1 = local supported

  • 2 = two-phase-commit supported

110

text pattern handling

  • 0 = unsupported

  • 1 =supported

111

order by

  • 0 = unsupported

  • 1 = supported

112

group by

  • 0 = unsupported

  • 1 = supported

113

net password encryption

  • 0 = unsupported

  • 1 = supported

114

object case sensitivity

  • 0 = case-insensitive

  • 1 = case-sensitive

115

distinct

  • 0 = unsupported

  • 1 = supported

116

wildcard escape

  • 0 = unsupported

  • Anything else is the escape character

117

union handling

  • 0 = unsupported

  • 1 = supported

118

string functions

  • 0 = unsupported

  • 1 = substring supported

  • 2 = Oracle subset supported

  • 3 = all T-SQL supported

119

expression handling

  • 0 = unsupported

  • 1 = supported

  • 2 = full T-SQL supported

120

truncate trailing spaces on varchar parameters

  • 0 =no

  • 1 = yes

121

language events

  • 0 = no support for DML

  • 1 = DML support without datetime in where clause

  • 2 = no restrictions on DML

122

date functions

  • 0 = unsupported

  • 1 = all T-SQL supported

123

math functions

  • 0 = unsupported

  • 1 = Oracle subset supported

  • 2 = all T-SQL supported

124

T-SQL convert function

  • 0 = unsupported

  • 1 = supported

125

T-SQL delete/update

  • 0 = unsupported

  • 1 = T-SQL extensions supported

126

insert/update handling

  • 0 = unsupported

  • 1 = supported

127

subquery handling

  • 0 = unsupported

  • 1 = supported

128

in/not in clause

  • 0 = unsupported

  • 1 = supported

129

case expression in a SQL statement

  • 0 = unsupported

  • 1 = supported

sp_char_length (not supported)

Description

Determines the number of characters in the text data associated with the text pointer.

Syntax

sp_char_length table_qualifier,  table_owner, table_name, column_name, text_ptr,  ret_value

Parameters

This procedure does not allow parameters.

Usage

The number returned by this procedure may differ from that returned by sp_datalength if multibyte characters are in use.

sp_configure

Description

Provides a complete list of configuration names, minimum and maximum values, configured values, and current run values for each item.

Syntax

sp_configure

Parameters

This procedure does not allow parameters.

Usage

This procedure returns an empty result set since none of the configuration information is supported.

sp_datalength (not supported)

Description

Obtains the length of the text data, in bytes, referenced by the text pointer.

Syntax

sp_datalength table_qualifier, table_owner,  table_name, column_name, text_ptr, ret_value

Parameters

None

This procedure does not allow parameters.

Usage

The number returned by this procedure may differ from that returned by sp_char_length if multibyte characters are in use.

sp_groups

Description

Returns the current user name as the sole user group.

Syntax

sp_groups

Parameters

None

This procedure does not allow parameters.

Usage

This procedure was created for DirectConnect. It is not documented in any Adaptive Server or ODBC manuals.

Results

The following table shows the result set:

Result set for

Column

Datatype

Description

GROUP_NAME

char(8)

Group Name (Authorization ID)

sp_helpserver

Description

Returns the following information:

Syntax

sp_helpserver

Parameters

None

This procedure does not allow parameters.

Usage

not defined

sp_password (not supported)

Description

Changes or queries the current status of the user's password.

Syntax

sp_password your_password, new_password,[, login_name]

Parameters

your_password

is the password for the user of this procedure.

new_password

is the new password for the user. It must conform to the rules required on the DBMS in which the password change is to take effect.

login_name

is the login name of the user whose password is to be changed. Security is maintained by the DBMS, which should reject the request if the user is not logged in as the System Administrator.

Usage

sp_patindex

Description

The DirectConnect Anywhere Access Service does not support this procedure.

Finds the character position in a text column that contains the supplied pattern.

Syntax

sp_patindex table_qualifier, table_owner, table_name, column_name, text_ptr, ret_value

Parameters

None

This procedure does not allow parameters.

Usage

Not defined

sp_sqlgetinfo

Description

Provides information about SQL grammar, syntax, and capabilities that the target DBMS supports.

Syntax

sp_sqlgetinfo [attribute_name]

Parameters

attribute_name

is the name of a particular SQL option.

Usage

Results

Result set information is described in the following sections.

Format

The format is shown in the following table.

sp_sqlgetinfo format

sql_option

varchar(30)

not null

sql_value

varchar(255)

null

If the sql_value column is NULL, this option is not supported for the target DBMS.

Common Variables

The return string for some options includes embedded variable information. These variables have the same meaning for all access service DBMS targets. The stored procedure describes when and how to use the variables. Common variables embedded in a return string are prefixed with the "&" character.

Common variables are shown in the following table. The value returned for each option can vary depending upon the ODBC driver.

sp_sqlgetinfo common variables

Variable

Description

&QualifierName

Required in the SQL statement. Use "sp_sqlgetinfo SQL_Max_Qualifier_Name_Len" to determine the maximum length.

&LocationName

Used in the "SQL_CREATE_TABLE_SUFFIX" or "SQL_Alt_Create_Table_Suffix" sql_option return strings. A location name is required in the SQL statement at the location indicated.

Use "sp_sqlgetinfo SQL_Location_Name_Format" and "sp_sqlgetinfo SQL_Location_Name_Len" to determine the format and maximum length, respectively.

SQL options are shown in the following two tables. The first table lists DirectConnect options and SQL options A through L.

sp_sqlgetinfo SQL options (A through L)

SQL Options

Description

ICD_Cursor_Support

Bitmask indicating cursor support.

ICD_Dynamic_Support

Bitmask indicating dynamic statement support.

ICD_Execdirect

Bitmask indicating how dynamic execdirect statement is supported.

ICD_Language_Support

Bitmask indicating language statement support. No parameter marker support.

ICD_Longtypes_Supported

Support for long types as parameters.

ICD_Modify_Groupby

Intersolv driver insures GROUP BY clause when aggregate functions are used as part of the select list.

SQL_Accessible_Procedures

User can execute all procedures returned by sp_stored_procedures.

SQL_Accessible_Tables

User is guaranteed SELECT privileges to tables returned by sp_tables.

SQL_Active_Connections

No known limit to the number of connections.

SQL_Active_Statements

No known limit to the number of statements for a connection.

SQL_Alter_Table

Bitmask indicating which clauses in ALTER TABLE are supported.

SQL_Bookmark_Persistence

Bitmask enumerating through which bookmarks persist. None supported.

SQL_Column_Alias

Support for column alias.

SQL_Concat_Null_Behavior

Bitmask indicating how the DBMS handles concatenations with NULLS.

SQL_Convert_Bigint SQL_Convert_Binary SQL_Convert_Bit SQL_Convert_Char SQL_Convert_Date SQL_Convert_Decimal SQL_Convert_Double SQL_Convert_Float SQL_Convert_Integer SQL_Convert_Longvarbinary SQL_Convert_Longvarchar SQL_Convert_Numeric SQL_Convert_Real SQL_Convert_Smallint SQL_Convert_Time SQL_Convert_Timestamp SQL_Convert_Tinyint SQL_Convert_Varbinary SQL_Convert_Varchar

Bitmask indicating conversions "to type" supported.

SQL_Convert_Functions

Bitmask indicating conversion functions supported.

SQL_Correlation_Name

Table correlation names supported.

SQL_CSP_Support

Sybase/Intersolv extension for supporting CSPs. Value = 16383.

SQL_Cursor_Commit_Behavior

Bitmask indicating how a COMMIT operation affects a cursor.

SQL_Cursor_Rollback_Behavior

Bitmask indicating how a ROLLBACK operation affects a cursor.

SQL_Database_Name

Value provided by the DirectConnect Server.

SQL_Date_Source_Read_Only

The data source is read/write.

SQL_DBMS_Name

The target DBMS name. A maximum of 30 characters is returned.

SQL_DBMS_Ver

The target DBMS version in the form ##.##.####. A maximum of 30 characters is returned. The version string may have target-specific information that follows.

SQL_Default_TXN_Isolation

Bitmask indicating the default transaction level supported by the DBMS.

SQL_Expressions_In_Orderby

Support for expressions in ORDER BY clause.

SQL_Fetch_Direction

Bitmask enumerating supported options.

SQL_File_Usage

Files treated in data source.

SQL_Getdata_Extensions

Bitmask enumerating extensions to SQLGetData.

SQL_Group_By

Bitmask indicating the relationship between GROUP BY columns supported in the DBMS.

SQL_Identifier_Case

Defines whether identifiers are case-sensitive.

SQL_Identifier_Quote_Char

Character used to delimit quoted identifiers.

SQL_Keywords

See the Microsoft ODBC 3.5 Programmer's Reference and SDK Guide for information.

SQL_Like_Escape_Clause

Support of "%" character and "_" character as escape characters in LIKE clause.

SQL_Lock_Types

Bitmask enumerating supported lock types.

The second table lists SQL options M through Z.

sp_sqlgetinfo SQL options (M through Z)

SQL Option

Description

SQL_Max_Binary_Literal_Len

Maximum length of binary literal is either unknown or unlimited.

SQL_Max_Char_Literal_Len

Maximum length of character literal is either unknown or unlimited.

SQL_Max_Column_Name_Len

Maximum length for a column name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Columns_In_Group_By

Maximum number of columns allowed in a SQL GROUP BY clause. Convert this string to an integer. A value of 0 means that the limit is unknown or unlimited.

SQL_Max_Columns_In_Index

Maximum number of columns allowed in a SQL CREATE INDEX. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Columns_In_Order_By

Maximum number of columns allowed in a SQL ORDER BY clause. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Columns_In_Select

Maximum number of columns allowed in a SQL SELECT column list. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Columns_In_Table

Maximum number of columns allowed in a SQL CREATE TABLE. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Cursor_Name_Len

Maximum length for a cursor name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Index_Size

Maximum number of characters allowed in the combined column length of an index. Convert this string to an integer. A value of 0 indicates that the limit is unknown.

SQL_Max_Owner_Name_Len

Maximum length for an owner name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Procedure_Name_Len

Maximum length for a procedure name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Qualifier_Name_Len

Maximum length for a qualifier name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Row_Size

Maximum number of characters allowed in the combined column length of a row in a table. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Row_Size_Includes_Long

SQL_MAX_ROW_SIZE includes the length of all long datatypes.

SQL_Max_Statement_Len

Maximum length allowed for a SQL statement. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_Table_Name_Len

Maximum length allowed for a table name. Convert this string to an integer. A value of 0 means not supported.

SQL_Max_Tables_In_Select

Maximum number of columns allowed in a SQL SELECT FROM clause. Convert this string to an integer. A value of 0 means that the limit is unknown.

SQL_Max_User_Name_Len

Maximum length for the user name. Convert this string to an integer. A value of 0 means not supported.

SQL_Mult_Result_Sets

Driver does not support multiple result sets in a given language event.

SQL_Multiple_Active_TXN

Only one connection can have an active transaction.

SQL_Need_Long_Data_Len

Need the length of the long datatypes.

SQL_Non_Nullable_Columns

Bitmask indicating whether the DBMS supports non-nullable columns.

SQL_Null_Collation

Bitmask indicating how the DBMS collates NULL values.

SQL_Numeric_Functions

Bitmask indicating the supported scalar numeric functions.

SQL_ODBC_API_Conformance

Bitmask enumerating ODBC level.

SQL_ODBC_SAG_CLI_Conformance

Bitmask enumerating compliance to functions of the SAG specification.

SQL_ODBC_SQL_Conformance

Bitmask indicating supported SQL grammar.

SQL_ODBC_SQL_Opt_IEF

Support for Integrity Enhancement Facility

SQL_Order_By_Columns_In_Select

Columns in ORDER BY clause must be in select list.

SQL_Outer_Joins

Support for outer joins.

SQL_Owner_Term

The DBMS term for an owner name. A maximum of 30 characters is returned. A null value means not supported.

SQL_Owner_Usage

Bitmask indicating statements in which owners can be used.

SQL_Pos_Operations

Bitmask enumerating the operations in SQLSetPos.

SQL_Positioned_Statements

Bitmask indicating supported positioned SQL statements.

SQL_Procedure_Term

DBMS term for a procedure name. A maximum of 30 characters is returned. A null value means not supported.

SQL_Procedures

Support for procedures.

SQL_Qualifier_Location

Bitmask indicating the position of the qualifier in a qualified table name.

SQL_Qualifier_Name_Separator

Character or string separator between the qualifier and the name element. A maximum of five characters is returned.

SQL_Qualifier_Term

DBMS term for a qualifier name. A maximum of 30 characters is returned.

SQL_Qualifier_Usage

Bitmask indicating in which statements a qualifier can be used.

SQL_Quoted_Identifier_Case

Bitmask describing SQL identifier case and storage in system tables when used in SQL statements.

SQL_Row_Updates

See the Microsoft ODBC 3.5 Programmer's Reference and SDK Guide for information.

SQL_Scroll_Concurrency

Bitmask identifying concurrency control options for scrollable cursors.

SQL_Scroll_Options

Bitmask indicating scroll options for scrollable cursors.

SQL_Search_Pattern_Escape

See the Microsoft ODBC 3.5Programmer's Reference and SDK Guide for information.

SQL_Set_Database_Context

Sybase/Intersolv extension for supporting CSPs. If value = Y, the driver issues use_database_name to the configured database name and is sensitive to three-part names.

SQL_Special_Characters

Special characters used in object names. All characters except a-z, A-Z, 0-9, and the underscore character.

SQL_String_Functions

Bitmask indicating supported scalar string functions.

SQL_Subqueries

Bitmask indicating predicates that support subqueries.

SQL_System_Functions

Bitmask indicating supported scalar system functions.

SQL_Table_Term

DBMS term for a table name. A maximum of 30 characters is returned.

SQL_TimeDate_Add_Intervals

Bitmask indicating supported timestamp intervals associated with TIMESTAMPADD function.

SQL_TimeDate_Diff_Intervals

Bitmask indicating supported timestamp intervals associated with TIMESTAMPDIFF function.

SQL_TimeDate_Functions

Bitmask indicating supported timestamp intervals.

SQL_TXN_Capable

Indicates the transaction support in the DBMS.

SQL_TXN_Isolation_Option

Bitmask indicating transaction isolation levels.

SQL_Union

Bitmask indicating support for UNION clause.

SQL_User_Name

Current user name. A maximum of SQL_Max_User_Name_Len characters are returned. A null value means not supported.

sp_textvalid

Description

Determines whether a given text pointer is valid.

The DirectConnect Anywhere Access Service does not support this procedure.

Syntax

sp_textvalid table_qualifier, table_owner,  table_name, column_name, text_ptr, ret_value

Parameters

None

This procedure does not allow parameters.

Usage

not defined

sp_thread_props

Description

Enables the client to retrieve and set various thread properties.

Syntax

sp_thread_props [ property_name [, property_value ]]

Parameters

property_name

is the name of the property to be set or shown.

property_value

is the value to which the property is to be set.

Usage

If you do not provide any parameters, or if you provide only property_name, the access service returns a single result set consisting of every instance of property_name and the value for each.

sp_who (not supported)

Description

Returns information about all current on-line users and processes, or about a particular user or process.

The DirectConnect for Anywhere Access Service does not support this procedure.

sp_who returns the following information:

Syntax

sp_who [ username | "spid "]

Parameters

None

This procedure does not allow parameters.

Examples

Example 1

Usage

Not defined


Chapter 12 Accessing

Catalog Information with CSPs [Table of Contents] Chapter 14 Using SQL

Stored Procedures