Table expression in RETURN statement for SRF functions

Z PostgreSQL
Přejít na: navigace, hledání
CREATE OR REPLACE FUNCTION te(OUT a int, OUT b int)                                                             
RETURNS SETOF RECORD AS                                                                                         
$$                                                                                                              
  RETURN                                                                                                        
    VALUES(12, 13), (16, 17);                                                                                   
$$ 
LANGUAGE plpgpsm;                                                                                            
                                          
                                                                                                                
CREATE OR REPLACE FUNCTION te(OUT a int, OUT b int)                                                             
RETURNS SETOF RECORD AS                                                                                         
$$                                                                                                              
  VALUES(19, 20), (21, 22);                                                                                     
$$ 
LANGUAGE plpgpsm;                                                                                                                                                                       
                                                                                                                
CREATE OR REPLACE FUNCTION te(OUT a int, OUT b int)                                                             
RETURNS SETOF RECORD AS                                                                                         
$$                                                                                                              
  INSERT INTO Foo                                                                                               
    SELECT *                                                                                                    
       FROM Foo                                                                                                 
      WHERE Foo.a < 20                                                                                          
      RETURNING *;                                                                                              
$$
LANGUAGE plpgpsm;