Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Table Exists

    I am wanting to check the existance of a table in my informix db
    before I query it, since if I query a table that does not exist, it'll
    blow up on me.

    Anyone know the syntax on this? My code currently looks like this:
    Set rsMachineOwner = Server.CreateObject("ADODB.Recordset")
    MOQ = "SELECT * FROM ari.units WHERE u_id='"& thisPage.getUnitID()
    &"'"
    rsMachineOwner.Open MOQ, Conn1,3,1
    if not rsMachineOwner.EOF then
    MachOwn = trim(rsMachineOwner("u_company"))
    thisPage.setMachineOwner(MachOwn)
    else
    thisPage.setMachineOwner("")
    end if
    set rsMachineOwner = nothing

    I do not need to use this piece of code in many cases, but I want to
    make the code smart enough to handle it, so I won't need to copy this
    code from project to project on an "as needed" basis.

    Thanks!
    Tyler
    TylerB Guest

  2. Similar Questions and Discussions

    1. Table exists?
      Hi, can anyone tell me, how to find out if a table in an MS Access DB exists? Also, I'd like to find out, if certain columns exits if a table...
    2. Check if table exists
      ON.KG wrote: One thing to consider: you are making a trip to the database to determine if a table exists. If it exists, you are then making...
    3. Testing if a mysql table exists
      Is there a simple way to test if a mysql table exists? JUST One line !
    4. Is there anything like an 'exists table' method I can use?
      I need to run a querry from an asp page only if a certain table exists in the data base. Is there any kind of method that can look at the database...
    5. Another user has modified the contents of this table or view; the database row you are modifying no longer exists in the database;
      Hi, I am testing a trigger that and I am getting this error message saying "Another user has modified the contents of this table or view; the...
  3. #2

    Default Re: Table Exists

    > I am wanting to check the existance of a table in my informix db
    > before I query it,
    How could you possibly write a query against a table that you're not sure if
    it exists or not???

    Anyway, this is one way to check for a table in Informix:

    SELECT COUNT(*) FROM systables WHERE tabname = 'your_table_name'

    If this returns 0, the table doesn't exist. If it returns 1, it does. If
    it returns more than 1, you have an issue.

    A


    Aaron Bertrand - MVP 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