CREATE TABLE IF NOT EXIST

CREATE TABLE IF NOT EXIST

am 25.01.2008 15:09:28 von Mike Gagnon

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



charset=3Diso-8859-1">




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,

size=3D2>Mike


------=_NextPart_000_0030_01C85F31.FD013490--

Re: CREATE TABLE IF NOT EXIST

am 25.01.2008 16:03:48 von robe.dnd

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_catalogpg_tables WHERE tablename=
=3D 'mytable') ..... =0A IF NOT =
EXISTS(SELECT table_name FROM information_schematables where table_=
name =3D 'mytable') Maybe the problem you are having is a permi=
ssions problem though Are you using the same account in psql as yo=
u are in ODBC? Hope that helps, Regina ________=
________________________ From: pgsql-odbc-owner@postgresqlorg=
[mailto:pgsql-odbc-owner@postgresqlorg] On Behalf Of Mike Gagnon=
Sent: Friday, January 25, 2008 9:09 AM To: pgsql-odbc@postgresql=
org Subject: [ODBC] CREATE TABLE IF NOT EXIST Hi P=
ostgres Experts, I'm trying to create tables (if they don't exi=
st) 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 ou=
t if a table exists? Many thanks, Mike --=
--------------------------------------- The substance of this message,=
including any attachments, may be=0Aconfidential, legally privileged and/o=
r exempt from disclosure=0Apursuant to Massachusetts law It is intended=
solely for the addressee If you received this in error, please=0Ac=
ontact the sender and delete the material from any computer. =0A
------_=_NextPart_001_01C85F63.7E3A50AB
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

> =3Dus-ascii"> NERATOR> =0D=
=0A

=3DArial color=3D#0000ff size=3D2>IF NOT EXISTS(SELECT tablename FROM=
pg_catalogpg_tables WHERE tablename =3D 'mytable')
<=
/DIV>
NT face=3DArial color=3D#0000ff size=3D2> 
=
ce=3DArial color=3D#0000ff size=3D2>....
=
ce=3DArial color=3D#0000ff size=3D2> 
<=
DIV dir=3Dltr align=3Dleft> ial color=3D#0000ff size=3D2> 
=3Dltr align=3Dleft> =0Acolor=3D#0000ff size=3D2>IF NOT EXISTS(SELECT table_name FROM info=
rmation_schematables where table_name =3D 'mytable')
=
ce=3DArial color=3D#0000ff size=3D2> 
<=
DIV dir=3Dltr align=3Dleft> ial color=3D#0000ff size=3D2>Maybe the problem you are having is a pe=
rmissions problem though  Are you using the same account in p=
sql as you are in ODBC?
=3Dleft> 0000ff size=3D2> 
> size=3D2>Hope that helps,
eft> ff size=3D2>Regina

Header lang=3Den-us dir=3Dltr align=3Dleft>
ONT face=3DTahoma size=3D2>From: pgsql-odbc-owner@postgresqlorg =
[mailto:pgsql-odbc-owner@postgresqlorg] On Behalf Of Mike =
Gagnon
Sent: Friday, January 25, 2008 9:09 AM
To:=
pgsql-odbc@postgresqlorg
Subject: [ODBC] CREATE TABLE I=
F NOT EXIST

e=3DArial size=3D2>Hi Postgres Experts,
=3DArial size=3D2> 
>I'm trying to create tables (if they don't exist) through the ODBC d=
river  I've tried the following:
=3DArial size=3D2> 
SELECT relname F=
ROM 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 SQL=
Fetch)
  V>
Any ideas?  Are there other w=
ays to find out if a table exists?
=3DArial size=3D2> 
>Many thanks,
Mike >


P>

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

=


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

=

------_=_NextPart_001_01C85F63.7E3A50AB--