Re: passing values to a function
От | Jan Wieck |
---|---|
Тема | Re: passing values to a function |
Дата | |
Msg-id | 200102191932.OAA01894@jupiter.jw.home обсуждение исходный текст |
Ответ на | passing values to a function (Cedar Cox <cedarc@visionforisrael.com>) |
Ответы |
Re: passing values to a function
|
Список | pgsql-interfaces |
Cedar Cox wrote: > > Why does this not work? Am I doing something wrong? > > CREATE FUNCTION uutest(text) RETURNS bool AS ' > declare > varop alias for $1; > begin > raise notice '' varop is '',varop; raise notice '' varop is %'', varop; > return false; > end; > ' LANGUAGE 'plpgsql'; > [...] > > One other question.. Is there an easy way to pass an entire record to a > function (eg, the 'new' record)? Presently I am passing all 12 fields as > separate parameters. Yes and no. Yes, PL/pgSQL functions can receive tuples as arguments. The only oddity is that they *must* get aliased for access of attributes. Your function would look like: CREATE FUNCTION myfunc (mytable) RETURNS text AS ' DECLARE row ALIAS FOR %1; BEGIN return row.key || '' equals '' row.value; END;' LANGUAGE 'plpgsql'; But unfortunately (and there's no really good reason why) no, a PL/pgSQL function having some row somehow cannot call another function handing that row over as a tuple argument. Something to work on for 7.2. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
В списке pgsql-interfaces по дате отправления: