home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # 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 : @(#)serial_utl.tcl /main/hindenburg/3
- # Author : peku
- # Original date : 28-7-1993
- # Description : procedures to support the serial data type
- #
- #---------------------------------------------------------------------------
- #
- # @(#)serial_utl.tcl /main/hindenburg/3 26 May 1997 Copyright 1992-1995 Cadre Technologies Inc.
- #
- #---------------------------------------------------------------------------
-
-
- #---------------------------------------------------------------------------
- #
- # PROCEDURES TO SUPPORT MAPPING OF TYPE "serial" TO "integer" WHEN NEEDED
- #
- #---------------------------------------------------------------------------
-
- # Is 'type' serial?
- #
- proc is_serial {type} {
- return [regexp -nocase {^ *serial( *\( *[0-9]+ *\))?} $type]
- }
-
- global get_type_4gl
- set get_type_4gl get_inf_type_4gl
-
- # The "normal" way to get the 4gl type. Always does the mapping
- #
- proc get_inf_type_4gl {column} {
- set type [get_type_4gl $column]
- if [is_serial $type] {
- return INTEGER
- }
- return $type
- }
-
- # A special variant of get_type_4gl for create table statements. Type "serial"
- # is mapped to integer for all imported columns
- #
- proc get_table_type {column} {
- if {[$column get_obj_type] == "column"} {
- return [get_type_4gl $column]
- }
- return [get_inf_type_4gl $column]
- }
-
- # find the serial column
-
- proc get_serial_column_name {table} {
- foreach col [ $table columnSet] {
- set col_type [get_table_type $col]
- if [is_serial $col_type] {
- return [$col getUniqueName]
- }
- }
- return ""
- }
-
- # update the data field which is a serial in the base class
-
- proc call_for_all_bases_set_serial {class sect} {
- set supers [$class genNodeSet]
- if [lempty $supers] {
- return
- }
- $sect indent +
- foreach super $supers {
- set superClass [$super superClass]
- if {![$superClass isPersistent]} {
- continue
- }
- set table [$superClass table]
- set serial_name [get_serial_column_name $table]
- if {$serial_name == ""} {
- continue
- }
- set name [$super getSuperClassName]
- expand_text $sect {
- data.~$serial_name = ~$name::data.~$serial_name;
- }
- }
- $sect indent -
- }
-
-