SnowConvert AI - Sybase IQ - SELECT¶
Description¶
Retrieves information from the database. (Sybase SQL Language Reference (https://help.sap.com/docs/SAP_IQ/a899599784f21015a466ed42e24d07f9/a624e72e84f210159276a39335acd358.html?version=16.0.11&locale=en-US))
Warning
This syntax is partially supported in Snowflake.
Grammar Syntax¶
Sample Source Patterns¶
Row Limitation¶
Sybase allows row limitation in a query by using the TOP clause with an optional START AT. Snowflake does not support this syntax but it can be transformed as shown below to achieve the same functionality.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
Window-function ORDER BY NULL Ordering¶
Sybase treats NULL as the smallest value, so ORDER BY x ASC sorts NULLs first and ORDER BY x DESC sorts NULLs last. Snowflake’s default treats NULL as the largest value, which silently inverts the position of NULLs and changes window-function ranks/values for any partition that contains NULLs in the order key.
To preserve Sybase semantics, SnowConvert AI emits an explicit NULLS FIRST or NULLS LAST clause on every ORDER BY item inside an OVER (...) window-function clause that does not already carry one: ASC (or no direction) becomes NULLS FIRST; DESC becomes NULLS LAST. The rewrite is idempotent — items that already specify a NULLS … clause are preserved verbatim, including caller overrides such as ORDER BY x ASC NULLS LAST.
Statement-level ORDER BY (outside OVER) and WITHIN GROUP (ORDER BY ...) carry the same divergence but are intentionally not rewritten; add an explicit NULLS … clause manually or set the session parameter DEFAULT_NULL_ORDERING if the result depends on NULL position.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
Non-Standard Comparison Operators (!>, !<)¶
Sybase supports two non-standard comparison operators that Snowflake does not accept:
| Sybase | Meaning | Snowflake equivalent |
|---|---|---|
!> | not greater than | <= |
!< | not less than | >= |
Leaving these operators untranslated produces invalid Snowflake SQL that fails at compile time (SQL compilation error: unexpected '>'). SnowConvert AI rewrites them to their standard equivalents. The translation is exact for every operand combination — including NULLs — because NULL !> x and NULL <= x both evaluate to UNKNOWN, matching Sybase semantics. Both the compact form (!>, !<) and the legacy spaced form (! >, ! <) are rewritten; user-written IS NOT NULL guards or any other surrounding predicates are preserved verbatim.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
Into Clause¶
In Sybase, a table can be defined by selecting multiple rows and defining a name to store the data retrieved. Snowflake does not support this behavior but can be emulated by doing a CREATE TABLE AS.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
Force Index¶
Snowflake does not contain indexes for query optimization.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
TABLE FUNCTIONS¶
Snowflake allows calling a stored procedure(when the procedure meets certain limitations) or a table value function in a FROM clause, but RESULTSETS and windowing cannot be used as parameters.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
OPEN STRING¶
Snowflake does not support OPENSTRING (https://help.sap.com/docs/SAP_IQ/a898e08b84f21015969fa437e89860c8/a7749cf084f21015b73b899c1520fb06.html#parameters) functionality.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
DML Derived Table¶
In Sybase, during execution, the DML statement specified in the dml-derived table is executed first, and the rows affected by that DML materialize into a temporary table whose columns are described by the REFERENCING clause. The temporary table represents the result set of dml-derived-table. Snowflake does not support this behavior.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
KEY JOIN¶
Snowflake does not support KEY join but when the ON CLAUSE is defined in the query the KEY keyword is removed; otherwise, an EWI is inserted.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
OUTER-CROSS APPLY¶
Snowflake transforms the clause the CROSS APPLY into LEFT OUTER JOIN and OUTER APPLY to INNER JOIN.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
CONTAINS Clause¶
In Sybase the CONTAINS (https://help.sap.com/docs/SAP_IQ/a898e08b84f21015969fa437e89860c8/a7749cf084f21015b73b899c1520fb06.html) clause following a table name to filter the table and return only those rows matching the full text query specified with contains-query. Every matching row of the table is returned together with a score column that can be referred to using score-correlation-name. Snowflake does not support this behavior.
Input Code:¶
Sybase¶
Output Code:¶
Snowflake¶
Related EWIs¶
SSC-FDM-0009: GLOBAL TEMPORARY TABLE FUNCTIONALITY NOT SUPPORTED.
SSC-FDM-SY0001: CALLING STORED PROCEDURE IN FROM CLAUSE MIGHT HAVE COMPILATION ERRORS
SSC-FDM-SY0002: FORCE INDEX IS NOT SUPPORTED IN SNOWFLAKE
SSC-EWI-SY0004 - UNSUPPORTED SYNTAX TABLE FUNCTION CAN’T RECEIVE A QUERY AS PARAMETER
SSC-EWI-SY0005 - UNSUPPORTED SYNTAX TABLE FUNCTION CAN’T BE USED WITH OVER EXPRESSION
SSC-EWI-SY0006 - OPEN STRING IS NOT SUPPORTED IN SNOWFLAKE
SSC-EWI-SY0007 - DML DERIVED TABLE NOT SUPPORTED IN SNOWFLAKE
SSC-EWI-SY0008 - CONTAINS CLAUSE NOT SUPPORTED IN SNOWFLAKE
SSC-EWI-SY0009 - KEY JOIN NOT SUPPORTED IN SNOWFLAKE