Re: storing table info in tables

2007-01-07 Thread Chet Gardiner
If I understand your request, you want to build a table of column names, 
types, lengths, etc. for a bunch of free tables in order to rebuild them.

Ed was correct, your best bet is to use AFIELDS() to get an array of 
field information.

You can then store the array into a structures' table along with each 
table name.  When recreating, load an array from the table and then use 
CREATE TABLE xxx  FROM ARRAY yyy  as Ed indicated.

It gets tricky if you need to save table information for more than one 
version of VFP -- they array structure has changed over the versions.  
No problem if you just want to operate in one version.

For Instance, VFP 9 AFIELDS() creates an array of 18 elements.  The 
first 4 are important, the rest can be set to their default values...

Good luck;

Chet


Jeff wrote:

>I need to be able to recreate free tables using information stored in 
>tables. I know how to create tables using SQL statements but how 
>would I pull the field [column - hate that about VFP!] information 
>[column name, type, character/column length,... - all stored for 
>reporting] to create a new table?
>
>jeff fisher, MCP
>www.turbofish.com 
>
>
>
[excessive quoting removed by server]

___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.


Re: storing table info in tables

2007-01-07 Thread Ted Roche
On 1/7/07, Jeff <[EMAIL PROTECTED]> wrote:
> I need to be able to recreate free tables using information stored in
> tables. I know how to create tables using SQL statements but how
> would I pull the field [column - hate that about VFP!] information
> [column name, type, character/column length,... - all stored for
> reporting] to create a new table?
>

How about COPY STRUCTURE EXTENDED?

-- 
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com


___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.


RE: storing table info in tables

2007-01-07 Thread Sietse Wijnker
Hi Jeff,

You can use SAVE TO MEMO to store any variables into a memo field
So if you have a tblDefinitions table that has a cName and a mStruct field
You can do the following to fill the table:

LOCAL laFields[1]
SELECT 0
USE tblSource1
AFIELDS(laFields, "tblSource1")
SELECT tblDefinitions
INSERT INTO tblDefinitions (cName) VALUES ("tblSource1")
SAVE TO MEMO tblDefinitions.mStruct ALL LIKE laFields


To recreate the tables defined in the tblDefinitions:
CLOSE TABLES ALL
LOCAL lcName
USE tblDefinitions
SCAN
lcName = ALLTRIM(tblDefinitions.cName)
RESTORE FROM MEMO tblDefinitions.mStruct ADDITIVE
IF VARTYPE(laFields) <> "U" AND TYPE("laFields",1) = "A"
CREATE TABLE (lcName) FROM ARRAY laFields
ENDIF   
ENDSCAN

Of course there are some path-issues in the provided code, along with some
error handling, but it shows a possible way to do it.

Regards,
Sietse Wijnker

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Jeff
> Sent: zondag 7 januari 2007 16:50
> To: [EMAIL PROTECTED]
> Subject: storing table info in tables
> 
> I need to be able to recreate free tables using information 
> stored in tables. I know how to create tables using SQL 
> statements but how would I pull the field [column - hate that 
> about VFP!] information [column name, type, character/column 
> length,... - all stored for reporting] to create a new table?
> 
> jeff fisher, MCP
> www.turbofish.com 
> 
> 
> 
[excessive quoting removed by server]

___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.


Re: storing table info in tables

2007-01-07 Thread Ed Leafe
On Jan 7, 2007, at 10:50 AM, Jeff wrote:

> I need to be able to recreate free tables using information stored in
> tables. I know how to create tables using SQL statements but how
> would I pull the field [column - hate that about VFP!] information
> [column name, type, character/column length,... - all stored for
> reporting] to create a new table?

You could also do:

select OrigTable
AFIELDS(laFields)
CREATE TABLE NewTable FROM ARRAY laFields


-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.


RE: storing table info in tables

2007-01-07 Thread Bill Arnold

Jeff, 


Use tablex
copy to temp structure extended
create newtab from temp


Bill


> I need to be able to recreate free tables using information stored in 
> tables. I know how to create tables using SQL statements but how 
> would I pull the field [column - hate that about VFP!] information 
> [column name, type, character/column length,... - all stored for 
> reporting] to create a new table?
> 
> jeff fisher, MCP
> www.turbofish.com 
> 



___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.


storing table info in tables

2007-01-07 Thread Jeff
I need to be able to recreate free tables using information stored in 
tables. I know how to create tables using SQL statements but how 
would I pull the field [column - hate that about VFP!] information 
[column name, type, character/column length,... - all stored for 
reporting] to create a new table?

jeff fisher, MCP
www.turbofish.com 



___
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.