Re: [SQL] How can you generate a counter for ordered sets?

2007-06-18 Thread Rodrigo De León
On May 17, 8:19 am, [EMAIL PROTECTED] (Christopher Maier) wrote: > Conceptually, all the exons for a given gene form a set, ordered by > their "start" attribute. I need to add a new integer column to the > table to store a counter for each exon that indicates their position > in this ordering. > >

Re: [SQL] tsearch2() trigger and domain types...

2007-06-18 Thread Tom Lane
"Michael D. Stemle, Jr." <[EMAIL PROTECTED]> writes: > For standardization in my database I use a domain (login_t) for my login > column in my profile table. > Well, here's what I get upon every update and insert to the profile table: > WARNING: TSearch: 'login' is not of character type The tse

[SQL] tsearch2() trigger and domain types...

2007-06-18 Thread Michael D. Stemle, Jr.
Okay, so I have an interesting problem that I'm having a hard time figuring out. For standardization in my database I use a domain (login_t) for my login column in my profile table. I'm trying to use the tsearch2() trigger to index several columns, including the login column, into a column ca

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 the discussion.] On

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 function, I'm a litt

Re: [SQL] [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: [SQL] [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

Re: [SQL] Setting variable

2007-06-18 Thread Michael Glaesemann
On Jun 18, 2007, at 9:29 , Ranieri Mazili wrote: 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

[SQL] 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

[SQL] 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] Exec a text variable as select

2007-06-18 Thread A. Kretschmer
am Mon, dem 18.06.2007, um 10:14:32 -0300 mailte Ranieri Mazili folgendes: > Hello, > > I'm creating a function that will create a select statement into a > while, this select will be stored into a text variable, after while ends > I need to execute this query stored into variable, on SQLSERVER

[SQL] Exec a text variable as select

2007-06-18 Thread Ranieri Mazili
Hello, I'm creating a function that will create a select statement into a while, this select will be stored into a text variable, after while ends I need to execute this query stored into variable, on SQLSERVER I can do: EXEC(text_variable) How can I do this on Postgres? I appreciate any help

Re: [SQL] array_to_string

2007-06-18 Thread Sabin Coanda
"Tom Lane" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Sabin Coanda" <[EMAIL PROTECTED]> writes: >> I used the function array_to_string, and I found it ignores NULL values, >> e.g. array_to_string( 'ARRAY[1,NULL,3]', ',' ) returns '1,3'. > > Do you have a better idea? > > regar