SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy PostgreSQL- Create Table

    Hello

    I want to create a table if it does not exists (via ASP). I tried somethig like this but i get an error.

    Code:
    strCheck = "SELECT * FROM " & TableName
    oConn.Execute strCheck		
    IF (oRs.EOF) then
     --- create table
    END IF
    error:
    Code:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    ERROR: relation "mod48_00_2009" does not exist
    How should i test this??

    Thank you
    dReAm

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the system tables:
    Code:
    IF NOT EXISTS(SELECT tablename FROM pg_catalog.pg_tables WHERE tablename = 'mod48_00_2009')
    ...
    Or, via the information_schema:
    Code:
    IF NOT EXISTS(SELECT table_name FROM information_schema.tables where table_name = 'mod48_00_2009')
    ....

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks.. i will try it
    dReAm


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
  •