CREATEFUNCTIONgetfoo(int)RETURNSsetofintAS'SELECT fooid FROM foo WHERE fooid = $1;'LANGUAGESQL;
SELECT*FROMgetfoo(1)ASt1;
DROPVIEWvw_getfoo;
CREATEVIEWvw_getfooASSELECT*FROMgetfoo(1);
SELECT*FROMvw_getfoo;
-- sql, proretset = t, prorettype = b
DROPFUNCTIONgetfoo(int);
CREATEFUNCTIONgetfoo(int)RETURNSsetoftextAS'SELECT fooname FROM foo WHERE fooid = $1;'LANGUAGESQL;
SELECT*FROMgetfoo(1)ASt1;
DROPVIEWvw_getfoo;
CREATEVIEWvw_getfooASSELECT*FROMgetfoo(1);
SELECT*FROMvw_getfoo;
-- sql, proretset = f, prorettype = c
DROPFUNCTIONgetfoo(int);
CREATEFUNCTIONgetfoo(int)RETURNSfooAS'SELECT * FROM foo WHERE fooid = $1;'LANGUAGESQL;
SELECT*FROMgetfoo(1)ASt1;
DROPVIEWvw_getfoo;
CREATEVIEWvw_getfooASSELECT*FROMgetfoo(1);
SELECT*FROMvw_getfoo;
-- sql, proretset = t, prorettype = c
DROPFUNCTIONgetfoo(int);
CREATEFUNCTIONgetfoo(int)RETURNSsetoffooAS'SELECT * FROM foo WHERE fooid = $1;'LANGUAGESQL;
SELECT*FROMgetfoo(1)ASt1;
DROPVIEWvw_getfoo;
CREATEVIEWvw_getfooASSELECT*FROMgetfoo(1);
SELECT*FROMvw_getfoo;
-- plpgsql, proretset = f, prorettype = b
DROPFUNCTIONgetfoo(int);
CREATEFUNCTIONgetfoo(int)RETURNSintAS'DECLARE fooint int; BEGIN SELECT fooid into fooint FROM foo WHERE fooid = $1; RETURN fooint; END;'LANGUAGE'plpgsql';
SELECT*FROMgetfoo(1)ASt1;
DROPVIEWvw_getfoo;
CREATEVIEWvw_getfooASSELECT*FROMgetfoo(1);
SELECT*FROMvw_getfoo;
-- plpgsql, proretset = f, prorettype = c
DROPFUNCTIONgetfoo(int);
CREATEFUNCTIONgetfoo(int)RETURNSfooAS'DECLARE footup foo%ROWTYPE; BEGIN SELECT * into footup FROM foo WHERE fooid = $1; RETURN footup; END;'LANGUAGE'plpgsql';