About the Easysoft ODBC-Sybase Driver
The Easysoft ODBC-Sybase Driver provides real-time access to Sybase data from any application that supports ODBC.
ODBC API and scalar functions
API functions
Use this table to find out what ODBC API functions the Easysoft ODBC-Sybase Driver supports:
Function | Status |
---|---|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Not supported |
|
Not supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Not supported |
|
Supported |
|
Supported |
|
Not supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
|
Supported |
Scalar functions
The Easysoft ODBC-Sybase Driver supports a number of scalar functions:
Use either the SQL-92 or ODBC syntax with scalar functions. For example:
SELECT
Invoice_Id,
Customer_Name,
EXTRACT(YEAR FROM Due_Date) as "Year"
FROM
Invoice
SELECT
Invoice_Id,
Customer_Name,
{fn EXTRACT(YEAR FROM Due_Date)} as "Year"
FROM
Invoice
String functions
The Easysoft ODBC-Sybase Driver supports these string functions:
-
ASCII(string_exp)
-
CHAR(code)
-
CHAR_LENGTH(string_exp)
-
DIFFERENCE(string_exp1, string_exp2)
-
LTRIM(string_exp)
-
RIGHT(string_exp, count)
-
RTRIM(string_exp)
-
SOUNDEX(string_exp)
-
SPACE(count)
-
SUBSTRING(string_exp, start, length)
Numeric functions
The Easysoft ODBC-Sybase Driver supports these numeric functions:
-
ABS(numeric_exp)
-
ACOS(float_exp)
-
ASIN(float_exp)
-
ATAN(float_exp)
-
CEILING(numeric_exp)
-
COS(float_exp)
-
COT(float_exp)
-
DEGREES(numeric_exp)
-
EXP(float_exp)
-
FLOOR(numeric_exp)
-
LOG(float_exp)
-
LOG10(float_exp)
-
PI()
-
POWER(numeric_exp, integer_exp)
-
RADIANS(numeric_exp)
-
RAND([integer_exp])
-
ROUND(numeric_exp, integer_exp)
-
SIGN(numeric_exp)
-
SIN(float_exp)
-
SQRT(float_exp)
-
TAN(float_exp)
-
TRUNCATE(numeric_exp, integer_exp)
Time, date, and interval functions
The Easysoft ODBC-Sybase Driver supports these time, date, and interval functions:
-
CURRENT_DATE()
-
CURRENT_TIME[(time-precision)]
-
CURRENT_TIMESTAMP[(timestamp-precision)]
-
CURDATE()
-
CURTIME()
-
DAYNAME(date_exp)
-
EXTRACT(extract-field FROM extract-sourc)
-
HOUR(time_exp)
-
MINUTE(time_exp)
-
MONTH(date_exp)
-
MONTHNAME(date_exp)
-
QUARTER(date_exp)
-
SECOND(time_exp)
-
WEEK(date_exp)
-
YEAR(date_exp)
System functions
The Easysoft ODBC-Sybase Driver supports these system functions:
-
IFNULL(exp, value)
-
USER()
Conversion functions
The Easysoft ODBC-Sybase Driver supports supports both the SQL-92 CAST function and the ODBC CONVERT function for conversion between compatible data types.
Data type mapping
The Easysoft ODBC-Sybase Driver maps Sybase data types to ODBC data types in this way:
URI
Sybase data type | ODBC data type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL support
The Easysoft ODBC-Sybase Driver supports these SQL statements, clauses, and operators:
-
SELECT
-
SELECT DISTINCT
-
WHERE
-
ORDER BY
-
AND
-
OR
-
NOT
-
INSERT INTO
-
NULL
-
UPDATE
-
DELETE
-
TOP
-
MIN
-
MAX
-
COUNT
-
SUM
-
AVG
-
LIKE
-
WILDCARDS
-
IN
-
BETWEEN
-
ALIASES
-
JOINS
-
UNION
-
GROUP BY
-
HAVING
-
EXISTS
-
CASE
Example queries
-
To fetch all records from a table, use the asterisk symbol (
*
) in your queries. For example:SELECT * FROM Customers
-
To only fetch records whose values are different, use
DISTINCT
. For example:-- Which different sales regions are there? SELECT DISTINCT Region AS Different_Regions FROM SalesOrders -- How many different sales regions are there? SELECT COUNT(DISTINCT Region) AS Different_Regions FROM SalesOrders
-
To filter records, use
WHERE
. For example:SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region = 'Eastern' SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region = 'Eastern' OR Region = 'Western' SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region = 'Eastern' AND {fn YEAR(OrderDate)} = 2024
You can also supply a
WHERE
clause value as a parameter. For example, to do this in Python:cursor.execute("SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region = ?", ['Eastern'])
-
To fetch records that don’t match the
WHERE
clause pattern useNOT
. For example:SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE NOT Region = 'Eastern'
-
To sort the result set in either ascending or descending order, use
ORDER BY
. For example:SELECT * FROM SalesOrders ORDER BY OrderDate ASC SELECT * FROM Contacts ORDER BY ( CASE WHEN Surname IS NULL THEN Title ELSE Surname END );
-
To group a result set into summary rows, use
GROUP BY
. For example:SELECT COUNT(Id) As "Number", ProductID FROM SalesOrderItems GROUP BY ProductID SELECT COUNT(Id) As "Number", ProductID FROM SalesOrderItems GROUP BY ProductID HAVING COUNT(Id) > 100;
-
To do calculations based on result set vales, use the SQL aggregate functions
MIN()
,MAX()
,COUNT()
,SUM()
, andAVG()
. For example:SELECT Max(Quantity) FROM SalesOrderItems SELECT Sum(Quantity) FROM SalesOrderItems
In addition, you can use these scalar funtions.
-
To convert between compatible data types, use
CAST
orCONVERT
. For example:SELECT CAST(Quantity AS Char(100))FROM SalesOrderItems SELECT {fn CONVERT(Quantity, SQL_CHAR)} FROM SalesOrderItems
-
To fetch records that contain column values between a given range, use
BETWEEN
For example:SELECT ProductID FROM SalesOrderItems WHERE Quantity BETWEEN 10 AND 20
-
To combine the result set of two or more
SELECT
statements, useUNION
. For example:SELECT City FROM Contacts UNION SELECT City FROM Customers ORDER BY City;
-
To combine rows from two or more tables, use
JOIN
. For example:SELECT SalesOrders.ID, Customers.Surname, SalesOrders.OrderDate FROM SalesOrders INNER JOIN Customers ON SalesOrders.CustomerID=Customers.ID;
-
To fetch records that contain column values matching a search pattern, use
LIKE
. For example:SELECT Surname, GivenName FROM Customers WHERE CompanyName LIKE 'R%' SELECT Surname, GivenName FROM Customers WHERE CompanyName LIKE '_he'
-
To search for columns without a value (
NULL
) or with a value (nonNULL
), use eitherIS NULL
orIS NOT NULL
. For example:SELECT * FROM Customers WHERE CompanyName IS NULL
-
To specify multiple values in a
WHERE
clause, you can useIN
as an alternative toOR
. For example:SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region = 'Eastern' OR Region = 'Western' OR Region = 'Central'
can be replaced with:
SELECT OrderDate, SalesRepresentative FROM SalesOrders WHERE Region IN ('Eastern', 'Western', 'Central')
-
To set the maximum number of records to return, use
TOP
. For example:SELECT TOP 10 * FROM Customers
-
To test for the existence of records in a subquery, use
EXISTS
. For example:SELECT Name FROM Products WHERE EXISTS ( SELECT * FROM SalesOrderItems WHERE Products.ID = SalesOrderItems.ProductID AND Quantity < 20 )
Example inserts, updates, and deletes
-
To insert a Sybase record, use
INSERT INTO
. For example:INSERT INTO Customers ( Surname, GivenName, City, State, Country ) VALUES ( 'Devlin', 'Michaels', 'Kingston', 'NJ', 'USA' )
-
Here’s an Oracle linked table example:
DECLARE num_rows integer; BEGIN num_rows:=DBMS_HS_PASSTHROUGH.EXECUTE_IMMEDIATE@SybaseLink ('INSERT INTO Customers (Surname, GivenName, City, State, Country) VALUES (''Devlin'', ''Michaels'', ''Kingston'', ''NJ'', ''USA'')'); END; /
-
The Easysoft ODBC-Sybase Driver also supports parameterized inserts. Here’s an example of doing this in Perl:
my $sth = $dbh->prepare(q/INSERT INTO Customers (Surname, GivenName, City, State, Country) VALUES (?, ?, ?, ?, ?)/) or die "Can't prepare statement: $DBI::errstr"; $sth->execute('Devlin', 'Michaels', 'Kingston', 'NJ', 'USA');
-
To update a Sybase record, use
UPDATE
. For example:UPDATE Customers SET Surname = 'Jones' WHERE Account_Id = '667'
The Easysoft ODBC-Sybase Driver also supports parameterized updates. Here’s an example of doing this in Perl:
my $sth = $dbh->prepare('UPDATE Customers SET Surname = \'Jones\' WHERE ID = ?') or die "Can't prepare statement: $DBI::errstr"; $sth->execute('667');
-
To delete a Sybase record, use
DELETE
. For example:-- Delete (mark inactive) a bank account DELETE FROM Customers WHERE ID = '667'
The Easysoft ODBC-Sybase Driver also supports parameterized deletes. Here’s an example of doing this in Python:
sql = "DELETE FROM Customers WHERE ID = ?" cursor.execute(sql, '667')