Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes: make install-all-headers That's not a complete solution though; the headers are only half the problem. Makefiles are the other half, and our story on them is pretty bad. For instance I've been meaning to ask what to do about this open bug report:

[SQL] Select from two databases

2004-04-22 Thread Becky Alcorn
Hi, I was wondering if there has been any further development on running SQL statements involving more than one database? We are porting a database from SQLServer to Postgres and some queries in related applications use joins on tables that are in different databases. We know we can modify the

Re: [SQL] Join issue on a maximum value

2004-04-22 Thread Tom Lane
Heflin [EMAIL PROTECTED] writes: Bruno Wolff III wrote: The postgres specific way of doing this is: SELECT DISTINCT ON (auction.auction_id) auction.auction_id, image.image_id, image.image_descr FROM auction JOIN image ON auction.auction_id = image.auction_id WHERE auction.auction_owner =

Re: [SQL] staggered query?

2004-04-22 Thread Vincent Ladlad
hey thanks! it worked:) here's how we did it: select sampletime from data where (extract(seconds from sampletime)::int)::text in (14, 17, 19); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Denis P Gohel Sent: Wednesday, April 21, 2004

[SQL] Bug#960: WAS: Trigger calling a function HELP ME! (2)

2004-04-22 Thread abief_ag_-postgresql
Ok. I think I found the problem is related to this Bug. is there anywhere to check the status of this bug? regards, = Riccardo G. Facchini ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] rule's behavior with join interesting

2004-04-22 Thread Richard Huxton
On Wednesday 21 April 2004 21:07, Kemin Zhou wrote: Here I have a very simple case table1 table1_removed anotherTable create or replace RULE rec_remove as ON DELETE TO table1 do insert into table1_remove select old.*, a.acc from old g join anotherTable a on g.acc=a.other_acc; === the

Re: [SQL] Select from two databases

2004-04-22 Thread Richard Huxton
On Thursday 22 April 2004 08:00, Becky Alcorn wrote: Hi, I was wondering if there has been any further development on running SQL statements involving more than one database? We are porting a database from SQLServer to Postgres and some queries in related applications use joins on tables

Re: [SQL] Order by YYYY MM DD in reverse chrono order trouble

2004-04-22 Thread ogjunk-pgjedan
Hello, I'd love to be able to do that, but I cannot just ORDER BY uu.add_date, because I do not have uu.add_date in the SELECT part of the statement. The reason I don't have it there is because I need distinct MM DD values back. Is there a trick that I could use to make this more elegant?

Re: [SQL] Order by YYYY MM DD in reverse chrono order trouble

2004-04-22 Thread Stijn Vanroye
Yes indeed, I seem to have misinterpreted that last one. My apologies. The distinct solution I mentioned isn't going to solve it, you are absolutely right in your example. To get back on track: You don't have to use a field in the select part of you query to be able to use it in the order by

Re: [SQL] Trigger calling a function HELP ME! (2)

2004-04-22 Thread Richard Huxton
On Wednesday 21 April 2004 16:16, [EMAIL PROTECTED] wrote: CREATE OR REPLACE FUNCTION public.imp_test_to_out_test(imp_test) RETURNS imp_test AS 'begin return $1; end;' LANGUAGE 'plpgsql' STABLE; CREATE OR REPLACE FUNCTION public.imp_test_trigger() RETURNS trigger AS

Re: [SQL] Order by YYYY MM DD in reverse chrono order trouble

2004-04-22 Thread Tom Lane
[EMAIL PROTECTED] writes: I'd love to be able to do that, but I cannot just ORDER BY uu.add_date, because I do not have uu.add_date in the SELECT part of the statement. Sure you can. Back around SQL89 there was a restriction that ORDER BY values had to appear in the SELECT list as well, but

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Rod Taylor
On Thu, 2004-04-22 at 01:18, Peter Eisentraut wrote: Kemin Zhou wrote: IN chapter 33 Extending SQL 33.7.5 Writing Code when run pg_config --includedir-server I got /usr/local/pgsql/include/server but my machine does have this directory make install-all-headers It's explained in

Re: [SQL] Order by YYYY MM DD in reverse chrono order trouble

2004-04-22 Thread ogjunk-pgjedan
Hello, Hm, doesn't work for me: [EMAIL PROTECTED] mydb= select distinct date_part('year', uu.add_date), date_part('month', uu.add_date), date_part('day', uu.add_date) from uus inner join ui on uus.user_id=ui.id inner join uu on ui.id=uu.user_id where uus.subscriber_user_id=1 order by

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Tom Lane
Peter Eisentraut [EMAIL PROTECTED] writes: Am Donnerstag, 22. April 2004 07:59 schrieb Tom Lane: For instance I've been meaning to ask what to do about this open bug report: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=112244 Well, perhaps getting the tutorial to compile should be

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Tom Lane
Rod Taylor [EMAIL PROTECTED] writes: On Thu, 2004-04-22 at 01:18, Peter Eisentraut wrote: make install-all-headers It's explained in the installation instructions. That doesn't happen on most platforms in the standard package. Depends what you mean by standard package? The PGDG and Red

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Rod Taylor
On Thu, 2004-04-22 at 10:11, Peter Eisentraut wrote: Am Donnerstag, 22. April 2004 15:58 schrieb Rod Taylor: make install-all-headers It's explained in the installation instructions. That doesn't happen on most platforms in the standard package. It certainly happens in all the

[SQL] Design Problem...

2004-04-22 Thread Ryan Riehle
Our business has multiple cost/profit centers that I call business units, these are in a table called buinessunits. We also have a table that holds a list of services that are offerred by a business. Each business unit has many services it offers; 1 businees unit = Many Services. We want to be

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Peter Eisentraut
Am Donnerstag, 22. April 2004 15:58 schrieb Rod Taylor: make install-all-headers It's explained in the installation instructions. That doesn't happen on most platforms in the standard package. It certainly happens in all the packages that have ever come by me (maybe after a little

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Peter Eisentraut
Am Donnerstag, 22. April 2004 07:59 schrieb Tom Lane: Peter Eisentraut [EMAIL PROTECTED] writes: make install-all-headers That's not a complete solution though; the headers are only half the problem. Makefiles are the other half, and our story on them is pretty bad. For instance I've been

Re: [SQL] rule's behavior with join interesting

2004-04-22 Thread Jan Wieck
Richard Huxton wrote: On Wednesday 21 April 2004 21:07, Kemin Zhou wrote: Here I have a very simple case table1 table1_removed anotherTable create or replace RULE rec_remove as ON DELETE TO table1 do insert into table1_remove select old.*, a.acc from old g join anotherTable a on

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Kemin Zhou
Rod Taylor wrote: On Thu, 2004-04-22 at 01:18, Peter Eisentraut wrote: Kemin Zhou wrote: IN chapter 33 Extending SQL 33.7.5 Writing Code when run pg_config --includedir-server I got /usr/local/pgsql/include/server but my machine does NOT have this directory make

[SQL] lifetime of temp schema versus compiled image of plpgsql proc

2004-04-22 Thread Dennis
Hi, this is pg 7.4.1 I am opening a connection to postgres starting a transaction executing a plpgsql function that creates temp tables executing a plpgsql function that populates the temp tables querying the temp table closing the transaction then on the same connection, I open a

Re: [SQL] lifetime of temp schema versus compiled image of plpgsql proc

2004-04-22 Thread Dennis
Bruce Momjian writes: There is an FAQ item on this --- use EXECUTE. So I should be using EXECUTE for all access to the temp tables? ie inserts, and selects (in this case). Should I use execute for the table creation? Dennis ---(end of

Re: [SQL] lifetime of temp schema versus compiled image of plpgsql proc

2004-04-22 Thread Bruce Momjian
There is an FAQ item on this --- use EXECUTE. --- Dennis wrote: Hi, this is pg 7.4.1 I am opening a connection to postgres starting a transaction executing a plpgsql function that creates temp tables executing

[SQL] Is there an easy way to normalize-space with given string functions

2004-04-22 Thread Janning Vygen
Hi, i am looking for something like $ SELECT btrim(replace(' too many spaces! ', '\s+',' '), ''); too many spaces i searched the function list and tried to combine to or more functions, but i miss a replace function which uses regular expressions. Do i have to write my own function or

Re: [SQL] lifetime of temp schema versus compiled image of plpgsql proc

2004-04-22 Thread Tom Lane
Dennis [EMAIL PROTECTED] writes: then on the same connection, I open a transaction, execute a plpgsql function that populates the temp tables and the function bombs with this error message: ERROR: schema pg_temp_8 does not exist That's a bit hard to believe. Could we see a complete test

Re: [SQL] lifetime of temp schema versus compiled image of plpgsql proc

2004-04-22 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Dennis wrote: So I should be using EXECUTE for all access to the temp tables? ie inserts, and selects (in this case). Should I use execute for the table creation? All access from plpgsql functions for temp tables should use EXECUTE, I think that

Re: [SQL] Is there an easy way to normalize-space with given string functions

2004-04-22 Thread Tom Lane
Janning Vygen [EMAIL PROTECTED] writes: i searched the function list and tried to combine to or more functions, but i miss a replace function which uses regular expressions. There isn't one in the SQL standard. Most people who need one write a one-liner function in plperl or pltcl. (Mind