STRING Function - Sybase SQL Anywhere to Oracle Migration

STRING function concatenates one or more strings into a single string.

Quick Example:

   -- Concatenate strings AB and CD
   SELECT STRING('AB', 'CD');
   -- Result: ABCD

For more information, see STRING Function in Sybase SQL Anywhere (Sybase ASA).

Conversion to Oracle

Conversion summary:

Sybase SQL Anywhere Oracle
Syntax STRING(string1, …) CONCAT(string1, string2) string1 || string2 || …
Variable Parameter List 2 parameters only
NULL Is Empty String
Implicit Parameter Conversion

Last Update: Sybase SQL Anywhere 12.0 and Oracle 11g

Conversion Examples

Examples of STRING conversion from Sybase SQL Anywhere to Oracle:

STRING with 2 Parameters

Oracle CONCAT function can concatenate 2 strings only:

Oracle:

  SELECT CONCAT('A', 'B', 'C') FROM dual;
  -- ERROR at line 1:
  -- ORA-00909: invalid number of arguments

So STRING function with only 2 parameters can be converted to CONCAT in Oracle:

Sybase SQL Anywhere:

   SELECT STRING('New ', 'York');
   -- Result: New York
 
   SELECT STRING(1, 3);
   -- Result: 13
 
   SELECT STRING('New', NULL);
   -- Result: New

Oracle:

   SELECT CONCAT('New ', 'York') FROM dual;
   -- Result: New York
 
   SELECT CONCAT(1, 3)  FROM dual;
   -- Result: 13
 
   SELECT CONCAT('New', NULL)  FROM dual;
   -- Result: New

Convert Online

STRING with More than 2 Parameters

STRING with more than 2 parameters has to be converted to concatenation using || operator in Oracle:

Sybase SQL Anywhere:

   SELECT STRING('New ', 'York ', 'City');
   -- Result: New York City
 
   SELECT STRING(1, 3, 7);
   -- Result: 137
 
   SELECT STRING('New ', NULL, 'City');
   -- Result: New City

Oracle:

   SELECT 'New ' || 'York ' || 'City' FROM dual;
   -- Result: New York City
 
   SELECT 1 || 3 || 7 FROM dual;
   -- Result: 137
 
   SELECT 'New ' || NULL || 'City' FROM dual;
   -- Result: New City

Convert Online

Resources