Re: [GENERAL] I need help creating a query

2006-07-14 Thread Sergio Duran
Ok, all the suggestions were good.I think I'll stick with Marcin Mank's query for now, I'll also try to work further with Richard Broersma's query later.Thank you guys, you were really helpful. On 7/14/06, Marcin Mank <[EMAIL PROTECTED]> wrote: - Original Messag

Re: [GENERAL] I need help creating a query

2006-07-14 Thread Sergio Duran
osition ON position.worker_id=worker.worker_id WHERE fecha<='2006-05-01'ORDER BY fecha DESC;I'd appreciate some feedback, I hope there's a better way to do this. (maybe without creating the plpgsql function but using an internal function) On 7/14/06, Sergio Duran <[EMAIL PROTECTED]>

Re: [GENERAL] I need help creating a query

2006-07-14 Thread Sergio Duran
irst grouped salary, maybe I should write an aggregate function that saves the first value and ignores the next ones. Is there already an aggregate function that does this? I havent written any aggregate functions yet, can anybody spare some pointers? On 7/14/06, Sergio Duran <[EMAIL PROTECTED]> w

Re: [GENERAL] I need help creating a query

2006-07-14 Thread Sergio Duran
Nice, Richard, but you use max(startdate), how about the salary? i cant use max(salary) how about if he got a pay cut?My current solution is to write the nested query on the field list, like SELECT worker.*,   (select salary FROM position where worker_id=worker.worker_id and fecha<='2006

[GENERAL] I need help creating a query

2006-07-13 Thread Sergio Duran
Hello,I need a little help creating a query, I have two tables, worker and position, for simplicity sake worker only has its ID and its name, position has the ID of the worker, the name of his position, a date, and his salary/ worker:   worker_id, nameposition: position_id, worker_id, position, sta

[GENERAL] Trigger function to audit any kind of table

2006-06-06 Thread Sergio Duran
Hello,I would like to know if it is possible to create a trigger function which does something likeCREATE OR REPLACE FUNCTION table_audit() RETURNS TRIGGER AS $table_audit$BEGIN  INSERT INTO audit SELECT TG_OP, current_timestampmp, current_user, OLD, NEW;   RETURN NEW;END $table_audit$ LANGUAGE plp

[GENERAL] PostgreSQL authentication as my application's authentication.

2006-06-01 Thread Sergio Duran
Hello,I'm developing a web application, I normally write the authentication using a database table for usernames and passwords, I would like to implement this app using postgresql's authentication, the user types his user/pass and that's the user/pass used for database connectivity, so each user ar