Subject | Re: [firebird-support] help with a select, please! |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2009-04-03T19:19:40Z |
Thank you very much Fidel & Dimitry!!
account I'm analizing... what I want is: all the "childs" of that account, and
all the "childs of the childs", and all the "childs of the childs of the
childs"... and so on :)
In my previous example, as want the balance of the account 1400, I need to
select the accounts:
1410
1421
1422
never used that before, and I don't have a clue about how to start...
I don't imagine how to do it on the client side (as Dimitry says), because I
don't know how to select the records I need...
Thanks again guys!!!
> Hum... I see. You are trying to create a hierarquical tree ofYup! that's exactly what I want!!
> accounts, and then you want to get the balance on each one.
> create table account (Yes! that's almost the same structue I have...
> id bigint not null primary key,
> parent_id references account (id),
> code varchar(6),
> description not null varchar(60),
> allows_entries boolean /* Declare boolean as a domain of type
> char(1) or short */
> );
> Now, in your journal entry form, you will select only the accountsWell, yes, but not *all* the accounts that allows entries... depending the
> that have allows_entries equal 1.
account I'm analizing... what I want is: all the "childs" of that account, and
all the "childs of the childs", and all the "childs of the childs of the
childs"... and so on :)
In my previous example, as want the balance of the account 1400, I need to
select the accounts:
1410
1421
1422
> In order to get the balances (or summaries as you call it), you can doI use FB2.1 and I think a recursive select is what I need, the problem is that I
> two things:
>
> 1) if you are using FB 2.1.x, then use recursive CTEs
> 2) if you are using a version that does not support CTEs, then use a
> stored procedure
never used that before, and I don't have a clue about how to start...
I don't imagine how to do it on the client side (as Dimitry says), because I
don't know how to select the records I need...
Thanks again guys!!!