Re: Out parameters handling
От | Dimitri Fontaine |
---|---|
Тема | Re: Out parameters handling |
Дата | |
Msg-id | 04CCAC7D-AE82-4FD0-BDD0-6CBC07CA1C31@hi-media.com обсуждение исходный текст |
Ответ на | Re: Out parameters handling (Josh Berkus <josh@agliodbs.com>) |
Ответы |
Re: Out parameters handling
Re: Out parameters handling |
Список | pgsql-hackers |
Hi, Le 7 mars 09 à 02:44, Josh Berkus a écrit : > Thing is, anybody can institute their own naming convention. I've > long used v_ as a prefix. Allowing : would save me some keystrokes, > but that's about it. What I usually do in those cases is abusing the ALIAS option of DECLARE (because as mentioned somewhere else in this thread, you generally don't want to have that ugly OUT parameters, you want a nice API) : CREATE OR REPLACE FUNCTION test_out ( IN a integer, IN b integer, OUT s integer ) RETURNS setof integer LANGUAGE PLPGSQL AS $f$ DECLARE v_s ALIAS FOR $3; BEGIN FOR v_s IN SELECT generate_series(a, b) LOOP v_s := v_s * v_s; RETURN NEXT; END LOOP; RETURN; END; $f$; CREATE FUNCTION dim=# SELECT * FROM test_out(2, 4); s ---- 4 9 16 (3 rows) I'd sure be happy not having to do it explicitly, but schema-style prefixing has the drawback of needing to avoid any user defined schema. Maybe pg_plout would do? Regards, -- dim
В списке pgsql-hackers по дате отправления: