Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting Records into DBF
Message
From
02/07/2013 15:09:08
 
 
To
02/07/2013 15:01:45
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01577675
Message ID:
01577688
Views:
54
If you have a complex or lengthy set of unordered records to insert, then you can construct an array with one row per record, and use a single loop like:
DIMENSION laInserts[3,3]

laInserts[1,1] = "tablea"
laInserts[1,2] = 1
laInserts[1,3] = 75

laInserts[2,1] = "tableb"
laInserts[2,2] = 1
laInserts[2,3] = 25

laInserts[3,1] = "tablea"
laInserts[3,2] = 76
laInserts[3,3] = 100

SELECT * ;
    FROM tablea ;
    WHERE .f. ;
    INTO TABLE results.dbf

* Untested, would require some debugging I'm sure. :-)
FOR lnI = 1 TO ALEN(laInserts,1)
    INSERT INTO results ;
        SELECT * FROM (laInserts[lnI,1]) WHERE BETWEEN(RECNO(laInserts[lnI,1]), laInserts[lnI,2], laInserts[lnI,3])
NEXT
>Thanks , I will Try it.
>
>>>Suppose I have a table A with 100 records and Table B with 25 Records. I want to insert the
>>>records of Table B in Table A, after 75 records of Table A.
>>>I.e First 75 recodrs shoud be of A , next 25 of B and than 25 of A. How it will be done ?
>>
>>
>>Several ways. I think you want a SQL solution? Something like (untested) this if tablea and tableb have the same structure:
>>
>>
SELECT * ;
>>    FROM tablea ;
>>    WHERE RECNO() <= 75 ;
>>UNION ;
>>SELECT * ;
>>    FROM tableb ;
>>    WHERE RECNO() <= 25 ;
>>UNION ;
>>SELECT * ;
>>    FROM tablea ;
>>    WHERE BETWEEN(RECNO(), 76, 100) ;
>>    INTO TABLE result.dbf
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform