• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQLJ == Parent node displayed as a child if the parent node contains no children  RSS feed

sharath kv
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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];
// Set the Root 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;
// Select all parents
#sql id_it={select id,fdn,level from groups connect by prior
fdn=parent_fdn start with fdn='/' };
int m = id_it.level();
if(m > 1)
String nameg = id_it.id();
nodes[m]=new DefaultMutableTreeNode(nameg);
param =id_it.fdn();
// Select all children based on the above parent
// Query
#sql clli_it={select clli from nes where parent_fdn= aram order by clli};
int n=id_it.level();
String name=clli_it.clli();
nodes[n+1] = new DefaultMutableTreeNode(name);
return ( jtree );
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!