Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generate TABLE from Code
Message
De
13/06/2007 11:41:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01232619
Message ID:
01232637
Vues:
13
>>>Hey Gang!
>>>
>>>I have a table called DW_HEADER.
>>>
>>>I want to create a text file (.PRG) so that when I run it in VFP, it creates the TABLE.
>>>
>>>So.................
>>>
>>>Any tools that can READ the already created table, and create the text file, with the commands in it, to CREATE the table later from the master program? (And no, there is no database container for this project... sigh.)
>>>
>>>Thanks!
>>
>>Afields()?
>>Cetin
>
>I will take a look at it.
>
>I was wanting something that could be run on a table, and create a PRG with the CREATE TABLE command with the field structure in it ready to run.
>
>Thanks!

For that what I do is to use 2 prgs (CreateDictionary and RestoreFromDictionary):
CreateDictionary part is:
Create cursor crsSTRUCTS ;
	(FIELD_NAME C(128) nocptrans, ;
	FIELD_TYPE C(1), ;
	FIELD_LEN N(3, 0), ;
	FIELD_DEC N(3, 0), ;
	FIELD_NULL L, ;
	FIELD_NOCP L, ;
	_TABLENAME M nocptrans)
Create cursor crsINDEXES ;
	(TAG_NAME C(10) nocptrans, ;
	KEY_EXPR M, ;
	NDXTYPE C(1), ;
	IS_DESC L, ;
	FILTEREXPR M nocptrans, ;
	_TABLENAME M nocptrans)
Select 0
lnTables = adir(arrTables,tcDataDir+'*.dbf')
For ix=1 to lnTables
	Use (tcDataDir+arrTables[ix,1])
	if empty(cursorgetprop('Database'))
		lnFields=afields(arrStruc)
		For jx=1 to lnFields
			arrStruc[jx,7]=arrTables[ix,1]
		Endfor
		Insert into crsSTRUCTS from array arrStruc
		Release arrStruc
		If tagcount()>0
			Dimension arrIndexes[tagcount(),6]
			For jx=1 to tagcount()
				arrIndexes[jx,1] = tag(jx)
				arrIndexes[jx,2] = key(jx)
				arrIndexes[jx,3] = iif(Primary(jx),'P',iif(Candidate(jx),'C',iif(unique(jx),'U','R')))
				arrIndexes[jx,4] = descending(jx)
				arrIndexes[jx,5] = sys(2021,jx)
				arrIndexes[jx,6] = arrTables[ix,1]
			Endfor
			Insert into crsINDEXES from array arrIndexes
		Endif
	endif
	Use
Endfor
Select crsSTRUCTS
Copy to (tcDicDir+'NewStruc')
Select crsINDEXES
Copy to (tcDicDir+'NewIndexes')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform