You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
7.6 KiB
234 lines
7.6 KiB
<?xml version="1.0" encoding="UTF-8" ?> |
|
<xsl:stylesheet version="1.0" |
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|
<xsl:template name="sx_field"> |
|
<xsl:param name="dbsystem"/> |
|
<xsl:value-of select="@name" /><xsl:text> </xsl:text> |
|
<xsl:choose> |
|
|
|
<xsl:when test="contains(@type,'SERIAL') or contains(@type,'serial')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='HSQLDB'"> |
|
<xsl:text>identity</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'DOUBLE') or contains(@type,'double')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>double precision</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<xsl:text>float</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'DATETIME') or contains(@type,'datetime')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>timestamptz</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<xsl:text>datetime year to second</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'LONG') or contains(@type,'long')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>int8</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<xsl:text>long</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'BIGINT') or contains(@type,'bigint')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<!--postgres kennt zwar auch bigint, aber dbconv nicht--> |
|
<xsl:text>int8</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<xsl:text>int8</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'NVARCHAR') or contains(@type,'nvarchar')"> |
|
|
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<!--postgres unterstützt kein nvarchar--> |
|
<xsl:text>varchar</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="contains(@type,'DATETIME') or contains(@type,'datetime')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>timestamptz</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<xsl:text>datetime year to second</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="@type='LVARCHAR' or @type='lvarchar'"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>text</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="$dbsystem='INFORMIX'"> |
|
<!--unter informix muss lvarchar eine Größenangabe haben, sonst gehen nur max. 2048 Zeichen--> |
|
<xsl:text>lvarchar</xsl:text><xsl:if test="@size != ''"><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text></xsl:if> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
|
|
<xsl:when test="@type='CHAR' or @type='char'"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='INFORMIX' and @size > 50"> |
|
<!--wegen Sortierung längerer Textfelder unter informix--> |
|
<xsl:value-of select="'NCHAR'" /><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
|
|
<xsl:when test="contains(@type,'VARCHAR') or contains(@type,'varchar')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='INFORMIX' and @size > 50"> |
|
<!--wegen Sortierung längerer Textfelder unter informix--> |
|
<xsl:value-of select="'NVARCHAR'" /><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text> |
|
</xsl:when> |
|
<xsl:when test="@size = ''"> |
|
<xsl:value-of select="@type" /> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
|
|
</xsl:when> |
|
<xsl:when test="contains(@type,'TEXT') or contains(@type,'text')"> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='HSQLDB'"> |
|
<!-- längere Textfelder unter hsqldb--> |
|
<xsl:value-of select="'VARCHAR'" /><xsl:text>(32000)</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /><xsl:text></xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
|
|
</xsl:when> |
|
<xsl:when test="contains(@type,'DECIMAL') or contains(@type,'decimal') or contains(@type,'NUMERIC') or contains(@type,'numeric')"> |
|
<xsl:text>decimal</xsl:text><xsl:value-of select="@size" /><xsl:text></xsl:text> |
|
</xsl:when> |
|
<xsl:when test="@type='DISKBLOB' or @type='diskblob'"> |
|
<xsl:value-of select="'char'" /><xsl:text>(</xsl:text><xsl:value-of select="@size" /><xsl:text>)</xsl:text> |
|
|
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@type" /> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
|
|
|
|
<xsl:text> </xsl:text> |
|
<xsl:if test="@default != '' and (@type !='SERIAL' or @type !='serial')"> |
|
<xsl:text> default </xsl:text> |
|
<xsl:choose> |
|
<xsl:when test="@type ='CHAR' or @type ='VARCHAR' or @type ='TEXT' or @type ='char' or @type ='varchar' or @type ='text' or @type ='nvarchar' or @type ='nchar' or @type ='NVARCHAR' or @type ='NCHAR'"> |
|
<xsl:text>'</xsl:text><xsl:value-of select="@default" /><xsl:text>' </xsl:text> |
|
</xsl:when> |
|
<xsl:when test="@type ='date' or @type ='DATE' "> |
|
<xsl:choose> |
|
<xsl:when test="contains(@default,'today()') and $dbsystem='INFORMIX'"> |
|
<xsl:value-of select="'TODAY'" /> |
|
</xsl:when> |
|
<xsl:when test="contains(@default,'()')"> |
|
<!--Wenn Funktionsname, dann kein date( davor--> |
|
<xsl:value-of select="@default" /> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:choose> |
|
<xsl:when test="$dbsystem='POSTGRES'"> |
|
<xsl:text>date('</xsl:text><xsl:value-of select="@default" /><xsl:text>') </xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:text>'</xsl:text><xsl:value-of select="@default" /><xsl:text>' </xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:when test="(@type ='TIMESTAMP' or @type ='timestamp') and $dbsystem='POSTGRES'"> |
|
<xsl:choose> |
|
<xsl:when test="contains(@default,'CURRENT_TIMESTAMP')"> |
|
<xsl:value-of select="'CURRENT_TIMESTAMP'" /> |
|
</xsl:when> |
|
<xsl:when test="contains(@default,'HIGHEST_TIMESTAMP')"> |
|
<xsl:text>'2999-12-31 23:59:59'</xsl:text> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:text>date('</xsl:text><xsl:value-of select="@default" /><xsl:text>') </xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:when> |
|
<xsl:otherwise> |
|
<xsl:value-of select="@default" /><xsl:text> </xsl:text> |
|
</xsl:otherwise> |
|
</xsl:choose> |
|
</xsl:if> |
|
|
|
<xsl:if test="@notnull='true'"> |
|
<xsl:text> not null</xsl:text> |
|
</xsl:if> |
|
|
|
<xsl:if test="position() < last()"> |
|
<xsl:text>, |
|
</xsl:text> |
|
</xsl:if> |
|
|
|
</xsl:template> |
|
<xsl:template name="drop_sequence"> |
|
<xsl:if test="$sx_client = 'psql' "> |
|
<!--<xsl:text>drop index </xsl:text>-<xsl:value-of select="type" /><xsl:text>- |
|
</xsl:text>--> |
|
<xsl:if test="contains(type, 'serial')"> |
|
<xsl:text>drop sequence </xsl:text> <xsl:value-of select="concat(../name,'_',name,'_seq')" /> |
|
<xsl:text>; |
|
</xsl:text> |
|
</xsl:if> |
|
</xsl:if> |
|
|
|
|
|
</xsl:template> |
|
</xsl:stylesheet>
|
|
|