ad_sql_get

one of the documented procedures in this installation of the ACS
Usage:
ad_sql_get { } sqlarrayname
What it does:
Returns the SQL statement as a string
Defined in: /web/philip/packages/acs-core/sql-statement-procs.tcl

Source code:

arg_parser_for_ad_sql_get $args

    upvar $sqlarrayname sql

    if { ![info exists sql(select)] } {
	error "SQL statement doesn't have any SELECT clause"
    }
    if { ![info exists sql(from)] } {
	error "SQL statement doesn't have any FROM clause"
    }

    set sql_string "select [join $sql(select) ", "]\nfrom [join $sql(from) ", "]\n"
    
    if { [info exists sql(where)] && [llength $sql(where)] > 0 } {
	append sql_string "where [join $sql(where) "\nand "]\n"
    }
    
    if { [info exists sql(groupby)] && [llength $sql(groupby)] > 0 } {
	append sql_string "group by [join $sql(groupby) ", "]\n"
    }
    
    if { [info exists sql(orderby)] && [llength $sql(orderby)] > 0 } { 
	append sql_string "order by [join $sql(orderby) ", "]\n"
    }

    return $sql_string


philg@mit.edu