Professional Web Applications Themes

Empty data tables - Check - Coldfusion Database Access

How can I check to see if a data table is empty so that I can set the ID value the first time? thanks...

Sponsored Links
  1. #1

    Default Empty data tables - Check


    How can I check to see if a data table is empty so that I can set the ID value the first time?

    thanks

    Sponsored Links
    CF_starter Guest

  2. #2

    Default Re: Empty data tables - Check

    I assume "ID" is not some sort of auto incrementing record ID column?

    It depends on your database. In an ms sql database, you could use "if not
    exists ...". You could also count the number of records in the table and if it
    is zero, execute some code.

    --- ms sql database
    if not exists (select someColumn from yourTable)
    begin
    do something here...
    end


    mxstu Guest

  3. #3

    Default Re: Empty data tables - Check

    select count(id) as thecount from mytable

    I assume you have a plan for setting the id field the first time, and incrementing it.
    Dan Bracuk Guest

  4. #4

    Default Re: Empty data tables - Check

    You probably need to know what the ID is for your programming.
    Try looking up identity. It will tell you the ID AFTER the insert query.
    chuckbeckwith Guest

  5. #5

    Default Re: Empty data tables - Check

    Yes, I do have a plan for setting the record. I am going use MS-SQL 2000 as
    the finished product. Right now I'm testing with MS-Access. I'm just trying to
    figure out how to do it, I tried MAX but got no value back.

    g

    CF_starter Guest

  6. #6

    Default Re: Empty data tables - Check

    If you are using Access and migrating to SQL Server, why not just use an
    autonumber column and run SELECT IDENTITY after your inserts like
    chuckbeckwith suggested? (Note - You will need to wrap both the INSERT and
    SELECT IDENTITY queries in a CFTRANSACTION) Then when you migrate to SQL
    Server the autonumber column will likely become an identity column and you can
    use one of SQL Server's identity functions.

    mxstu Guest

Similar Threads

  1. Check Empty form fields
    By wavesurfer in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: August 19th, 10:05 AM
  2. How do you check for empty results
    By Chris Falzone in forum Macromedia Flex General Discussion
    Replies: 2
    Last Post: October 12th, 02:47 PM
  3. Why does CT drop empty lines in tables
    By Howard Heflin in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: December 5th, 10:26 PM
  4. check if querystring is empty
    By TomB in forum ASP
    Replies: 3
    Last Post: July 23rd, 06:08 PM
  5. RegularExpressionValidator - check for empty field
    By Oleg Ogurok in forum ASP.NET General
    Replies: 1
    Last Post: June 25th, 08:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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