Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create a Table programmatically
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00562933
Message ID:
00563013
Views:
31
>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
>#DEFINE MAX_CLAUSES 20
>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
>lcClause = ""
 lnCount=0
>
>lcfields = ""
>SELECT schema
>SCAN
>	lnCount=m.lnCount +1
>	lcFieldName = schema.desc
>	lnLength = schema.length
>	lcType = schema.type
>	lcClause = m.lcClause+ " ADD Column "+ ;
        m.lcFieldName+" "+ m.lcType+'('+transform(m.lnLenght)+')'
        if m.lnCount>= MAX_CLAUSES
           alter table OhioStreets &lcClause
>	   lnCount=0
           lcClause =""
       endif
>ENDSCAN
if !empty(m.lcClause) && Remainder
    alter table OhioStreets &lcClause
endif
See the changes, I made in code.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform