[EMAIL PROTECTED] wrote:

hi people

last days i'm in trouble trying to run a "recursive" - like SQL query

in my table are rows with an id column and a column that specify the parent_id (row). so when i get a row (with id=10 for example) the i have to ask all the rows with the value 10 in column patent_id (but for each row and before get the next row-results i have to run a SQL query that
search for all rows that are have parent_id = this row id) and so on....



i have a succesfull output using an .xsp with hand coded nested esql queries (3 or 4 levels)


the problem is tha i dont know how many levels i have to go.

trying to put this esql query into a function who will call it-self has began my odysey.


i need something like


        <xsp:logic>       
        
                public void getChilds(String parent_id){

                        <esql:execute-query>
                                <esql:query>select * from tblElements WHERE element_Parent= 
<xsp:expr>parent_id</xsp:expr></esql:query>
                                <esql:results>
                                <xsp:logic>parent_id = <esql:get-string 
column="element_id"/>;</xsp:logic>
                                <esql:get-columns/>
                                call getChilds(parent_id);
                                </esql:results>
                        </esql:execute-query>
                }       
                
                getChilds("1");
                
        </xsp:logic>              

what i try to do is to display all elements from the table in a Tree-like view

<element>
<id>5</id>
<parent_id>1</parent_id>
<element>
<id>6</id>
<parent_id>5</parent_id>
</element>
<element>
<id>9</id>
<parent_id>5</parent_id>
  <element>
  <id>12</id>
  <parent_id>9</parent_id>
  </element>
</element>
</element>

any idea?



The key is to pass some more vars to the method like the object model and the document handler. See
generated source code for details. E.g. the esql logicsheet defines a method that could serve as a blue
print.


Chris.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to