Re: [GENERAL] Setting variable

2007-06-19 Thread Aleksis Petrov
On 6/18/07, Ranieri Mazili <[EMAIL PROTECTED]> wrote: Hello, I need to know why can't I do it? CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interva

[GENERAL] Setting variable

2007-06-18 Thread Ranieri Mazili
Hello, I need to know why can't I do it? CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3 year'; The last line (END_DATE := START_DATE - interval

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Michael Glaesemann
On Jun 18, 2007, at 12:11 , Ranieri Mazili wrote: Look, I did a UNION, exist other way to do it better? Considering your aggregates are different, you shouldn't really union them. In the upper query of the union, you've got production_period (which is actually a date that represents the b

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Original Message Subject: Re:[SQL] [GENERAL] Setting Variable - (Correct) From: Michael Glaesemann <[EMAIL PROTECTED]> To: Ranieri Mazili <[EMAIL PROTECTED]> Date: 18/6/2007 13:50 [Please reply to the list so that others may benefit from and participate in th

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Michael Glaesemann
[Please reply to the list so that others may benefit from and participate in the discussion.] On Jun 18, 2007, at 11:32 , Ranieri Mazili wrote: Thanks a lot for your prompt reply. You query is perfect for my problem, but I need another thing with it, I need to return the sum of production_h

Re: [SQL] [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Original Message Subject: Re:[SQL] [GENERAL] Setting Variable - (Correct) From: Michael Glaesemann <[EMAIL PROTECTED]> To: Michael Glaesemann <[EMAIL PROTECTED]> Date: 18/6/2007 13:15 On Jun 18, 2007, at 10:17 , Michael Glaesemann wrote: Looking over your fun

Re: [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Michael Glaesemann
On Jun 18, 2007, at 10:17 , Michael Glaesemann wrote: Looking over your function, I'm a little confused about what you're trying to do. I'm guessing the (final) result you're trying to get is the number of hours lost for each product per area per month for the three years prior to the prov

Re: [GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Michael Glaesemann
On Jun 18, 2007, at 9:34 , Ranieri Mazili wrote: Hello, I'm trying do the following function: CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3

[GENERAL] Setting Variable - (Correct)

2007-06-18 Thread Ranieri Mazili
Hello, I'm trying do the following function: CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3 year'; WHILE EXTRACT(YEAR FROM START_DATE) = E

[GENERAL] Setting variable

2007-06-18 Thread Ranieri Mazili
Hello, I need to know why can't I do it? CREATE OR REPLACE FUNCTION lost_hours_temp(date) RETURNS text AS $BODY$ DECLARE START_DATE date; END_DATE date; QUERY text; BEGIN START_DATE := $1; END_DATE := START_DATE - interval '3 year'; The last line (END_DATE := START_DATE - interval