[SQL] Sum up network events by type, interval and network

2010-11-16 Thread Axel Rau
Hi all, For each event of each type in each interval I want to compute the sum of events referencing the same relayNet (via host) and insert/update 1 row in SumOfEvents. All intervals start at a time, minimum 5 minutes in the past, rounded down modulo 5 minutes like: SELECT DATE_TRUNC('MI

[SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause

2010-10-29 Thread Axel Rau
Good morning, I have a function argument blah of type text containing something like 33,44,55,66 . Can I cast it in some way to use it in an IN clause as integers like UPDATE foo SET x = y WHERE id IN ( blah ); or need I revert to dynamic SQL (EXECUTE...) ? Thanks, Axel --- axel@chao

Re: [SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]

2010-10-25 Thread Axel Rau
Thanks Richard and Sergey, your solution works perfect, even if blah contains only one member. Am 25.10.2010 um 18:17 schrieb Richard Broersma: Here is what I think should work: UPDATE foo Set x = y WHERE id = ANY( CAST( string_to_array( '1,2,3,4', ',' ) AS INTEGER[] )); Axel --- axel

[SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]

2010-10-25 Thread Axel Rau
Good morning, I have a function argument blah of type text containing something like 33,44,55,66 . Can I cast it in some way to use it in an IN clause as integers like UPDATE foo SET x = y WHERE id IN ( blah ); or need I revert to dynamic SQL (EXECUTE...) ? Thanks, Axel --- axel@chaos1

Re: [SQL] Poor performance in inet << cidr join (Resolved)

2005-11-03 Thread Axel Rau
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 03.11.2005 um 00:22 schrieb Tom Lane: Axel Rau <[EMAIL PROTECTED]> writes: Question: Can rtree_inet be included in the core? No, because rtree is going away in 8.2. Feel like converting that code to be a GIST opclass, instead? Perha

Re: [SQL] Poor performance in inet << cidr join (Resolved)

2005-11-02 Thread Axel Rau
Am 31.10.2005 um 19:53 schrieb Axel Rau: The planner does not use the pk-indices. Poking around, I could not find an operator class, which supports the containment ('<<') operator. Is my conclusion correct? How can the functionality be extended? Is there any implemen

[SQL] Poor performance in inet << cidr join

2005-10-31 Thread Axel Rau
Filter: ($0 << (id)::inet) The planner does not use the pk-indices. Poking around, I could not find an operator class, which supports the containment ('<<') operator. Is my conclusion correct? How can the functionality be extended? Is there any implementation

Re: [SQL] Selecting count of details along with details columns

2005-09-29 Thread Axel Rau
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 29.09.2005 um 12:03 schrieb Richard Huxton: Axel Rau wrote: Am 29.09.2005 um 10:30 schrieb Richard Huxton: Axel Rau wrote: ... Ah - this is two questions: 1. What are the unique (t2_name,t1_name) pairings? 2. How many different (t1.id

Re: [SQL] Selecting count of details along with details columns

2005-09-29 Thread Axel Rau
Am 29.09.2005 um 10:30 schrieb Richard Huxton: Axel Rau wrote: SELECT T2.T2_name, COUNT(T1.id) AS xx FROM T2, T1 WHERE T2.id = T1.fk_t2 GROUP BY T2.T2_name HAVING COUNT(T1.id) > 1 ORDER BY xx DESC; t2_name | xx -+ T2-N2 | 3 T2-N3 | 2 (2 rows) Adding column t1_name to the res

[SQL] Selecting count of details along with details columns

2005-09-28 Thread Axel Rau
in WHERE clauses. Question: Is this conform with the standard? Sorry, if this has been discussed earlier. Axel Axel Rau, Frankfurt, Germany +49-69-951418-0

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Axel Rau
ks no big difference. It's the nature of my ids/abuse application, that there are always faked source addresses, which may not belong to any routed net. Axel Axel Rau, Frankfurt, Germany +49-69-951418-0 ---(end of broadcast)--

Re: [SQL] Updating cidr column with network operator

2005-09-27 Thread Axel Rau
rt_check() RETURNS TRIGGER AS $$ BEGIN -- check if new net overlapps with existing one PERFORM N.id FROM network N WHERE NEW.id << N.id OR NEW.id >> N.id; IF FOUND THEN RAISE EXCEPTION '?Attempt to insert overlapping network %', NEW.id; RETURN NULL; E

Re: [SQL] Updating cidr column with network operator

2005-09-26 Thread Axel Rau
Am 26.09.2005 um 02:05 schrieb Michael Fuhr: On Fri, Sep 23, 2005 at 09:19:25PM +0200, Axel Rau wrote: Am 23.09.2005 um 19:32 schrieb Michael Fuhr: On Fri, Sep 23, 2005 at 06:31:17PM +0200, Axel Rau wrote: Networks change during time, being diveded or aggregated or you just enter wrong data

Re: [SQL] Updating cidr column with network operator

2005-09-23 Thread Axel Rau
ema is events -> addresses -> autnums -> organisations. Axel Axel Rau, Frankfurt, Germany +49-69-951418-0 -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iQEVAwUBQzRWjsFz9+6bacTRAQIT4Af/fYbPJtgi9sDcWTm84hbtPl9BUS6Rt0Wo 728oZO7/iEXNSCoaZCqUymK2sK

Re: [SQL] Updating cidr column with network operator

2005-09-23 Thread Axel Rau
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 23.09.2005 um 19:32 schrieb Michael Fuhr: On Fri, Sep 23, 2005 at 06:31:17PM +0200, Axel Rau wrote: Networks change during time, being diveded or aggregated or you just enter wrong data during insert. Have you considered using a CHECK

Re: [SQL] Updating cidr column with network operator

2005-09-23 Thread Axel Rau
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am 22.09.2005 um 22:26 schrieb Daryl Richter: Axel Rau wrote: Thank you for responding, Daryl, Am 22.09.2005 um 16:45 schrieb Daryl Richter: Axel Rau wrote: Hi SQLers, I have a fk from address to network and try to update the foreign key

Re: [SQL] Updating cidr column with network operator

2005-09-22 Thread Axel Rau
Thank you for responding, Daryl, Am 22.09.2005 um 16:45 schrieb Daryl Richter: Axel Rau wrote: Hi SQLers, I have a fk from address to network and try to update the foreign key column to point at the network, "it belongs to": CREATE TABLE network ( id cidr PRIMARY KEY

[SQL] Updating cidr column with network operator

2005-09-22 Thread Axel Rau
rresponding net exists): UPDATE address SET network = (SELECT N.id WHERE A.id << N.id) FROM address A, network N WHERE A.id << N.id; But this ended up with all network columns pointing at the same net (-:). Any help would be appreciated. Axel Axel Rau, Frankfur