6 Replies Latest reply on Apr 2, 2010 1:58 PM by philmodjunk

    Is there a quick way to create a thousand records with the same data?

    hbj

      Title

      Is there a quick way to create a thousand records with the same data?

      Post

      For example, let's say I wanted 1000 records with a given photographer's name in the name field, is there any way to do that in one step?

       

      Thanks!

        • 1. Re: Is there a quick way to create a thousand records with the same data?
          philmodjunk

          Not one step but just a few steps in a script: Let's say you enter the name in a global text field, gName and then run the script:

           

          Set Variable [$I : Value 1]

          Loop

            New Record/Request

            Set FIeld [Table::Name; Table::gName]

            Set Variable [ $I ; Value: $I + 1]

            Exit Loop If [$I > 1000]

          End Loop

          • 2. Re: Is there a quick way to create a thousand records with the same data?
            hbj

            Thanks so much Phil, trying it now.

            • 3. Re: Is there a quick way to create a thousand records with the same data?
              hbj

              That worked great, Phil. Thanks.

               

              Now how would I give each record a unique serial number in the process?  Or even better, after creating them all.

               

              Thanks again!

               

               

              • 4. Re: Is there a quick way to create a thousand records with the same data?
                philmodjunk

                Simply define your serial number field to be an auto-entered serial number.

                • 5. Re: Is there a quick way to create a thousand records with the same data?
                  LaRetta_1

                  Actually, incrementing and setting variables can slow it down and there is no need because your record count can increment for you.  Also, setting the name each time can be skipped because you can duplicate the record which performs the 'new record' and 'set field' in one whack.

                   

                  So instead of this:

                  Set Variable [$I : Value 1]

                  Loop

                    New Record/Request

                    Set FIeld [Table::Name; Table::gName]

                    Set Variable [ $I ; Value: $I + 1]

                    Exit Loop If [$I > 1000]

                  End Loop

                   

                  It can be this:

                  Set Variable [ $num ; Get ( TotalRecordCount ) ]

                  Set Field [  Name ; gName ]

                  Loop

                   Exit Loop If [ Get ( TotalRecordCount ) = $num + 1000

                   Duplicate Record/Request

                  End Loop

                   

                  ... just another perspective. :smileyhappy:

                   

                   

                  • 6. Re: Is there a quick way to create a thousand records with the same data?
                    philmodjunk

                    For a 1000 records it doesn't make much difference either way. I became curious as to how repeated calls to Get (Foundcount) compared to incrementing a variable so I ran the following script to see:

                     

                    Freeze Window

                    Set Field [ Table::TimeA1; Get ( CurrentTime ) ]

                    Set Variable [ $I; Value:1 ]

                    Loop

                      New Record/Request

                      Set Field [ Table::Name; Table::gName ]

                      Set Variable [ $I; Value:$I + 1 ]

                      Exit Loop If [ $I > 1000 ]

                    End Loop

                    Set Field [ Table::TimeA2; Get ( CurrentTime ) ]

                    Set Field [ Table::TimeB1; Get ( CurrentTime) ]

                    Set Variable [ $N; Value:Get ( FoundCount ) ]

                    New Record/Request

                    Set Field [ Table::Name; Table::gName ]

                    Loop

                      Exit Loop If [ Get ( FoundCount ) = $N + 1000 ]

                      Duplicate Record/Request

                    End Loop

                    Set Field [ Table::TimeB2; Get ( CurrentTime ) ]

                     

                    The difference in elapsed time was only 1 second and the first loop was faster. I then modified the second loop by changing two lines:

                    Set Variable [$N ; Value: Get(FoundCount) + 1000]

                    and

                    Exit loop if [ Get ( FoundCount ) = $N ]

                     

                    That change reversed the comparitive results making the second loop a second faster than the first. Thus get (foundcount) with duplicate is faster than an incremented variable. (at least with Filemaker 11, on my particular Windows XP machine.)

                     

                    In any case, not  significant difference for 1,000 records but it could easily be significant for larger numbers of records.