Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create a Table programmatically
Message
From
02/10/2001 09:15:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00562933
Message ID:
00562940
Views:
32
>Please help:
> I'm trying to create a universal data import table based upon the content of another table I call 'schema'. Schema contains the field names, length, type and start and end points of the fields to be imported from a ASCII file. I'm hung up on creating the new data table using just variables to declare the fields. Here is my latest version of code, and it keeps erroring out on the "Alter Table" command.
>
>I really appreciate your help.
>
>Bob Ohrstedt
>RJO Associates
>
>LOCAL lcfile, lcalias, lcreclen, lafields
>
>IF NOT USED('schema')
> USE schema IN 0 SHARED
>ENDIF
>
>CREATE TABLE OhioStreets(fieldnum I(4))
>
>IF NOT used('OhioStreets')
> USE OhioStreets IN 0 EXCLUSIVE
>ENDIF
>SELECT schema
>
>GO top
>
>
>lcfields = ""
>SELECT schema
>SCAN
>
> lcFieldName = schema.desc
> lnLength = schema.length
> lctype = schema.type
>
> ALTER TABLE add column &lcfieldname &lctype(lnlength)
>
>LOOP
>EXIT
>ENDSCAN

Robert,
There are numerous ways which some are even compatible with fox2x :
Assuming your schema table has exactly (Field_Name c(128),Field_Type c(1),Field_len i, Field_dec i + tablename m) structure (you can get this structure and more if you 'create structure extended' for a table)

select Field_Name,Field_Type,Field_len, Field_dec from ;
Schema where tablename = 'OhioStreets' into array myArray
create OhioStreets from array myArray

Your alter table is another way. There as I could see tablename is missing.

ALTER TABLE OhioStreets add column &lcfieldname &lctype(lnlength)

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
Previous
Reply
Map
View

Click here to load this message in the networking platform