# $Header: /home/cvsroot/tcldb/ucodb/Tlib/dataHelp,v 1.1.1.1 1996/10/12 01:08:25 de Exp $
# tcl procs saved on Sun Sep 03 16:18:58 PDT 1995

proc dataHelp {table fld} {
	

	global dictionary
#	global datahelping

#	set datahelping 1

	if {$fld == ""} {set fld "TABLEDEF"}

#	The ddict format was changed on Jan 20 1994, so that base, owner
#	and table are separate fields (dbase, owner, tbln).  We ignore
#	dbase at this point, because of the unique nomenclature of our
#	tables.  We assume dbo if no owner is specified.  We could at
#	some future date insist on FQ object names and use the base
#	value as well.  

	set base ""
	set temp [split $table .]
	case [llength $temp] in {
	{3} {
		lassign $temp base owner table
	}
	{2} {
		lassign $temp owner table
	}
	{1} {
		set table $temp
		set owner "dbo"
	}
	}

	if {$dictionary == "NONE"} {
		set title "No Dictionary"
		set text "Sorry, there is no Data Dictionary."
	} else {

	set sqlcmd "select ddesc from $dictionary where ((owner = '$owner' and tbln = '$table') or tbln = 'ANYTABLE') and fldn = '$fld'"

	set sqt "$dictionary"
	
	set res [doSQL 1]
	if {[lindex $res 0] == "ERROR"} {
		echo "Serious problem here"
		echo "$sqlcmd"
		echo "$res"
		exit 1
	}

	set text "[stringFix [sybNext 1]]"

	set hdr "Table $table - Field $fld"

	if {$text == ""} {	
		set title "No Dictionary Info"
		set text "Sorry, there is no Data Dictionary entry for table $table, field $fld in the dictionary table $dictionary."
	} else {
		set title "Data Dictionary Info"
	}

	}

	
	dictDisp "$title" "$text" "Done" l "$hdr"

}

