SQLines tools help you transfer data, convert database schema (DDL), views, stored procedures, functions, triggers, queries and SQL scripts from SAP Sybase Adaptive Server Enterprise (Sybase ASE) to PostgreSQL.
Databases:
SQLines tools to help you migrate from Sybase ASE to PostgreSQL:
Technical information on migration from Sybase ASE to PostgreSQL:
Converting SQL language elements:
Sybase ASE | PostgreSQL | |||
1 | string1 + string2 | String concatenation | string1 || string2 |
Converting data types:
Converting built-in SQL functions from Sybase ASE to PostgreSQL:
Sybase ASE | PostgreSQL | ||
1 | CHAR_LENGTH(string) | Number of characters in string | CHAR_LENGTH(string) |
2 | CHARINDEX(substring, string) | Get substring position in string | POSITION(substring IN string) |
3 | CONVERT(CHAR | VARCHAR, exp) | Convert to string | TO_CHAR(exp) |
4 | DATEADD(dd, int, datetime) | Add days to datetime | datetime + INTERVAL 'int DAY' |
DATEADD(dd, exp, datetime) | datetime + exp * INTERVAL '1 DAY' | ||
5 | GETDATE() | Get the current date and time | NOW() |
6 | SUBSTRING(string, start, length) | Return substring | SUBSTRING(string, start, length) |
Converting stored procedures from Sybase ASE to PostgreSQL:
Sybase ASE | PostgreSQL | ||
1 | CREATE PROCEDURE name | CREATE OR REPLACE FUNCTION name | |
2 | If RETURN is not specified | RETURNS VOID is added | |
3 | AS | Changed AS $$ | |
4 | Declarations inside BEGIN block | DECLARE block is between AS and BEGIN clauses | |
5 | END | End of procedure block | END; $$ LANGUAGE plpgsql; |
Converting procedural Transact-SQL statements used in stored procedures, functions and triggers from Sybase ASE to PostgreSQL:
Variable declaration and assignment:
Sybase ASE | PostgreSQL | ||
1 | DECLARE @var [AS] datatype(len) [= default] | Variable declaration | var datatype(len) [:= default]; |
Flow-of-control statements:
Sybase ASE | PostgreSQL | ||
1 | IF condition BEGIN … END | IF statement | IF condition THEN … END IF; |
2 | WHILE condition BEGIN … END | WHILE loop | WHILE condition LOOP … END LOOP; |
Cursors operations and attributes:
Sybase ASE | PostgreSQL | ||
1 | CLOSE cur DEALLOCATE [CURSOR] cur | Close a cursor | CLOSE cur; |
2 | @@SQLSTATUS = 0 | Fetch was successful | FOUND |
Converting system stored procedures from Sybase ASE to PostgreSQL:
Sybase ASE | PostgreSQL | ||
1 | sp_addtype name, "basetype(len)", "not null" | Create a user-defined type | CREATE DOMAIN name AS basetype(len) NOT NULL |
2 | sp_bindrule name, "table.column" | Assign a rule to a table column | ALTER TABLE table ADD CHECK rule_condition |
Converting SQL statements from Sybase ASE to PostgreSQL:
Sybase ASE | PostgreSQL | ||
1 | CREATE RULE name AS condition | Create a domain of acceptable values | Converted to a CHECK constraint |