fixes for vfp9 db definition

--HG--
extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4066
This commit is contained in:
ondrej.zara
2009-12-07 17:51:53 +00:00
parent 363733c69b
commit 6c950e043d
3 changed files with 130 additions and 115 deletions
+39 -39
View File
@@ -1,39 +1,39 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<datatypes db="vfp9"> <datatypes db="vfp9">
<group label="Keys" color="rgb(250,250,100)"> <group label="Keys" color="rgb(250,250,100)">
<type label="Integer" length="0" sql="INTEGER" quote=""/> <type label="Integer" length="0" sql="INTEGER" quote=""/>
</group> </group>
<group label="Numeric" color="rgb(255,255,200)"> <group label="Numeric" color="rgb(255,255,200)">
<type label="Integer (not key)" length="0" sql="Integer" quote="" /> <type label="Integer (not key)" length="0" sql="Integer" quote="" />
<type label="Numeric" length="1" sql="Numeric" quote="" /> <type label="Numeric" length="1" sql="Numeric" quote="" />
<type label="Double" length="1" sql="Double" quote="" /> <type label="Double" length="1" sql="Double" quote="" />
<type label="Float" length="1" sql="Float" quote="" /> <type label="Float" length="1" sql="Float" quote="" />
</group> </group>
<group label="Logical" color="rgb(100,100,255)"> <group label="Logical" color="rgb(100,100,255)">
<type label="Logical" length="0" sql="Logical" quote="'"/> <type label="Logical" length="0" sql="Logical" quote="'"/>
</group> </group>
<group label="Text short (NOCPTR->DEFAULT)" color="rgb(255,200,200)"> <group label="Text short (NOCPTR->DEFAULT)" color="rgb(255,200,200)">
<type label="Character" length="1" sql="Character" quote="'"/> <type label="Character" length="1" sql="Character" quote="'"/>
<type label="Varchar" length="1" sql="Varchar" quote="'"/> <type label="Varchar" length="1" sql="Varchar" quote="'"/>
</group> </group>
<group label="Text long (NOCPTR->DEFAULT)" color="rgb(255,150,150)"> <group label="Text long (NOCPTR->DEFAULT)" color="rgb(255,150,150)">
<type label="Memo" length="0" sql="Memo" quote="'"/> <type label="Memo" length="0" sql="Memo" quote="'"/>
</group> </group>
<group label="Date/Time" color="rgb(150,255,150)"> <group label="Date/Time" color="rgb(150,255,150)">
<type label="Date" length="0" sql="Date" quote="'" /> <type label="Date" length="0" sql="Date" quote="'" />
<type label="Datetime" length="0" sql="Datetime" quote="'" /> <type label="Datetime" length="0" sql="Datetime" quote="'" />
</group> </group>
<group label="Currency" color="rgb(200,100,255)"> <group label="Currency" color="rgb(200,100,255)">
<type label="Currency" length="0" sql="Currency" quote="'"/> <type label="Currency" length="0" sql="Currency" quote="'"/>
</group> </group>
<group label="Binary/Hexa" color="rgb(150,200,255)"> <group label="Binary/Hexa" color="rgb(150,200,255)">
<type label="Varbinary" length="1" sql="Varbinary" quote="'"/> <type label="Varbinary" length="1" sql="Varbinary" quote="'"/>
<type label="Blob" length="0" sql="Blob" quote="'"/> <type label="Blob" length="0" sql="Blob" quote="'"/>
<type label="General" length="0" sql="General" quote="'"/> <type label="General" length="0" sql="General" quote="'"/>
</group> </group>
</datatypes> </datatypes>
+49 -31
View File
@@ -26,22 +26,26 @@
<!-- parameters/setting --> <!-- parameters/setting -->
<xsl:text>LPARAMETERS teLongName, tcCommand <xsl:text>LPARAMETERS teLongName, tcCommand, tcPath
</xsl:text> </xsl:text>
<xsl:text>* [teLongName] False: set llDbc=.F. and generates "FREE", Empty: generates without "FREE" and "NAME", otherwise generates "NAME teLongName" <xsl:text>* [teLongName] False: set llDbc=.F. and generates "FREE", Empty: generates without "FREE" and "NAME", otherwise generates "NAME teLongName"
</xsl:text> </xsl:text>
<xsl:text>* [tcCommand] if used, &amp;tcCommand command will run after CREATE TABLE <xsl:text>* [tcCommand] if used, &amp;tcCommand command will run after CREATE TABLE, f.e. "= MyProc( ALIAS(), m.lcTableComment, @lacComments )"
</xsl:text>
<xsl:text>* [tcPath] path where tables will be created (if not used, tables will be created in current folder)
</xsl:text> </xsl:text>
<xsl:text>LOCAL llDbc, lcFreeOrName, lnIndex <xsl:text>LOCAL ARRAY lacComments[1,2]
</xsl:text>
<xsl:text>LOCAL llDbc, lcFreeOrName, lcTableComment
</xsl:text> </xsl:text>
<xsl:text>llDbc = VARTYPE( m.teLongName )=[C] <xsl:text>llDbc = VARTYPE( m.teLongName )=[C]
</xsl:text> </xsl:text>
<xsl:text>* True not supported yet: Improve db\vfp9\output.xsl and remove "xsl:if test=[1=2]" from it <xsl:text> * no special support for llDbc=True yet (you could improve db\vfp9\output.xsl and remove "xsl:if test=[1=2]" from it)
</xsl:text> </xsl:text>
<xsl:text>lcFreeOrName = IIF( m.llDbc, IIF( EMPTY( m.teLongName ), [], [NAME "] + m.teLongName + ["] ), [FREE] ) <xsl:text>lcFreeOrName = IIF( m.llDbc, IIF( EMPTY( m.teLongName ), [], [NAME "] + m.teLongName + ["] ), [FREE] )
</xsl:text> </xsl:text>
<xsl:text>lnIndex = IIF( VARTYPE( m.teIndex )=[L], 0, IIF( EMPTY( m.teIndex ), 1, 2 ) ) <xsl:text>tcPath = IIF( VARTYPE( m.tcPath )=[L], [], ADDBS( m.tcPath ) )
</xsl:text> </xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
@@ -49,36 +53,36 @@
<!-- tables --> <!-- tables -->
<xsl:for-each select="table"> <xsl:for-each select="table">
<xsl:text>ERASE </xsl:text> <xsl:text>ERASE '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text>.dbf</xsl:text> <xsl:text>.dbf'</xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:text>ERASE </xsl:text> <xsl:text>ERASE '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text>.fpt</xsl:text> <xsl:text>.fpt'</xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:text>ERASE </xsl:text> <xsl:text>ERASE '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text>.cdx</xsl:text> <xsl:text>.cdx'</xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:text>ERASE </xsl:text> <xsl:text>ERASE '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text>.bak</xsl:text> <xsl:text>.bak'</xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:text>ERASE </xsl:text> <xsl:text>ERASE '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text>.tbk</xsl:text> <xsl:text>.tbk'</xsl:text>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:text>CREATE TABLE </xsl:text> <xsl:text>CREATE TABLE (m.tcPath + '</xsl:text>
<xsl:value-of select="@name" /> <xsl:value-of select="@name" />
<xsl:text> &amp;lcFreeOrName</xsl:text> <xsl:text>') &amp;lcFreeOrName</xsl:text>
<xsl:text> ( ; <xsl:text> ( ;
</xsl:text> </xsl:text>
<xsl:for-each select="row"> <xsl:for-each select="row">
@@ -102,7 +106,8 @@
<xsl:if test="default"> <xsl:if test="default">
<!-- VFP9 Support DEFAULT.., NOCPTRANS, ..<xsl:text>DEFAULT </xsl:text> --> <!-- VFP9 Support DEFAULT.., NOCPTRANS, ..<xsl:text>DEFAULT </xsl:text> -->
<xsl:value-of select="default" /> <xsl:variable name="cdefault" select="default"/>
<xsl:value-of select="substring($cdefault,2,string-length($cdefault)-2)" />
<xsl:text> </xsl:text> <xsl:text> </xsl:text>
</xsl:if> </xsl:if>
@@ -154,26 +159,39 @@
<xsl:text>) <xsl:text>)
</xsl:text> </xsl:text>
<xsl:if test="1=2"> <!-- VFP9 no .dbc support yet --> <xsl:text>lcTableComment = '</xsl:text>
<xsl:call-template name="replace-substring">
<xsl:with-param name="value" select="comment" />
<xsl:with-param name="from" select='"&apos;"' />
<xsl:with-param name="to" select='"&apos;&apos;"' />
</xsl:call-template>
<xsl:text>'
</xsl:text>
<xsl:if test="comment">
<xsl:text> COMMENT '</xsl:text> <!-- VFP9 call command/function after table was created -->
<xsl:text>DIMENSION lacComments[FCOUNT(),2]
</xsl:text>
<xsl:for-each select="row">
<xsl:text> lacComments[</xsl:text>
<xsl:value-of select="position()" />
<xsl:text>,1] = '</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>'
</xsl:text>
<xsl:text> lacComments[</xsl:text>
<xsl:value-of select="position()" />
<xsl:text>,2] = '</xsl:text>
<xsl:call-template name="replace-substring"> <xsl:call-template name="replace-substring">
<xsl:with-param name="value" select="comment" /> <xsl:with-param name="value" select="comment" />
<xsl:with-param name="from" select='"&apos;"' /> <xsl:with-param name="from" select='"&apos;"' />
<xsl:with-param name="to" select='"&apos;&apos;"' /> <xsl:with-param name="to" select='"&apos;&apos;"' />
</xsl:call-template> </xsl:call-template>
<xsl:text>'</xsl:text> <xsl:text>'
</xsl:if> </xsl:text>
</xsl:for-each>
<xsl:text>; <xsl:text>
</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>IF NOT EMPTY( m.tcCommand )
</xsl:text> </xsl:text>
<xsl:text> &amp;tcCommand <xsl:text> &amp;tcCommand
+42 -45
View File
@@ -1,45 +1,42 @@
02.12.2009 07.12.2009
vfp9 add-on for WwwSQLDesigner vfp9 support for WwwSQLDesigner
by zvolsky@seznam.cz by zvolsky@seznam.cz
Installation: Installation:
------------- -------------
Download and install WwwSQLDesigner from http://code.google.com/p/wwwsqldesigner/ vfp9 support is standard part of WwwSQLDesigner - simple choose database vfp9 in Settings.
If there is no db\vfp9 folder, then continue:
You can change the generated script by patch/replace of db\vfp9\output.xsl.
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. WwwSQLDesigner basics:
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. To start click Index.html.
Never use Page Refresh (F5) - data will be lost!
Use Save button to generate FoxPro script with CREATE TABLEs.
WwwSQLDesigner basics: 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.
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 of VFP9 support:
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. 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." instead.
Use of VFP9 add-on:
------------------- Data types Binary aren't in list. Use standard Varchar, Character, Memo instead and write "NOCPTRANS" into the "Default" textbox.
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", Data type "Integer (not key)" differents (from the primary/foreign key) just in its color (but generates standard Integer).
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)
Generated VFP script contains (optional) parameters, which change behavior of CREATE TABLE commands:
Data types Binary aren't in list. They are supported through "Default" textbox. Write "NOCPTRANS" there. teLongName gives a possibility to generate FREE or NAME keywords.
tcCommand can fire immediately after each CREATE TABLE (new table is selected).
F.e. "= MyProc( ALIAS(), m.lcTableComment, @lacComments )" gives access to alias and all comments from model inside MyProc() procedure.
There is (at this time - 02.12.2009) no support for .dbc (primary/foreign keys,..). tcPath can control path, where tables will be created.
Plain CREATE TABLE commands are generated.
Comments aren't copied directly into target database.
Instead of this, they are prepared in lcTableComment variable (table comment) and in lacComments array (field comments) before &tcCommand call.
You can call VFP script with parameters. See generated script for details. So you can work with comments in your user defined code as you want.
teLongName gives a possibility to genarate FREE or NAME keywords.
tcCommand can fire immediately after CREATE TABLE.
-------------------------------------------------------------------------------------------------------------------------