[SQL] How to get text representation of composite value?

2007-04-24 Thread David Flegl
Hello,
  I'd like to ask you for a help. I'm in trouble with $subj. I need something 
like documentation of PostgreSQL in chapter 8.11.5 says.
Inside trigger I have record type NEW which is composite type.  How could one 
do something like :

   text_var:=to_char(NEW)

 So if NEW.at1='test' and NEW.at2=100 I would get string: 'test',100

 But the problem is then if trigger is generally used for many tables, I
 don't know number of elements and so on.

As I know, for element types are defined output function, and I can use this:
  SELECT textin(point_out('(1,1)'::point))::varchar;

Anybody can help me? 
P.S. pl/pgsql would be best way if it possible.


David F


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [SQL] hi

2007-04-24 Thread David Flegl
Hi,
 try this. It's working...

SELECT t1.sno, sum(t2.value)
FROM temp as t1, temp as t2
WHERE t1.sno >= t2.sno
GROUP BY t1.sno;

but not completely. The problem is the this suppose your sno is uniqu. But as I 
see 3 is not.
Anyway it may help you.


>I have the data like this in temp table
>
>SQL> Select sno, value from temp;
>
>SNO   Value
>
>1 650.00
>
>2 850.00
>
>3 640.00
>
>3 985.00
>
>5 987.00
>
>9 9864.00
>
>7 875.00
>
>Now, I want display the result like this...
>
>SQL> Select sno, value, get_sum(value) as sum from temp;
>
>SNO   Value  SUM
>
>1 650.00 650.00
>
>2 850.00 1500.00   --650+850
>
>3 640.00 2140.00   --1500+640
>
>3 985.00 3125.00   -- 2140+985
>
>5 987.00 4112.00
>
>9 9864.00   13976.00
>
>7 875.00 14851.00
>
> 
>
>Any one can tell me query for this .. I don't want any procedure or
>function...
>
> 
>
> 
>
>Thanks & Regards
>
>Penchal Reddy
>
> 
>
>
>
>Information transmitted by this e-mail is proprietary to Infinite
Computer Solutions and / or its Customers and is intended for use only by
the individual or the entity to which it is addressed, and may contain
information that is privileged, confidential or exempt from disclosure
under applicable law. If you are not the intended recipient or it appears
that this mail has been forwarded to you without proper authority, you are
notified that any use or dissemination of this information in any manner is
strictly prohibited. In such cases, please notify us immediately at
[EMAIL PROTECTED] and delete this email from your records.
>


---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[SQL] NEW to plpythonu function?

2007-04-30 Thread David Flegl

Hi,
  may anyone help me with problem how to passed trigger row NEW from 
trigger function in plpgsql to other support function in plpythonu? I've 
tried something like>


CREATE FUNCTION pythfce(arg record)...
CREATE FUNCTION pythfce(arg anyelement)...

but now effect. I'm getting system messages like: plpythonu don't know 
argument type recort, anyelement)


P.S. I would like to have trigger function in plpgsql and supporting 
function in plpythonu, not to join them to plpythonu.


Thankx a lot

David Flegl

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings