Re: [SQL] Create function statement with insert statement

2003-03-17 Thread Susan Hoddinott
Hi Chris, Pleased to (finally) report success. Here are the solutions: INSERT - DROP FUNCTION orderinsert() ; CREATE OR REPLACE FUNCTION orderinsert() RETURNS OPAQUE AS ' BEGIN IF NEW.CUSTOMER_ID ISNULL THEN RAISE EXCEPTION "CUSTOMER_ID cannot be NULL value" ; END IF ; IF

Re: [SQL] upcasting multiplication in a query

2003-03-17 Thread Tom Lane
"John Guthrie" <[EMAIL PROTECTED]> writes: > select (seconds*100)+micros from my_table; > but it looks to me like postgresql puts the rresult into another int4 (since > i am getting negative numbers, i assume overflow). how can i get it to use > int8? Cast the constant to int8.

Re: [SQL] btree_gist, gint4_union

2003-03-17 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: > I am confused by your question. It seems it is declared as returning an > int. I suspect that all of the GiST union methods should be declared to return 'internal', but Oleg or Teodor would probably know better. regards, tom lan

Re: [SQL] upcasting multiplication in a query

2003-03-17 Thread dev
> i have a schema that stores timestamps in seconds/microseconds format. > each > column in the table is int4. what i want to do is to compute the int8 > value > of total microseconds, a la: > select (seconds*100)+micros from my_table; > but it looks to me like postgresql puts the rresult int

Re: [SQL] Poor performance on a right join

2003-03-17 Thread dev
> Here's the EXPLAIN output: > > EXPLAIN ANALYZE SELECT a.CALL_DATE, a.OPERATOR_ID, a.CUST_CODE FROM > PHONE as b right join CALLHIST as a on (a.CUST_CODE=b.CUST_CODE) where > (b.PHONE > = '847-478-2100') order by a.call_date desc; > NOTICE: QUERY PLAN: > > Sort (cost=14320.04..14320.04 rows=6046

Re: [SQL] Poor performance on a right join

2003-03-17 Thread Tom Lane
Carmen Sarlo <[EMAIL PROTECTED]> writes: > EXPLAIN ANALYZE SELECT a.CALL_DATE, a.OPERATOR_ID, a.CUST_CODE FROM > PHONE as b right join CALLHIST as a on (a.CUST_CODE=b.CUST_CODE) where > (b.PHONE = '847-478-2100') order by a.call_date desc; This query is rather pointless as-is: the WHERE clause wi

[SQL] howto?

2003-03-17 Thread Sjors
Hi,   Being not able to grasp in full sql, I've decided to call on the list. I've got a table with points, place_id and distance between points and place_id. For each point there can be more place_id's but I want to selesct the one with the minimum distance. Now I can group by the points and

Re: [SQL] Formatting intervals..

2003-03-17 Thread Christoph Haller
> > > > Is it possible to customize interval display. > > > > eg, > > > > tradein_clients=# SELECT cast ('10-10-1999'::timestamp - '1-1-1999'::timestamp AS interval); > > +--+ > > | interval | > > +--+ > > | 282 days | > > +--+ > > (1 row) > > > > can i display it in month

[SQL] String aggregate function

2003-03-17 Thread Objectz
Hi all, I want to make an aggregate function that concatenates strings from a certain column into one cell in a group by clause. For example I have the following table : TypeText = 1 text1 2 text2 1 text3 3