From: | tolik(at)icomm(dot)ru (Anatoly K(dot) Lasareff) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Problem with PlPgsql function on composite types |
Date: | 1998-11-26 14:28:45 |
Message-ID: | x7n25ebk9u.fsf@tolikus.hq.aaanet.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi, all!
I use postgres 6.4 under FreeBSD.
I create table 'a':
Table = a
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| dt | datetime | 8 |
| i | int4 | 4 |
+----------------------------------+----------------------------------+-------+
with some values:
tolik=> select * from a;
dt |i
----------------------------+-
Thu Nov 26 16:35:23 1998 MSK|1
Wed Nov 25 00:00:00 1998 MSK|2
Fri Nov 27 00:00:00 1998 MSK|3
(3 rows)
Then I create simple function:
--------------------------------------
create function fff(a) returns a as
'
declare
inp alias for $1;
begin
raise notice ''i=% dt=%'', inp.i, inp.dt;
return inp;
end;
'
language 'plpgsql';
--------------------------------------
This function returns its input argument without changing and notice
values of input row. When I execute statement
select dt(fff(a));
I get follow output:
-----------------------------------------------
NOTICE: i=1 dt=Thu Nov 26 16:35:23 1998 MSK
NOTICE: i=<NULL> dt=<NULL>
NOTICE: i=2 dt=Wed Nov 25 00:00:00 1998 MSK
NOTICE: i=<NULL> dt=<NULL>
NOTICE: i=3 dt=Fri Nov 27 00:00:00 1998 MSK
NOTICE: i=<NULL> dt=<NULL>
dt
----------------------------
Sat Jan 01 03:00:00 2000 MSK
Sat Jan 01 03:00:00 2000 MSK
Sat Jan 01 03:00:00 2000 MSK
(3 rows)
-----------------------------------------------
My questions are:
1) why the function calls 6 times, but not 3 times
2) what the data are in this output
3) how can I right write function, working with composite types?
Help me, please...
--
Anatoly K. Lasareff Email: tolik(at)icomm(dot)ru
From | Date | Subject | |
---|---|---|---|
Next Message | Stuart Rison | 1998-11-26 15:55:34 | [GENERAL] Typecasting datetype as date. How do I cope with NULLs? |
Previous Message | Oleg Broytmann | 1998-11-26 09:45:54 | Re: [GENERAL] table protections? |