Re: Composite Types and Function Parameters

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Composite Types and Function Parameters
Дата
Msg-id AANLkTi=NOJzWxMMiFA+tBLLZa44Q1Do1Qy5Cx=g1E_ra@mail.gmail.com
обсуждение исходный текст
Ответ на Composite Types and Function Parameters  (Greg <grigorey@yahoo.co.uk>)
Ответы Re: Composite Types and Function Parameters  (Greg <grigorey@yahoo.co.uk>)
Список pgsql-hackers
Hello<br /><br />I am thinking, so it isn't possible. There are a general datatype anyelement, but it cannot accept a
secondgeneral type record.<br /><br />CREATE TYPE p AS (a text, b int, c bool);<br /><br />CREATE OR REPLACE FUNCTION
fp(p)<br/> RETURNS int AS $$ <br />BEGIN RAISE NOTICE 'a = %', $1.a; RETURN $1.b;<br />END;<br />$$ LANGUAGE
plpgsql;<br/><br />postgres=# select fp(row('hello',10, false));<br />NOTICE:  a = hello<br /> fp <br />────<br
/> 10<br/>(1 row)<br /><br />Regards<br /><br />Pavel Stehule<br /><br />Time: 0.814 ms<br />postgres=# select
fp(row('hello',10,false));<br /><br /><br /><div class="gmail_quote">2010/10/25 Greg <span dir="ltr"><<a
href="mailto:grigorey@yahoo.co.uk">grigorey@yahoo.co.uk</a>></span><br/><blockquote class="gmail_quote"
style="margin:00 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table border="0" cellpadding="0"
cellspacing="0"><tbody><tr><tdstyle="font:inherit" valign="top">Hi guys, got across an interesting problem of passing
paramsto a function in postgre: is it possible to pass a composite parameter to a function without declaring a type
first?<br /><br />For example:<br /><br />// declare a function<br />create function TEST ( object??? )<br />   ....<br
/>  object???.paramName    // using parameter<br />   ....<br /><br />// calling<br />perform TEST( ROW(string, int,
bool,etc...) )<br /><br />Or do I have to do the type declaration for that parameter?<br /><br />Thanks!<br
/></td></tr></tbody></table><br/></blockquote></div><br /> 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: add label to enum syntax
Следующее
От: Jeff Davis
Дата:
Сообщение: Re: Range Types, discrete and/or continuous