Re: [GENERAL] Letting a function return multiple columns instead of a single complex one

2005-12-08 Thread A.j. Langereis
> test=# select c,(ff).* from (select bar.*,get_a_foo(c) as ff from bar) b; > c | a | b > ---+---+--- > 1 | 1 | 2 > (1 row) > > Tanks! that works great! It managed to get it even a bit more simplified: select bar.*, (get_a_foo(c)).* from bar; > Not amazingly elegant, but it works. Note that you

Re: [GENERAL] Delete Question

2005-12-06 Thread A.j. Langereis
Postgresql supports records in the where clause i.e. you can compare multiple columns simultaneously: > test=# delete from change where id || ':' || datum not in (select id || ':' || max(datum) from change group by id order by 1); could therefore be rewritten to: delete from change where (id, da

Re: [GENERAL] Letting a function return multiple columns instead of a single complex one

2005-12-06 Thread A.j. Langereis
> test=# select c,(ff).* from (select bar.*,get_a_foo(c) as ff from bar) b; > c | a | b > ---+---+--- > 1 | 1 | 2 > (1 row) > Tanks! that works great! It managed to get it even a bit more simplified: select bar.*, (get_a_foo(c)).* from bar; > Not amazingly elegant, but it works. Note that you

[GENERAL] Letting a function return multiple columns instead of a single complex one

2005-12-06 Thread A.j. Langereis
Dear all,   I have two questions: fist of all, is there any function in pg like oracle's rownum?   secondly, I wonder how it is possible to let a function return a dataset with different columns instead of a single, complex, one.   create table foo (a int, b int);   insert into foo (a,b) valu

[GENERAL] selecting a attribute from a function

2005-11-24 Thread A.j. Langereis
Dear all, I have written a function that returns a set. This set is of a type I made, containing multiple attributes.   create type my_type as (col1 int, col2 int)   Something likes this works:   select col1 from my_pg_func('hello');   But how can I do something like this:   select my_pg_func(t

Re: [GENERAL] PREPARE in bash scripts

2005-11-23 Thread A.j. Langereis
Dear Martijn, The problem with your solution is that the script is meant to process a log-file real-time. Therefore the insert should be done immediately, however it is the same statement over and over agian, just with different parameters i.e. an ideal case fore PREPARE. Yours, Aarjan Langereis

[GENERAL] PREPARE in bash scripts

2005-11-23 Thread A.j. Langereis
Dear all, I've written a bash script that looks like the one below: #!/bin/bash DBuser='root' DBname='test' psql -q --username=$DBuser --dbname=$DBname -c "prepare test_statement (integer) as insert into tbl_test (col_test) values (\\$1)"; tail -f /root/testfile | while read a; do

Re: [GENERAL] Rule appears not to fire on insert w/ "except"

2005-11-22 Thread A.j. Langereis
gin insert into test_que (row_id) values (new.id); return new; end; ' language plpgsql; create trigger trigger_test before insert on test1 for each row execute procedure trg_test(); Yours, Aarjan - Original Message - From: "Chris Kratz" <[EMAIL PROTECTED]&g

Re: [GENERAL] Rule appears not to fire on insert w/ "except"

2005-11-22 Thread A.j. Langereis
Dear Chris, What about this: insert into test1 select id, data from test2 where id, data not in (select id, data from test1); of which one would expect the same results... Yours, Aarjan Ps. notice that you are inserting data into a serial column (in your examples as well), as far as I

Re: [GENERAL] Difference in indexes

2005-11-22 Thread A.j. Langereis
Difference in indexes > > ""A.j. Langereis"" <[EMAIL PROTECTED]> wrote > > > > "Bitmap Heap Scan on hosts (cost=2.07..11.34 rows=21 width=59) (actual > > time=0.175..0.287 rows=21 loops=1)" > > " Recheck Cond: ((hostname)::text

Re: [GENERAL] Difference in indexes

2005-11-21 Thread A.j. Langereis
ame on hosts (cost=0.00..37.28 rows=21 width=59) (actual time=0.068..0.281 rows=21 loops=1)" " Index Cond: ((hostname)::text = 'Fabian'::text)" "Total runtime: 0.492 ms" Yours, Aarjan - Original Message - From: "Qingqing Zhou" <[E

[GENERAL] Difference in indexes

2005-11-21 Thread A.j. Langereis
Dear all,   I'm using a PostgreSQL 8.1.0 dabase on a Fedora Core 3 machine here. In this table there is a table hosts:   CREATE TABLE hosts(  hostid int4 NOT NULL DEFAULT nextval('hosts_hostid_seq'::regclass),  hostip cidr NOT NULL,  hostname varchar(50),  lastseen timestamp DEFAULT '1970-01

Re: [GENERAL] How to debug a locked backend ?

2005-11-18 Thread A.j. Langereis
First of all: "TIP 2: Don't 'kill -9' the postmaster" On topic: What do you mean with "locked"? Is it using 100% CPU? Or does it give any error messages? If so, what are they? If there is a deadlock situation, Postmaster should detect it and will then cancel the query. Yours, Aarjan - Origin