CREATE OR REPLACE FUNCTION self_destroy() RETURNS void AS
$BODY$
BEGIN
DROP TABLE IF EXISTS mslxp_self_destroy;
CREATE TEMP TABLE mslxp_self_destroy
(
dt1 timestamp without time zone,
dt2 timestamp(0) without time zone
);
INSERT INTO mslxp_self_destroy(dt1, dt2) VALUES (clock_timestamp(), clock_timestamp());
DROP FUNCTION self_destroy();
END;
$BODY$
LANGUAGE plpgsql;
SELECT self_destroy();
SELECT * FROM self_destroy;
Resultado:
2012-05-18 11:10:03.414 | 2012-05-18 11:10:03
Mostrando postagens com marcador Function. Mostrar todas as postagens
Mostrando postagens com marcador Function. Mostrar todas as postagens
sexta-feira, 18 de maio de 2012
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';
$BODY$
BEGIN
IF cond THEN
RETURN iftrue;
ELSE
RETURN ifelse;
END IF;
END;
$BODY$ LANGUAGE 'plpgsql';
Assinar:
Postagens (Atom)