/* * Example program that demonstrates the use of SQLTable. */ public class SQLTableDemo { public static void main(String[] argv) { /* Create a representation of the CUST table. */ SQLTable cust = new SQLTable("CUST", "CUST_ID"); cust.addColumn("CUST_NAME", "Customer"); cust.addColumn("CUST_ID", "Customer ID"); /* Create a representation of the INV table. */ SQLTable inv = new SQLTable("INV", "INV_ID"); /* Associate INV.INV_CUST_ID with CUST.CUST_ID. */ cust.addChildTable(inv, "INV_CUST_ID"); /* Create a representation of the LINE table. */ SQLTable line = new SQLTable("LINE", "LINE_ID"); line.addColumn("LINE_DESC", "Item Description"); line.addColumn("LINE_QTY", "Quantity"); /* Constrain the line table so that we only get * items with a quantity at least 10. */ line.addConstraint("LINE_QTY", Constraint.GE, "10"); /* Associate LINE.LINE_INV_ID with INV.INV_ID */ inv.addChildTable(line, "LINE_INV_ID"); /* Print out the SQL statement. */ System.out.println(cust.buildSQL()); } }