home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
gensqlomt.tcl
< prev
next >
Wrap
Text File
|
1996-06-05
|
3KB
|
117 lines
#---------------------------------------------------------------------------
#
# Copyright (c) 1993-1995 by Cadre Technologies Inc.
#
# This software is furnished under a license and may be used only in
# accordance with the terms of such license and with the inclusion of
# the above copyright notice. This software or any other copies thereof
# may not be provided or otherwise made available to any other person.
# No title to and ownership of the software is hereby transferred.
#
# The information in this software is subject to change without notice
# and should not be construed as a commitment by Cadre Technologies Inc.
#
#---------------------------------------------------------------------------
#
# File : @(#)gensqlomt.tcl 2.1
# Author : frmo
# Original date : 27-7-1993
# Description : OMT specific target independent gensql procedures
#
#---------------------------------------------------------------------------
#
proc gensql_omt {} {
global model oomodel
set tgt_files {
create.sql_script create_procs.sql_script
create_tables.sql_script drop.sql_script drop_procs.sql_script
drop_tables.sql_script
}
set cc [ClientContext::global]
set proj [$cc currentProject]
set configV [$cc currentConfig]
set phaseV [$cc currentPhase]
set systemV [$cc currentSystem]
if {![$proj isNil] } {
set projName [$proj name]
}
if {![$configV isNil] } {
set configName [[$configV config] name]
}
if {![$phaseV isNil] } {
set phaseName [[$phaseV phase] name]
}
if {![$systemV isNil] } {
set systemName [[$systemV system] name]
}
foreach tgt $tgt_files {
# Can't do this test since after import-new new persistent
# classes may be present which cause most of these scripts
# to be invalid.
#
# if {($import_new && [fstorage::exists $tgt])}
if {$import_sel && [lsearch [get_tgt_objs] $tgt] == -1} {
continue
}
set name [nt_get_name $tgt]
set sect [TextSection new]
expand_file $sect [m4_path_name etc $name.hdr] filename $name \
proj $proj \
configV [$configV versionNumber] \
phaseV [$phaseV versionNumber]\
systemV [$systemV versionNumber]\
projName $projName \
configName $configName \
phaseName $phaseName \
systemName $systemName
$sect append "\n"
gensql_for_$name $sect
# this will only work if name.hdr is constant:
#
if [section_equals_file $sect $tgt] {
puts "$tgt has not changed: file not written"
continue
}
if {[M4CheckManager::getErrorCount] > 0} {
puts "Not saving $tgt because of previous errors"
continue
}
m4_message $M_CREATE_FILE $tgt
if [catch {set fd [fstorage::open $tgt w]} reason] {
puts stderr $reason
m4_error $E_UNABLE_OPEN_WRITE $tgt
continue
}
$sect write $fd
fstorage::close $fd
}
}
proc gensql_for_drop {sect} {
expand_text $sect {
\~[@include drop_procs sql_script]
\~[@include drop_tables sql_script]
}
}
proc gensql_for_create {sect} {
expand_text $sect {
\~[@include create_tables sql_script]
\~[@include create_procs sql_script]
}
}