Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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

Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 =;
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 );
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic