5 Replies Latest reply on Jul 2, 2014 1:34 PM by bigtom

    Incremented text

    bigtom

      I am working on part of a solution that generates URLs for records.

       

      The issue is having the same URL. If there are multiple records for "Ford Falcon" or "Chevy Nova" I need URLs that are incremented such as "http://www.../ford-falcon.htm" and then "http://www.../ford-falcon-2.htm" and then "http://www.../ford-falcon-3.htm".

       

      Looping through the entire database looking for a match of each increment and then appending the correct number is too intensive.

       

      I was thinking of a table with all of the name values and and increment number. If the name is on the table get the number and increment +1. Finding an existing record and incrementing the value is easy.

       

      If the name is not already in the table a new record needs to be added. The thing I am having trouble with is how to script somehting to happen when a match is not found. I am sure this is simple but I am missing it.

        • 1. Re: Incremented text
          mardikennedy

          get(lasterror)?  (if not 0, etc)

          • 2. Re: Incremented text
            erolst

            Why not create a self-join by name, then check on the count of related records and either increment or add a new record?

            • 3. Re: Incremented text
              beverly

              There is a function FilterValues() that might help along with getting all the current "increments" into a List. Store the list of values, test a new possible against the list with FilterValues(), if there's not a match, use the value and add it to the list. If there is a match, try the next increment.

               

              You might even use PatternCount() on the list to see how many "ford-falcon-" have been used, assuming you have the increments correct.

               

              Then there's the ExecuteSQL to narrow list of what's used based on the "ford-falcon".

               

              Lots of lovely possibilities.

              • 4. Re: Incremented text
                bigtom

                This is what I was looking for mostly. It is simple. I just never had a use for somehting like this yet. 0 for scripts, 401 for finds, 1408 & 1409 for ExecuteSQL.

                • 5. Re: Incremented text
                  bigtom

                  Selecting the increment direcly from the table where the model = "Ford Falcon" using ExecuteSQL seems like the quickest way. If that fails and returns an error then add the name to the table.

                   

                  Thanks.