mpoeschl    2002/09/26 07:28:35

  Modified:    src/templates/sql/base/db2 columns.vm db.props drop.vm
                        foreignkey.vm primarykey.vm
  Log:
  TRQS1: several small patches to correct db2 sql generation
  patch by J. Russell Smyth
  i don't have db2 to test the patches, so feddback from db2 users would be great!
  
  Revision  Changes    Path
  1.2       +9 -2      jakarta-turbine-torque/src/templates/sql/base/db2/columns.vm
  
  Index: columns.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/base/db2/columns.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- columns.vm        2 Aug 2001 05:08:39 -0000       1.1
  +++ columns.vm        26 Sep 2002 14:28:35 -0000      1.2
  @@ -1,10 +1,17 @@
   #foreach ($col in $table.Columns)
       #set ( $type = $dbprops.get($col.Type) )
       #set ( $size = $col.printSize() )
  +    #set ( $rawsize = $col.Size )
  +    #set ( $torquetype = $col.TorqueType )
       #set ( $default = $col.DefaultSetting )
       #set ( $autoIncrement = $strings.select($col.isAutoIncrement(), 
$dbprops.get("AUTOINCREMENT"),"") )
       #set ( $nullString = $strings.select($col.isNotNull(), 
$dbprops.get("NOTNULL"),"") )
  -    #set ( $nullString = $strings.select($col.isAutoIncrement(), "", 
$dbprops.get("NOTNULL")) )
  -    #set ( $entry = "$col.Name $type $size $default $nullString $autoIncrement," )
  +    #if ( $torquetype == "BINARY" )
  +        #set ( $entry = "$col.Name CHAR($rawsize) FOR BIT DATA $type $size $default 
$nullString $autoIncrement," )
  +    #elseif ( $torquetype == "VARBINARY" )
  +        #set ( $entry = "$col.Name VARCHAR($rawsize) FOR BIT DATA $type $size 
$default $nullString $autoIncrement," )
  +    #else
  +        #set ( $entry = "$col.Name $type $size $default $nullString 
$autoIncrement," )
  +    #end
       $strings.sub($strings.collapseSpaces($entry)," ,",",")
   #end
  
  
  
  1.5       +4 -4      jakarta-turbine-torque/src/templates/sql/base/db2/db.props
  
  Index: db.props
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/base/db2/db.props,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- db.props  5 Sep 2002 12:46:05 -0000       1.4
  +++ db.props  26 Sep 2002 14:28:35 -0000      1.5
  @@ -13,14 +13,14 @@
   DECIMAL = DECIMAL
   CHAR = VARCHAR
   VARCHAR = VARCHAR
  -LONGVARCHAR = VARCHAR
  +LONGVARCHAR = LONG VARCHAR
   DATE = DATE
   TIME = TIME
   TIMESTAMP = TIMESTAMP
  -BINARY = 
  +BINARY = CHAR(n) FOR BIT DATA 
   # For DB2/400, VARBINARY must be changed to VARCHAR (32000) FOR BIT DATA
  -VARBINARY = 
  -LONGVARBINARY =
  +VARBINARY = VARCHAR(n) FOR BIT DATA 
  +LONGVARBINARY = LONG VARCHAR FOR BIT DATA
   NULL = NULL
   OTHER =
   JAVA_OBJECT =
  
  
  
  1.2       +5 -1      jakarta-turbine-torque/src/templates/sql/base/db2/drop.vm
  
  Index: drop.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/base/db2/drop.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- drop.vm   2 Aug 2001 05:08:39 -0000       1.1
  +++ drop.vm   26 Sep 2002 14:28:35 -0000      1.2
  @@ -1,2 +1,6 @@
   drop table $table.Name;
  -drop sequence if exists $table.SequenceName;
  +#set ($seqName = "~~novalue~~")
  +#set ($seqName = $table.SequenceName)
  +#if(!$seqName == "~~novalue~~")
  +drop sequence $seqName restrict;
  +#end
  
  
  
  1.3       +1 -2      jakarta-turbine-torque/src/templates/sql/base/db2/foreignkey.vm
  
  Index: foreignkey.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/base/db2/foreignkey.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- foreignkey.vm     22 Aug 2001 20:14:15 -0000      1.2
  +++ foreignkey.vm     26 Sep 2002 14:28:35 -0000      1.3
  @@ -2,6 +2,5 @@
   ALTER TABLE $table.Name
       ADD CONSTRAINT $fk.Name FOREIGN KEY ($fk.LocalColumnNames)
       REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)
  -USING INDEX;
  -
  +;
   #end
  
  
  
  1.2       +1 -2      jakarta-turbine-torque/src/templates/sql/base/db2/primarykey.vm
  
  Index: primarykey.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/sql/base/db2/primarykey.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- primarykey.vm     2 Aug 2001 05:08:39 -0000       1.1
  +++ primarykey.vm     26 Sep 2002 14:28:35 -0000      1.2
  @@ -1,3 +1,2 @@
   ALTER TABLE $table.Name
  -    ADD CONSTRAINT ${table.Name}_PK 
  -PRIMARY KEY ($table.printPrimaryKey());
  +    ADD PRIMARY KEY ($table.printPrimaryKey());
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to