PostgreSQL to Pervasive SQL Conversion Guide

This guide explains how to convert PostgreSQL queries and functions to Pervasive SQL syntax with examples and workarounds for unsupported functions.

1. Simulating RIGHT

-- PostgreSQL
RIGHT('foobar', 3); -- Result: "bar"

-- Pervasive SQL Equivalent
SELECT SUBSTRING('foobar', CHAR_LENGTH('foobar') - 3 + 1, 3); -- Result: "bar"
        
2. Simulating LEFT

-- PostgreSQL
LEFT('foobar', 3); -- Result: "foo"

-- Pervasive SQL Equivalent
SELECT SUBSTRING('foobar', 1, 3); -- Result: "foo"
        
3. Simulating RPAD

-- PostgreSQL
RPAD('foo', 5, ' ') -- Result: "foo  "

-- Pervasive SQL Equivalent
SELECT 'foo' + SPACE(5 - CHAR_LENGTH('foo')); -- Result: "foo  "
        
4. Simulating LPAD

-- PostgreSQL
LPAD('foo', 5, ' ') -- Result: "  foo"

-- Pervasive SQL Equivalent
SELECT SPACE(5 - CHAR_LENGTH('foo')) + 'foo'; -- Result: "  foo"
        
5. Simulating TRIM

-- PostgreSQL
TRIM('  foo  ') -- Result: "foo"

-- Pervasive SQL Equivalent
SELECT RTRIM(LTRIM('  foo  ')); -- Result: "foo"
        
6. Simulating Concatenation

-- PostgreSQL
SELECT 'foo' || 'bar'; -- Result: "foobar"

-- Pervasive SQL Equivalent
SELECT 'foo' || 'bar'; -- Result: "foobar"