[SQL] Cascading sum in tree with CTE?

2010-04-09 Thread Svenne Krap
Hi . My problem resembles this: I have the following (simplified) tables 1) create table account ( id serial, name varchar, parent_id int4 references account, primary key (id)) 2) create table transaction (id serial, account_id int4 references account, memo varchar, debet, credit, primary key(i

Re: [SQL] Cascading sum in tree with CTE?

2010-04-09 Thread silly sad
to select a whole subtree of a particular node of a tree. u have to modify the tree representation in one of the two ways (according to you fine-tuned needs) (1) store in the EACH node the PATH from root to this node (2) store (l,r) segment representing the INCLUSIONS of nodes into other nodes s

Re: [SQL] Cascading sum in tree with CTE?

2010-04-09 Thread Harald Fuchs
In article <4bbed49d.7080...@krap.dk>, Svenne Krap writes: > Hi . > My problem resembles this: > I have the following (simplified) tables > 1) create table account ( id serial, name varchar, parent_id int4 > references account, primary key (id)) > 2) create table transaction (id serial, accoun

[SQL] understanding select into

2010-04-09 Thread John
Hi, I am reviewing a function written by some xTuple guys. What is interesting about it is it uses the "INTO" statement like select something into _p from sometable where somecriteria. The function contiunes and uses the data retreived _p.somefield_name And then the function ends. Ok my que

Re: [SQL] understanding select into

2010-04-09 Thread Plugge, Joe R.
Johnf, I would think that the _p, _test, _r etc are local variables within the procedure/function and this is the way that the value (from the select) gets assigned to that local variable. -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.or

Re: [SQL] understanding select into

2010-04-09 Thread Pavel Stehule
Hello 2010/4/9 John : > Hi, > I am reviewing a function written by some xTuple guys.  What is interesting > about it is it uses the "INTO" statement like > > select something into _p from sometable where somecriteria. > > The function contiunes and uses the data retreived > _p.somefield_name > > A

Re: [SQL] understanding select into

2010-04-09 Thread John
Wow thanks to all that replied - you folks are correct. The "_p" and the others are vars. _p RECORD; I won't forget that one for a long time (however, I do drink :-)) Johnf On Friday 09 April 2010 10:32:51 am Pavel Stehule wrote: > Hello > > 2010/4/9 John : > > Hi, > > I am reviewing a function