SQL statements in SQL/PSM samples

Z PostgreSQL
Přejít na: navigace, hledání

SQL support

CREATE OR REPLACE FUNCTION fx(OUT a int)  AS
$$
  SELECT INTO a sum(y)
    FROM foo;
$$ LANGUAGE plpgpsm;

CREATE OR REPLACE FUNCTION fx() 
RETURNS int AS 
$$ 
  BEGIN
    DECLARE i int DEFAULT 0; 
    WHILE i < 10 
    DO 
      INSERT INTO foo VALUES(i, i+1); 
      SET i = i + 1; 
    END WHILE; 
    RETURN i; 
  END; 
$$ LANGUAGE plpgpsm;