CREATE TABLE IF NOT EXIST

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16587" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Postgres Experts,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm trying to create tables (if they =
don't exist)
through the ODBC driver.  I've tried the following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>
<DIV>SELECT relname FROM pg_class  WHERE relname =3D =
'mytable';</DIV>
<DIV> </DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>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)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas?  Are there other ways =
to find out
if a table exists?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Many thanks,</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Mike</FONT></DIV></DIV></DIV></BODY></HTML>

------=_NextPart_000_0030_01C85F31.FD013490--
Mike Gagnon [ Fr, 25 Januar 2008 15:09 ] [ ID #1916160 ]

Re: CREATE TABLE IF NOT EXIST

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 [at] postgresql=2Eorg=
=0D=0A[mailto:pgsql-odbc-owner [at] postgresql=2Eorg] On Behalf Of Mike Gagnon=
=0D=0ASent: Friday, January 25, 2008 9:09 AM=0D=0ATo: pgsql-odbc [at] 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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4=2E0 Transitional//EN">=0D=0A<HTML=
><HEAD>=0D=0A<META http-equiv=3DContent-Type content=3D"text/html; charset=
=3Dus-ascii">=0D=0A<META content=3D"MSHTML 6=2E00=2E6000=2E16481" name=3DGE=
NERATOR>=0D=0A<STYLE></STYLE>=0D=0A</HEAD>=0D=0A<BODY bgColor=3D#ffffff>=0D=
=0A<DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT face=
=3DArial =0D=0Acolor=3D#0000ff size=3D2>IF NOT EXISTS(SELECT tablename FROM=
pg_catalog=2Epg_tables =0D=0AWHERE tablename =3D 'mytable')</FONT></SPAN><=
/DIV>=0D=0A<DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FO=
NT face=3DArial =0D=0Acolor=3D#0000ff size=3D2></FONT></SPAN> </DIV>=
=0D=0A<DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT fa=
ce=3DArial =0D=0Acolor=3D#0000ff size=3D2>=2E=2E=2E=2E</FONT></SPAN></DIV>=
=0D=0A<DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT fa=
ce=3DArial =0D=0Acolor=3D#0000ff size=3D2></FONT></SPAN> </DIV>=0D=0A<=
DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT face=3DAr=
ial =0D=0Acolor=3D#0000ff size=3D2></FONT></SPAN> </DIV>=0D=0A<DIV dir=
=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT face=3DArial =0D=
=0Acolor=3D#0000ff size=3D2>IF NOT EXISTS(SELECT table_name FROM =0D=0Ainfo=
rmation_schema=2Etables where table_name =3D 'mytable')</FONT></SPAN></DIV>=
=0D=0A<DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT fa=
ce=3DArial =0D=0Acolor=3D#0000ff size=3D2></FONT></SPAN> </DIV>=0D=0A<=
DIV dir=3Dltr align=3Dleft><SPAN class=3D048170015-25012008><FONT face=3DAr=
ial =0D=0Acolor=3D#0000ff size=3D2>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?</FONT></SPAN></DIV>=0D=0A<DIV dir=3Dltr align=
=3Dleft><SPAN class=3D048170015-25012008><FONT face=3DArial =0D=0Acolor=3D#=
0000ff size=3D2></FONT></SPAN> </DIV>=0D=0A<DIV dir=3Dltr align=3Dleft=
><SPAN class=3D048170015-25012008><FONT face=3DArial =0D=0Acolor=3D#0000ff =
size=3D2>Hope that helps,</FONT></SPAN></DIV>=0D=0A<DIV dir=3Dltr align=3Dl=
eft><SPAN class=3D048170015-25012008><FONT face=3DArial =0D=0Acolor=3D#0000=
ff size=3D2>Regina</FONT></SPAN></DIV><BR>=0D=0A<DIV class=3DOutlookMessage=
Header lang=3Den-us dir=3Dltr align=3Dleft>=0D=0A<HR tabIndex=3D-1>=0D=0A<F=
ONT face=3DTahoma size=3D2><B>From:</B> pgsql-odbc-owner [at] postgresql=2Eorg =
=0D=0A[mailto:pgsql-odbc-owner [at] postgresql=2Eorg] <B>On Behalf Of </B>Mike =
=0D=0AGagnon<BR><B>Sent:</B> Friday, January 25, 2008 9:09 AM<BR><B>To:</B>=
=0D=0Apgsql-odbc [at] postgresql=2Eorg<BR><B>Subject:</B> [ODBC] CREATE TABLE I=
F NOT =0D=0AEXIST<BR></FONT><BR></DIV>=0D=0A<DIV></DIV>=0D=0A<DIV><FONT fac=
e=3DArial size=3D2>Hi Postgres Experts,</FONT></DIV>=0D=0A<DIV><FONT face=
=3DArial size=3D2></FONT> </DIV>=0D=0A<DIV><FONT face=3DArial size=3D2=
>I'm trying to create tables (if they don't exist) =0D=0Athrough the ODBC d=
river=2E  I've tried the following:</FONT></DIV>=0D=0A<DIV><FONT face=
=3DArial size=3D2></FONT> </DIV>=0D=0A<DIV>=0D=0A<DIV>SELECT relname F=
ROM pg_class  WHERE relname =3D 'mytable';</DIV>=0D=0A<DIV> =
</DIV>=0D=0A<DIV>=0D=0A<DIV><FONT face=3DArial size=3D2>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)</FONT></DIV>=0D=0A<DIV><FONT face=3DArial size=3D2></FONT> </DI=
V>=0D=0A<DIV><FONT face=3DArial size=3D2>Any ideas?  Are there other w=
ays to find out =0D=0Aif a table exists?</FONT></DIV>=0D=0A<DIV><FONT face=
=3DArial size=3D2></FONT> </DIV>=0D=0A<DIV><FONT face=3DArial size=3D2=
>Many thanks,</FONT></DIV>=0D=0A<DIV><FONT face=3DArial size=3D2>Mike</FONT=
></DIV></DIV></DIV></BODY></HTML>=0D=0A=0D=0A<HTML><BODY><P><hr size=3D1></=
P>=0D=0A<P><STRONG>=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</STRONG></P></BODY></HTML>=0D=0A=0D=0A=
<P><hr size=3D1></P>=0D=0A<P><STRONG><font size=3D"2" color=3D"339900"> Hel=
p make the earth a greener place=2E If at all possible resist printing this=
email and join us in saving paper=2E </p> <p> </font></STRONG></P>=0D=0A=
=0D=0A=0D=0A=0D=0A=0D=0A=0D=0A
------_=_NextPart_001_01C85F63.7E3A50AB--
robe.dnd [ Fr, 25 Januar 2008 16:03 ] [ ID #1916162 ]
Datenbanken » gmane.comp.db.postgresql.odbc » CREATE TABLE IF NOT EXIST

Vorheriges Thema: Building ODBC driver issue
Nächstes Thema: Driver 8.1 : fails contacting the server with routable address