25 lut 2010

Użycie funkcji regexp_replace

select mapa_pl, regexp_replace(mapa_pl, '!([a-z_]+)!', E'<xsl:value-of select="\\1"/>', 'g') as test from mapy.mapa where mapa_pl like '%!%'

update mapy.mapa set mapa_pl = regexp_replace(mapa_pl, '!([a-z_]+)!', E'<xsl:value-of select="\\1"/>', 'g') where mapa_pl like '%!%'

zamiana
mapa!id!
na
mapa<xsl:value-of select="id"/>

19 lut 2010

Przykład wykorzystania funkcji COALESCE

SELECT
  COALESCE(
    'abc',
    'def',
    'brak);
SELECT COALESCE(null, ' def ', ' brak ');
SELECT COALESCE(null, null, ' brak ');

Wynki:
abc
def
brak

Funkcja zwraca pierwszy argumenty, który nie jest null.