
--
-- PgAccess PgAckage
--

-- PGA

            INSERT INTO pga_forms (formname, formsource)
                 VALUES ('Working with trees','{ftree 6 {set city ""; set continent ""} 375x315+36+115 #999999 left_ptr {DataSet(.ftree.qp,city) DataSet(.ftree.qp,continent) DataSet(.ftree.qry,continent)}} {query qp {330 20 350 40} qry_city_continents query1 {} {} flat #d9d9d9 #d9d9d9 1 n center l left_ptr false none {} {}} {tree tr {30 30 210 280} {# these are variables for the labels to the right of the tree
variable continent
variable city

# the name of the tree we clicked is the first argument
set treename [lindex $args 0]

# the name of the node we clicked is the second (or more) argument
set nodename [lindex $args 1]

# if the node only has two parts, its the root and the continent name

if {[llength [split $nodename "-"]]==2} {

	set continent [lindex [split $nodename "-"] 1]
	set city ""

	::DataControl(.ftree.qp)::setSQL "
		SELECT DISTINCT city
						 FROM phonebook
					  WHERE  continent=\'$continent\'
							AND city!=\'\'"
	::DataControl(.ftree.qp)::open
	::DataControl(.ftree.qp)::fill .ftree.tr city $nodename
	::DataControl(.ftree.qp)::close

# else we are looking at a city in a continent

} else {

	set continent [lindex [split $nodename "-"] 1]
	set city [lindex [split $nodename "-"] 2]

}} tree2 {} {} sunken #3779fc284b24 #fefefe 1 n center l left_ptr false none {} {}} {button btnfill {240 50 340 90} {#
# perform these operations
# under the query that
# returns distinct continents
#
namespace eval DataControl(.ftree.qry) {

	# clear out the tree, starting at the root node
	drain .ftree.tr root
	
	# open the query to retrieve the continents
	open
	
	# fill up the tree with the names of the continents	
	fill .ftree.tr continent root

	# close the query
	close

}


# change the button label
.ftree.btnfill configure -text "Re-fill Tree"} {Fill Tree} {} {} raised #000000 #d9d9d9 1 n center l left_ptr false none {} {}} {query qry {250 20 270 40} qry_just_continents query4 {} {} flat #d9d9d9 #d9d9d9 1 n center l left_ptr false none {} {}} {label label5 {240 150 340 180} {} City city {} flat #000000 #d9d9d9 1 n center l left_ptr false none {} {}} {label label6 {240 190 340 220} {} Continent continent {} flat #000000 #d9d9d9 1 n center l left_ptr false none {} {}}');
-- PGA

            INSERT INTO pga_queries (querytype, querycommand, querytables, querylinks, queryresults, querycomments, queryname)
            VALUES ('S','select distinct continent from phonebook ','','','','
','qry_just_continents');
-- PGA

            INSERT INTO pga_queries (querytype, querycommand, querytables, querylinks, queryresults, querycomments, queryname)
            VALUES ('S','select t0."city", t0."continent" from "phonebook" t0 where t0."city"!=\' ','phonebook 10 10 t0','','city t0 unsorted {} Yes continent t0 unsorted {} Yes','

','qry_city_continents');
-- PGA
