¿Cómo escribir procedimientos almacenados en postgresql? ¿Cómo escribir un procedimiento almacenado en postgresql?
CREAR O REEMPLAZAR FUNCIÓN test()
DEVUELVE int4 AS
$BODY$
declarar
r RECORD;
num int4 := 0;
sql "varchar " := 'seleccione f_data_type del grupo t_water_arguments por f_data_type teniendo recuento(*) >= 2 límite 1';
begin
FOR r IN EJECUTAR BUCLE sql
num = r.f_data_type;
finalizar BUCLE;
retornar num;
end
$BODY$
IDIOMA 'plpgsql' VOLÁTIL;
seleccione prueba();
seleccione prueba().
http://bianbian.org/technology/52.html
Hay más detalles aquí