Visual FoxPro datatype definition, thanks to Mirek Zvolsky
--HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4065
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<datatypes db="vfp9">
|
||||||
|
<group label="Keys" color="rgb(250,250,100)">
|
||||||
|
<type label="Integer" length="0" sql="INTEGER" quote=""/>
|
||||||
|
</group>
|
||||||
|
<group label="Numeric" color="rgb(255,255,200)">
|
||||||
|
<type label="Integer (not key)" length="0" sql="Integer" quote="" />
|
||||||
|
<type label="Numeric" length="1" sql="Numeric" quote="" />
|
||||||
|
<type label="Double" length="1" sql="Double" quote="" />
|
||||||
|
<type label="Float" length="1" sql="Float" quote="" />
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group label="Logical" color="rgb(100,100,255)">
|
||||||
|
<type label="Logical" length="0" sql="Logical" quote="'"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group label="Text short (NOCPTR->DEFAULT)" color="rgb(255,200,200)">
|
||||||
|
<type label="Character" length="1" sql="Character" quote="'"/>
|
||||||
|
<type label="Varchar" length="1" sql="Varchar" quote="'"/>
|
||||||
|
</group>
|
||||||
|
<group label="Text long (NOCPTR->DEFAULT)" color="rgb(255,150,150)">
|
||||||
|
<type label="Memo" length="0" sql="Memo" quote="'"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group label="Date/Time" color="rgb(150,255,150)">
|
||||||
|
<type label="Date" length="0" sql="Date" quote="'" />
|
||||||
|
<type label="Datetime" length="0" sql="Datetime" quote="'" />
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group label="Currency" color="rgb(200,100,255)">
|
||||||
|
<type label="Currency" length="0" sql="Currency" quote="'"/>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group label="Binary/Hexa" color="rgb(150,200,255)">
|
||||||
|
<type label="Varbinary" length="1" sql="Varbinary" quote="'"/>
|
||||||
|
<type label="Blob" length="0" sql="Blob" quote="'"/>
|
||||||
|
<type label="General" length="0" sql="General" quote="'"/>
|
||||||
|
</group>
|
||||||
|
</datatypes>
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
<?xml version="1.0" ?>
|
||||||
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
<xsl:output method="text"/>
|
||||||
|
|
||||||
|
<xsl:template name="replace-substring">
|
||||||
|
<xsl:param name="value" />
|
||||||
|
<xsl:param name="from" />
|
||||||
|
<xsl:param name="to" />
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains($value,$from)">
|
||||||
|
<xsl:value-of select="substring-before($value,$from)" />
|
||||||
|
<xsl:value-of select="$to" />
|
||||||
|
<xsl:call-template name="replace-substring">
|
||||||
|
<xsl:with-param name="value" select="substring-after($value,$from)" />
|
||||||
|
<xsl:with-param name="from" select="$from" />
|
||||||
|
<xsl:with-param name="to" select="$to" />
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$value" />
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="/sql">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- parameters/setting -->
|
||||||
|
<xsl:text>LPARAMETERS teLongName, tcCommand
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>* [teLongName] False: set llDbc=.F. and generates "FREE", Empty: generates without "FREE" and "NAME", otherwise generates "NAME teLongName"
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>* [tcCommand] if used, &tcCommand command will run after CREATE TABLE
|
||||||
|
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>LOCAL llDbc, lcFreeOrName, lnIndex
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>llDbc = VARTYPE( m.teLongName )=[C]
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>* True not supported yet: Improve db\vfp9\output.xsl and remove "xsl:if test=[1=2]" from it
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>lcFreeOrName = IIF( m.llDbc, IIF( EMPTY( m.teLongName ), [], [NAME "] + m.teLongName + ["] ), [FREE] )
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>lnIndex = IIF( VARTYPE( m.teIndex )=[L], 0, IIF( EMPTY( m.teIndex ), 1, 2 ) )
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- tables -->
|
||||||
|
<xsl:for-each select="table">
|
||||||
|
<xsl:text>ERASE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text>.dbf</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>ERASE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text>.fpt</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>ERASE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text>.cdx</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>ERASE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text>.bak</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>ERASE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text>.tbk</xsl:text>
|
||||||
|
<xsl:text>
|
||||||
|
|
||||||
|
</xsl:text>
|
||||||
|
|
||||||
|
<xsl:text>CREATE TABLE </xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text> &lcFreeOrName</xsl:text>
|
||||||
|
<xsl:text> ( ;
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:for-each select="row">
|
||||||
|
<xsl:text></xsl:text>
|
||||||
|
<xsl:value-of select="@name" />
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
|
||||||
|
<xsl:value-of select="datatype" />
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
|
||||||
|
<xsl:if test="@null = 0">
|
||||||
|
<xsl:text>NOT NULL </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="@null = 1">
|
||||||
|
<xsl:text>NULL </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:if test="@autoincrement = 1">
|
||||||
|
<xsl:text>AutoInc </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:if test="default">
|
||||||
|
<!-- VFP9 Support DEFAULT.., NOCPTRANS, ..<xsl:text>DEFAULT </xsl:text> -->
|
||||||
|
<xsl:value-of select="default" />
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:if test="1=2"> <!-- VFP9 no .dbc support yet -->
|
||||||
|
<xsl:if test="comment">
|
||||||
|
<xsl:text>COMMENT '</xsl:text>
|
||||||
|
<xsl:call-template name="replace-substring">
|
||||||
|
<xsl:with-param name="value" select="comment" />
|
||||||
|
<xsl:with-param name="from" select='"'"' />
|
||||||
|
<xsl:with-param name="to" select='"''"' />
|
||||||
|
</xsl:call-template>
|
||||||
|
<xsl:text>' </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:if> <!-- VFP9 no .dbc support yet -->
|
||||||
|
|
||||||
|
<xsl:if test="not (position()=last())">
|
||||||
|
<xsl:text>, ;
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="position()=last()">
|
||||||
|
<xsl:text> ;
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
<!-- keys -->
|
||||||
|
<xsl:if test="1=2"> <!-- VFP9 no .dbc support yet -->
|
||||||
|
<xsl:for-each select="key">
|
||||||
|
<xsl:text>,
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="@type = 'PRIMARY'">PRIMARY KEY (</xsl:when>
|
||||||
|
<xsl:when test="@type = 'FULLTEXT'">FULLTEXT KEY (</xsl:when>
|
||||||
|
<xsl:when test="@type = 'UNIQUE'">UNIQUE KEY (</xsl:when>
|
||||||
|
<xsl:otherwise>KEY (</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
<xsl:for-each select="part">
|
||||||
|
<xsl:text></xsl:text><xsl:value-of select="." /><xsl:text></xsl:text>
|
||||||
|
<xsl:if test="not (position() = last())">
|
||||||
|
<xsl:text>, </xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:for-each>
|
||||||
|
<xsl:text>)</xsl:text>
|
||||||
|
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
</xsl:if> <!-- VFP9 no .dbc support yet -->
|
||||||
|
<xsl:text>)
|
||||||
|
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:if test="1=2"> <!-- VFP9 no .dbc support yet -->
|
||||||
|
|
||||||
|
<xsl:if test="comment">
|
||||||
|
<xsl:text> COMMENT '</xsl:text>
|
||||||
|
<xsl:call-template name="replace-substring">
|
||||||
|
<xsl:with-param name="value" select="comment" />
|
||||||
|
<xsl:with-param name="from" select='"'"' />
|
||||||
|
<xsl:with-param name="to" select='"''"' />
|
||||||
|
</xsl:call-template>
|
||||||
|
<xsl:text>'</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
|
||||||
|
<xsl:text>;
|
||||||
|
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:if> <!-- VFP9 no .dbc support yet -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- VFP9 call command/function after table was created -->
|
||||||
|
<xsl:text>IF NOT EMPTY( m.tcCommand )
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text> &tcCommand
|
||||||
|
</xsl:text>
|
||||||
|
<xsl:text>ENDIF
|
||||||
|
|
||||||
|
</xsl:text>
|
||||||
|
<!-- VFP9 call command/function after table was created finished -->
|
||||||
|
|
||||||
|
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
<!-- fk -->
|
||||||
|
<xsl:if test="1=2"> <!-- VFP9 no .dbc support yet -->
|
||||||
|
<xsl:for-each select="table">
|
||||||
|
<xsl:for-each select="row">
|
||||||
|
<xsl:for-each select="relation">
|
||||||
|
<xsl:text>ALTER TABLE </xsl:text>
|
||||||
|
<xsl:value-of select="../../@name" />
|
||||||
|
<xsl:text> ADD FOREIGN KEY (</xsl:text>
|
||||||
|
<xsl:value-of select="../@name" />
|
||||||
|
<xsl:text>) REFERENCES </xsl:text>
|
||||||
|
<xsl:value-of select="@table" />
|
||||||
|
<xsl:text> (</xsl:text>
|
||||||
|
<xsl:value-of select="@row" />
|
||||||
|
<xsl:text>);
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:if> <!-- VFP9 no .dbc support yet -->
|
||||||
|
|
||||||
|
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
02.12.2009
|
||||||
|
vfp9 add-on for WwwSQLDesigner
|
||||||
|
by zvolsky@seznam.cz
|
||||||
|
|
||||||
|
|
||||||
|
Installation:
|
||||||
|
-------------
|
||||||
|
Download and install WwwSQLDesigner from http://code.google.com/p/wwwsqldesigner/
|
||||||
|
If there is no db\vfp9 folder, then continue:
|
||||||
|
|
||||||
|
Unzip files into db\vfp9 folder of the WwwSQLDesigner.
|
||||||
|
If you don't see vfp9 in database type selection, copy db\vfp9\readme_vfp9\config.js into js\config.js location.
|
||||||
|
After changing js\config.js you must restart.
|
||||||
|
Changes in db\vfp9\output.xsl take effect immediately.
|
||||||
|
To re-read db\vfp9\datatypes.xml you must make some (dummy) change in js\config.js and restart.
|
||||||
|
|
||||||
|
|
||||||
|
WwwSQLDesigner basics:
|
||||||
|
----------------------
|
||||||
|
To start click Index.html.
|
||||||
|
Never use Page Refresh (F5) - data will be lost!
|
||||||
|
Use Save button to generate FoxPro script with CREATE TABLEs.
|
||||||
|
Use Save/Read and Save XML buttons to generate XML and copy-paste it into text file to save your work.
|
||||||
|
Use Save/Read and Read XML buttons to continue work.
|
||||||
|
|
||||||
|
|
||||||
|
Use of VFP9 add-on:
|
||||||
|
-------------------
|
||||||
|
Textbox "Default" in Field adding has different meaning. Here you can enter all foxpro keywords, which follow field definition.
|
||||||
|
No word "DEFAULT" is added. To use some DEFAULT, write "DEFAULT value". If you let just "NULL" in Textbox "Default",
|
||||||
|
you will receive FoxPro error. Write "DEFAULT .NULL." if you want a default null value.
|
||||||
|
|
||||||
|
Data type "Integer (not key)" differents just in its color (but generates standard Integer)
|
||||||
|
|
||||||
|
Data types Binary aren't in list. They are supported through "Default" textbox. Write "NOCPTRANS" there.
|
||||||
|
|
||||||
|
|
||||||
|
There is (at this time - 02.12.2009) no support for .dbc (primary/foreign keys,..).
|
||||||
|
Plain CREATE TABLE commands are generated.
|
||||||
|
|
||||||
|
|
||||||
|
You can call VFP script with parameters. See generated script for details.
|
||||||
|
teLongName gives a possibility to genarate FREE or NAME keywords.
|
||||||
|
tcCommand can fire immediately after CREATE TABLE.
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
var CONFIG = {
|
var CONFIG = {
|
||||||
AVAILABLE_DBS:["mysql","sqlite","web2py","mssql","postgresql"],
|
AVAILABLE_DBS:["mysql","sqlite","web2py","mssql","postgresql", "oracle", "sqlalchemy", "vfp9"],
|
||||||
DEFAULT_DB:"mysql",
|
DEFAULT_DB:"mysql",
|
||||||
|
|
||||||
AVAILABLE_LOCALES:["en","fr","de","cs","pl","pt_BR","es", "ru","eo"],
|
AVAILABLE_LOCALES:["en","fr","de","cs","pl","pt_BR","es", "ru","eo"],
|
||||||
|
|||||||
Reference in New Issue
Block a user