Forums Register Login

SQLJ == parent displayed as child if the parent contains no children

+Pie Number of slices to send: Send
Hi
PROBLEM: A parent node is displayed as a child if the parent node contains no further childern.
I need to somehow stop the 2nd sql query from being processed if it returns no results.
1st SQL Query == For the parent nodes
2nd SQL Query == For the children of the above Query(1st SQL Query).
I have the SQLJ source as follows
// This function returns a JTree type.
JTree createTree() throws SQLException
{
int id_node =0;
int clli_node=0;
#sql { select count(*) into :id_node from groups};
#sql { select count(*) into :clli_node from nes};
DefaultMutableTreeNode[] nodes = new DefaultMutableTreeNode[id_node+clli_node];
nodes[1]=new DefaultMutableTreeNode("Root");
JTree tree = new JTree(nodes[1]);
ID_iter id_it=null;
CLLI_iter clli_it=null;
String param=null;
#sql id_it={select id,fdn,level from groups connect by prior
fdn=parent_fdn start with fdn='/' };
while(id_it.next())
{
int m = id_it.level();
if(m > 1)
{
String nameg = id_it.id();
nodes[m]=new DefaultMutableTreeNode(nameg);
nodes[m-1].add(nodes[m]);
}
param =id_it.fdn();
#sql clli_it={select clli from nes where parent_fdn= aram order by clli};
while(clli_it.next())
{
int n=id_it.level();
String name=clli_it.clli();
nodes[n+1] = new DefaultMutableTreeNode(name);
nodes[n].add(nodes[n+1]);
}
}
id_it.close();
clli_it.close();
return ( jtree );
}
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 620 times.
Similar Threads
Updating a JTree
JTree
SQLJ == Parent node displayed as a child if the parent node contains no children
SQLJ Question== Parent Node is displayed as a child if that parent has no children
Subtree in JTree
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:45:48.