MODI STRU on the fly 
Author Message
 MODI STRU on the fly

I'm using FPRO 2.6 on the Mac.  I would like to be able to modify the
structure of a .dbf file in a program.  Specifically, I would like to add
a field to the structure of the file.  Is there a way to do this?  What
would the command(s) be?  I know I could do it with Copy Stru Extended,
but I was wondering if there was an easier way.

Thanks-

Sally Vegso



Sat, 18 Mar 2000 03:00:00 GMT  
 MODI STRU on the fly

Look at the AFIELDS() command.
USE TEST
NUMFIELDS=AFIELDS(TEST_AR)
This will store the file structure of TEST.DBF into an array called
TEST_AR.

Now you can modify the array or add new elements with the DIMENSION
command.

Then check out the CREATE TABLE...SQL command
CREATE TABLE TEST1 FROM ARRAY TEST_AR.
The above creates a new table called TEST1 with any mods to array
TEST_AR.

Quote:

> I'm using FPRO 2.6 on the Mac.  I would like to be able to modify the
> structure of a .dbf file in a program.  Specifically, I would like to
> add
> a field to the structure of the file.  Is there a way to do this?
> What
> would the command(s) be?  I know I could do it with Copy Stru
> Extended,
> but I was wondering if there was an easier way.

> Thanks-

> Sally Vegso



Sat, 18 Mar 2000 03:00:00 GMT  
 MODI STRU on the fly

Sally:

I guess it depends on your definition of "easier", but you could also use
the sql CREATE TABLE command.... which I prefer over COPY STRU EXTE.



Quote:
> I'm using FPRO 2.6 on the Mac.  I would like to be able to modify the
> structure of a .dbf file in a program.  Specifically, I would like to add
> a field to the structure of the file.  Is there a way to do this?  What
> would the command(s) be?  I know I could do it with Copy Stru Extended,
> but I was wondering if there was an easier way.

> Thanks-

> Sally Vegso

-larry gauthier



Sat, 18 Mar 2000 03:00:00 GMT  
 MODI STRU on the fly

Here is some code that does what you want.  This is production code
being used in a multi-user environment by one of my customers:

function f_mnidda_z
parameters fm_trandbf

copy structure extended to stru_dda

insert into stru_dda ;
    (field_name, ;
     field_type, ;
     field_len, ;
     field_dec) ;
  values ;
    ('SDDA_BIPCC', ;
     'C', ;
     3, ;
     0)

select stru_dda
use
flush

create stru_wrk from stru_dda

wait window nowait 'Appending from transaction table into stru_dda.'
append from (fm_trandbf)
go top
delete            && get rid of date header row
wait window nowait 'Establishing bipcc values in struc_wrk.'

replace sdda_bipcc with f_bipcc(sdda_actyp) ;
        all

flush

*--- more code deleted here for brevity

return .t.

Quote:

> I'm using FPRO 2.6 on the Mac.  I would like to be able to modify the
> structure of a .dbf file in a program.  Specifically, I would like to add
> a field to the structure of the file.  Is there a way to do this?  What
> would the command(s) be?  I know I could do it with Copy Stru Extended,
> but I was wondering if there was an easier way.

> Thanks-

> Sally Vegso



Sat, 18 Mar 2000 03:00:00 GMT  
 MODI STRU on the fly



Quote:
> I would like to be able to modify the
> structure of a .dbf file in a program.  Specifically, I would like to
> add a field to the structure of the file.

VFP 3 supports standard SQL DDL commands.

ALTER TABLE x ADD COLUMN y C(20)
ALTER TABLE x DROP COLUMN z

See Help ALTER TABLE

-Anders

--

10/01/97 12:04
---------
Using: OUI PRO 1.5.0.2 from http://www.dvorak.com



Sun, 19 Mar 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Vcx stru

2. Progmattic stru change while keeping CDX intact

3. CREATE FROM and COPY STRU EXTENDED

4. LIST STRU to PRINT?

5. problem with copy stru

6. modi comm window size?

7. modi gene & cd-rom problems

8. modi file/comm without word wrap and syntax hightlight

9. VFP 6 MODI FORM question

10. Modi form and JAZ Drive

11. MODI COMM on Read-Only Files?

12. How to set the default font for modi comm

 

 
Powered by phpBB® Forum Software