Subject | Re: [firebird-support] Re: Does This Table, or Column, Exist? |
---|---|
Author | M Tuttle (KS) |
Post date | 2005-02-14T12:38:57Z |
Hi Larry,
You must use upper case letters when referencing data in the system tables.
Change to UPPER_CASE on your table name as in the following
SELECT
1
FROM
RDB$RELATIONS
WHERE RDB$RELATION_NAME = 'NR_PHASE_TABLE_01'
or this way:
SELECT
1
FROM
RDB$RELATIONS
WHERE RDB$RELATION_NAME = UPPER('nr_phrase_table_01')
You could also use double quotes around your table name.
Mike
You must use upper case letters when referencing data in the system tables.
Change to UPPER_CASE on your table name as in the following
SELECT
1
FROM
RDB$RELATIONS
WHERE RDB$RELATION_NAME = 'NR_PHASE_TABLE_01'
or this way:
SELECT
1
FROM
RDB$RELATIONS
WHERE RDB$RELATION_NAME = UPPER('nr_phrase_table_01')
You could also use double quotes around your table name.
Mike
----- Original Message -----
From: "pukindog_2004" <pukindog_2004@...>
To: <firebird-support@yahoogroups.com>
Sent: Sunday, February 13, 2005 5:03 PM
Subject: [firebird-support] Re: Does This Table, or Column, Exist?
>
>
> --- In firebird-support@yahoogroups.com, "M Tuttle \(KS\)"
> <miket@s...> wrote:
> > Correction:
> > If successful COLUMN0 = 1 and if not succesful then no row returned
> at all.
> >
> > Mike
> >
> > ----- Original Message -----
> > From: "M Tuttle (KS)" <miket@s...>
> > To: <firebird-support@yahoogroups.com>
> > Sent: Sunday, February 13, 2005 7:33 AM
> > Subject: Re: [firebird-support] Does This Table, or Column, Exist?
> >
> >
> > >
> > > Greetings Larry,
> > >
> > > You simply query the system tables.
> > >
> > > For Tables something like this:.
> > > SELECT 1 FROM RDB$RELATIONS WHERE RDB$RELATION_NAME = 'ACCOUNT'
> > >
> > > For Fields something like this:
> > > SELECT 1 FROM RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME =
> 'ACCOUNT' AND
> > > RDB$FIELD_NAME = 'ACCT_ID'
> > >
> > > If successful COLUMN0 = 1 and if not succesful then COLUMN0 = 0
> > >
> > > Mike
> > >
> > > ----- Original Message -----
> > > From: "pukindog_2004" <pukindog_2004@y...>
> > > To: <firebird-support@yahoogroups.com>
> > > Sent: Sunday, February 13, 2005 4:38 AM
> > > Subject: [firebird-support] Does This Table, or Column, Exist?
> > >
> > >
> > > >
> > > >
> > > >
> > > > Hi Folks:
> > > >
> > > > How can I find if a particular table exists in the
> > > > database, or a particular column exists in a table?
> > > >
> > > > Thanks
> > > > Larry
>
> Thanks Mike:
>
> Testing for a table that currently exists in the
> database.
>
> Open the database, start a transaction, Prepare()
> this statement and pass it to Execute():
>
> SELECT
> 1
> FROM
> RDB$RELATIONS
> WHERE RDB$RELATION_NAME = 'nr_phrase_table_01'
>
> Execute() returns without throwing an exception.
>
> "nr_phrase_table_01" is the name of a table in
> the database. A Fetch() returns 0.
>
> I would expect Fetch to return non-zero if the
> table exists in the database.
>
> What am I doing wrong?
>
> Thanks
> Larry
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>