From mike.gagnon@bellnet.ca Fri Jan 25 14:09:41 2008 Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 2E9CD2E2F2F for ; Fri, 25 Jan 2008 10:09:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 24329-01 for ; Fri, 25 Jan 2008 10:09:26 -0400 (AST) Received: from tomts4-srv.bellnexxia.net (tomts4.bellnexxia.net [209.226.175.10]) by postgresql.org (Postfix) with ESMTP id 3A2192E2D99 for ; Fri, 25 Jan 2008 10:09:33 -0400 (AST) Received: from T60 ([70.52.248.103]) by tomts4-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20080125140932.DEWQ9176.tomts4-srv.bellnexxia.net@T60> for ; Fri, 25 Jan 2008 09:09:32 -0500 Message-ID: <003301c85f5b$e891c8b0$640fa8c0@T60> From: "Mike Gagnon" To: Subject: CREATE TABLE IF NOT EXIST Date: Fri, 25 Jan 2008 09:09:28 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0030_01C85F31.FD013490" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.079 tagged_above=0 required=5 tests=BAYES_50=0.001, HTML_MESSAGE=0.001, SUBJ_ALL_CAPS=2.077 X-Spam-Level: ** X-Archive-Number: 200801/34 X-Sequence-Number: 9341 This is a multi-part message in MIME format. ------=_NextPart_000_0030_01C85F31.FD013490 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Postgres Experts, I'm trying to create tables (if they don't exist) through the ODBC = driver. I've tried the following: SELECT relname FROM pg_class WHERE relname =3D 'mytable'; This works from the psql command line program when logged into my = database, but not when connected to my database over ODBC ( I get = SQL_NO_DATA back from SQLFetch) Any ideas? Are there other ways to find out if a table exists? Many thanks, Mike ------=_NextPart_000_0030_01C85F31.FD013490 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Postgres Experts,
 
I'm trying to create tables (if they = don't exist)=20 through the ODBC driver.  I've tried the following:
 
SELECT relname FROM pg_class  WHERE relname =3D = 'mytable';
 
This works from the psql command line = program when=20 logged into my database, but not when connected to my database over ODBC = ( I get=20 SQL_NO_DATA back from SQLFetch)
 
Any ideas?  Are there other ways = to find out=20 if a table exists?
 
Many thanks,
Mike
------=_NextPart_000_0030_01C85F31.FD013490-- From robe.dnd@cityofboston.gov Fri Jan 25 15:04:17 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 9A49F2E3000 for ; Fri, 25 Jan 2008 11:04:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 49637-03 for ; Fri, 25 Jan 2008 11:04:13 -0400 (AST) Received: from ci.boston.ma.us (justice.ci.boston.ma.us [140.241.2.200]) by postgresql.org (Postfix) with ESMTP id DC3252E325C for ; Fri, 25 Jan 2008 11:04:13 -0400 (AST) DKIM-Signature: a=rsa-sha1; d=cityofboston.gov; s=cob2008; c=simple/simple; q=dns; t=1201273447; x=1201359847; h=From:Date:Subject:Message-ID:Content-class:Content-Type; b=choz4sbo59eG2DjIMJ7GW75oeil708IHgDFduTZCts3UwNXO9bexU1gl+hedRJjxUkp7qdSjvL7fMM HPNMrORQ== Received: from ([10.241.103.26]) by justice.ci.boston.ma.us with ESMTP id KP-BRCKH.170551420; Fri, 25 Jan 2008 10:03:50 -0500 Received: from ZDND.DND.boston.cob ([10.241.27.23]) by xcb02.cityhall.boston.cob with Microsoft SMTPSVC(6.0.3790.3959); Fri, 25 Jan 2008 10:03:50 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: Re: CREATE TABLE IF NOT EXIST Date: Fri, 25 Jan 2008 10:03:48 -0500 Message-ID: <53F9CF533E1AA14EA1F8C5C08ABC08D20316E557@ZDND.DND.boston.cob> In-reply-to: <003301c85f5b$e891c8b0$640fa8c0@T60> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [ODBC] CREATE TABLE IF NOT EXIST Thread-Index: AchfXAFGIFveulBQRu2F42Z/y3cxTgABv3Ag References: <003301c85f5b$e891c8b0$640fa8c0@T60> From: "Obe, Regina" To: "Mike Gagnon" , X-OriginalArrivalTime: 25 Jan 2008 15:03:50.0335 (UTC) FILETIME=[7E2D2CF0:01C85F63] Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C85F63.7E3A50AB" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/36 X-Sequence-Number: 9343 This is a multi-part message in MIME format. ------_=_NextPart_001_01C85F63.7E3A50AB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable IF NOT EXISTS(SELECT tablename FROM pg_catalog=2Epg_tables WHERE tablename= =0D=0A=3D 'mytable')=0D=0A =0D=0A=2E=2E=2E=2E=2E=0D=0A =0D=0A =0D=0AIF NOT = EXISTS(SELECT table_name FROM information_schema=2Etables where=0D=0Atable_= name =3D 'mytable')=0D=0A =0D=0AMaybe the problem you are having is a permi= ssions problem though=2E Are=0D=0Ayou using the same account in psql as yo= u are in ODBC?=0D=0A =0D=0AHope that helps,=0D=0ARegina=0D=0A=0D=0A________= ________________________=0D=0A=0D=0AFrom: pgsql-odbc-owner@postgresql=2Eorg= =0D=0A[mailto:pgsql-odbc-owner@postgresql=2Eorg] On Behalf Of Mike Gagnon= =0D=0ASent: Friday, January 25, 2008 9:09 AM=0D=0ATo: pgsql-odbc@postgresql= =2Eorg=0D=0ASubject: [ODBC] CREATE TABLE IF NOT EXIST=0D=0A=0D=0A=0D=0AHi P= ostgres Experts,=0D=0A =0D=0AI'm trying to create tables (if they don't exi= st) through the ODBC=0D=0Adriver=2E I've tried the following:=0D=0A =0D=0A= SELECT relname FROM pg_class WHERE relname =3D 'mytable';=0D=0A =0D=0AThis= works from the psql command line program when logged into my=0D=0Adatabase= , but not when connected to my database over ODBC ( I get=0D=0ASQL_NO_DATA = back from SQLFetch)=0D=0A =0D=0AAny ideas? Are there other ways to find ou= t if a table exists?=0D=0A =0D=0AMany thanks,=0D=0AMike=0D=0A=0D=0A=0D=0A--= ---------------------------------------=0D=0AThe substance of this message,= including any attachments, may be=0Aconfidential, legally privileged and/o= r exempt from disclosure=0Apursuant to Massachusetts law=2E It is intended= =0D=0Asolely for the addressee=2E If you received this in error, please=0Ac= ontact the sender and delete the material from any computer=2E=0D=0A ------_=_NextPart_001_01C85F63.7E3A50AB Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A=0D= =0A
IF NOT EXISTS(SELECT tablename FROM= pg_catalog=2Epg_tables =0D=0AWHERE tablename =3D 'mytable')<= /DIV>=0D=0A
 
= =0D=0A
=2E=2E=2E=2E
= =0D=0A
 
=0D=0A<= DIV dir=3Dltr align=3Dleft> 
=0D=0A
IF NOT EXISTS(SELECT table_name FROM =0D=0Ainfo= rmation_schema=2Etables where table_name =3D 'mytable')
= =0D=0A
 
=0D=0A<= DIV dir=3Dltr align=3Dleft>Maybe the problem you are having is a pe= rmissions problem =0D=0Athough=2E  Are you using the same account in p= sql as you are in =0D=0AODBC?=0D=0A
 
=0D=0A
Hope that helps,
=0D=0A
Regina

=0D=0A
=0D=0A
=0D=0AFrom: pgsql-odbc-owner@postgresql=2Eorg = =0D=0A[mailto:pgsql-odbc-owner@postgresql=2Eorg] On Behalf Of Mike = =0D=0AGagnon
Sent: Friday, January 25, 2008 9:09 AM
To:= =0D=0Apgsql-odbc@postgresql=2Eorg
Subject: [ODBC] CREATE TABLE I= F NOT =0D=0AEXIST

=0D=0A
=0D=0A
Hi Postgres Experts,
=0D=0A
 
=0D=0A
I'm trying to create tables (if they don't exist) =0D=0Athrough the ODBC d= river=2E  I've tried the following:
=0D=0A
 
=0D=0A
=0D=0A
SELECT relname F= ROM pg_class  WHERE relname =3D 'mytable';
=0D=0A
 =
=0D=0A
=0D=0A
This works from the= psql command line program when =0D=0Alogged into my database, but not when= connected to my database over ODBC ( I get =0D=0ASQL_NO_DATA back from SQL= Fetch)
=0D=0A
 =0D=0A
Any ideas?  Are there other w= ays to find out =0D=0Aif a table exists?
=0D=0A
 
=0D=0A
Many thanks,
=0D=0A
Mike
=0D=0A=0D=0A


=0D=0A

=0D=0AThe substance of this message, including any attac= hments, may be confidential, legally privileged and/or exempt from disclosu= re pursuant to Massachusetts law=2E It is intended solely for the addressee= =2E If you received this in error, please contact the sender and delete the= material from any computer=2E=0D=0A

=0D=0A=0D=0A=


=0D=0A

Hel= p make the earth a greener place=2E If at all possible resist printing this= email and join us in saving paper=2E

=0D=0A= =0D=0A=0D=0A=0D=0A=0D=0A=0D=0A ------_=_NextPart_001_01C85F63.7E3A50AB--