sexta-feira, 11 de novembro de 2011

PostgreSQL - Função para usar printf em pgsql


http://wiki.postgresql.org/wiki/Sprintf

# select printf('% is a % and % is a %, but %% is a %', '{hello,word,1,number,percent sign}');
                      printf
------------------------------------------------------------
hello is a word and 1 is a number, but % is a percent sign
(1 fila)

terça-feira, 1 de novembro de 2011

IfThen do Delphi no PostgreSql

CREATE OR REPLACE FUNCTION public.ifthen(cond boolean, iftrue varchar, ifelse varchar) RETURNS varchar AS
$BODY$
BEGIN
    IF cond THEN
        RETURN iftrue;
    ELSE
        RETURN ifelse;
    END IF;
END;
$BODY$ LANGUAGE 'plpgsql';