Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a copy of a table + 1 column
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00807177
Message ID:
00807182
Views:
13
I need it broken up into two parts. Part one creates the structure with the extra column. Part two inserts the values, without wiping out the existing rows in the table. The two parts are in two different methods. Your SELECT works well, but it deletes all the previous rows.


>You can do that with one select
>select *, PADR(m.lettername,50) as lettername ;
> from property ;
> where key = m.key ;
> INTO TABLE (cdatasource)


>>I am trying to create a copy of a table structure, but to add a column on the end with a constant value.
>>
>>The following code seems to create the l_prop1.dbf table that is a copy of the property table structure with a column at the end named lettername. The 'into arr_prop' appears to create an array with the lettername value as the last element of the array. But when I 'append from', to the newly create table l_prop1, a date gets put into the lettername column. The previous two columns to lettername are both date types that should have values in them, but they are blank. Where does the following code go wrong. Will not a STRUCT return the column in the same order as a 'into array'.
>>
>>cdatasource = rpath + '\DATA\L_prop1.DBF'
>>SELECT property
>>COPY STRUCTURE TO (cdatasource)
>>alter table (cdatasource) add column lettername c(50) not null
>>select *, (m.lettername) as 'lettername' from property where key = m.key into array arr_prop
>>select l_prop1
>>append from array arr_prop
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform