Microsoft KB Archive/170128: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 92: Line 92:
       INSERT INTO lartable (NumVal, CharVal, DateVal) ;
       INSERT INTO lartable (NumVal, CharVal, DateVal) ;
       VALUES ( RECCOUNT()+1, ;
       VALUES ( RECCOUNT()+1, ;
       "Record " + PADL(ALLTRIM(STR(RECCouNt()+1, m.NumWide, 0)), ;
       "Record " + PADL(ALLTRIM(STR(RECCouNt()+1, m.NumWide, 0)), ;
       m.NumWide, "0"), m.DateVal + m.CurRecord)
       m.NumWide, "0"), m.DateVal + m.CurRecord)
       ? RECNO()
       ? RECNO()
   NEXT
   NEXT

Latest revision as of 11:04, 21 July 2020

Knowledge Base


How To Programmatically Create Large Tables for Testing Purposes

Article ID: 170128

Article Last Modified on 7/1/2004



APPLIES TO

  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition
  • Microsoft FoxPro 2.6a Standard Edition
  • Microsoft FoxPro 2.6a Standard Edition
  • Microsoft FoxPro 2.6a Professional Edition for Macintosh
  • Microsoft Visual FoxPro 3.0b for Macintosh
  • Microsoft FoxPro 2.6 for SCO/UNIX



This article was previously published under Q170128

SUMMARY

This code can be used as an example of how to create a large sample table to test your programs. It is very basic and must be modified to meet your specific design needs.

MORE INFORMATION

Create a program Lartable.prg and add the following sample code to create a table containing any number of records. For this example, the program creates a table containing 120 records. Remember not to allow the program to overwrite any tables that have valid data.

   *Environment area.
   CLEAR
   CLOSE ALL


   * Create a table by substituting your table, field names, and data
   * types.

   CREATE TABLE LarTable (CharVal C(20), NumVal N(9.2), DateVal D)
   USE LarTable.DBF

   * m.NumRecord = the number of record you want to create in your table.
   * NOTE: The time that it takes to create a table will depend upon
   *       the size of the table and the availability of system
   *       resources.

   ******************
   m.NumRecord = 120
   ******************

   m.NumWide = LEN(ALLTRIM(STR(m.NumRecord)))
   * Variable seed for DateVal date field.

   m.dateval = DATE()

   * For loop to fill the table with a Character, Number, and Date
   * fields substitute your field names.

   FOR m.CurRecord  = 1 TO m.NumRecord
      INSERT INTO lartable (NumVal, CharVal, DateVal) ;
      VALUES ( RECCOUNT()+1, ;
      "Record " + PADL(ALLTRIM(STR(RECCouNt()+1, m.NumWide, 0)), ;
       m.NumWide, "0"), m.DateVal + m.CurRecord)
      ? RECNO()
   NEXT
   BROWSE
                

Keywords: kbhowto KB170128