How to Create an Auto-Number in a Query?

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default How to Create an Auto-Number in a Query?

    I want to create a verity search collection by indexing the contents of a Union
    Query. My Union query collects data from multiple databases/DSNs.

    I believe the cfindex function (used to create a verity collection) needs a
    primary key from query. However, I do not know how to create an auto-number
    primary key in a query.
    Could someone offer some help?

    For reference, here?s the cfindex tag:
    <cfindex collection="myCollection" action="update" type="custom" body="title,
    article_body" key="autonumber_id" title="title" query="union_articles">


    Monizzle Guest

  2. Similar Questions and Discussions

    1. Using Data Merge with Auto Page Number
      InDesign CS2, Mac OS X.4.8, 1GB RAM, Xerox Phaser 8550 printer. I'm producing a 10-14 page newsletter twice a month for a small local group. I've...
    2. Auto generate unique order number sequential
      Hi: I need help on how to code in a CFFORM an order number. This order number must be auto generated, be unique and sequential. By the way I'm...
    3. How to get back the current count of a auto incrementing number.
      hi How to get the current value of a auto incrementing number generated using CREATE SEQUENCE seqname START 1 Is there any way and if yes...
    4. Auto-create thumbs?
      I've seen a couple of ASP sites that allow the upload of images and then automatically create a thumb-nail equivalent of the image. Normally, I've...
    5. Auto Increment a number field
      I have a memo field (History) and a number field (Count). What I require is that when the history field is updated then the count field will...
  3. #2

    Default Re: How to Create an Auto-Number in a Query?

    In your union query, select the constant 10000 as an extra field. Then loop through the query and set this field to the current rownumber.
    Dan Bracuk Guest

  4. #3

    Default Re: How to Create an Auto-Number in a Query?

    Dan,

    Not sure I understand. Are you suggesting that I establish an alias column in
    my union query and then cfloop over it, using a SQL update query to update the
    Union results to #currentrow#?
    I thought I could only update tables, not queries.
    You must mean that I can place a loop in my SQL statement, but I have no clue
    how to do this.
    If you could get me started it would be much appreciated.

    BTW, thanks for being such great presence on these forums. I?m sure you?re
    keeping ColdFusion alive for a lot of folks.



    Monizzle Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139