Re: postgresql "TABLENAME" versus TABLENAME

From: dan17..elus.net
Date: Tue Jul 06 2004 - 15:11:54 EDT

  • Next message: Andrus Adamchik: "Re: conflict with automatic session serialization by tomcat?"

    In Oracle SQL, putting doublesquotes around a table name makes it case-
    sensitive.

    ie, in Oracle:

    SELECT field FROM table;
    is the same as
    SELECT FIELD FROM TABLE;
    and
    SELECT "FIELD" FROM "TABLE"

    but not the same as

    SELECT "field" FROM "table";

    if you want the last one to work, you had to have done a

    CREATE TABLE "table" (
    "field" NUMBER
    )

    I've never worked with postgresql, but the issue may be similar.

    - Dan

    Quoting Andrus Adamchik <andru..bjectstyle.org>:

    > Hi Tore,
    >
    > So are you saying that a doublequote is actually a part of the table
    > name? That's weird, but still I think we should support this in
    > Cayenne. Could you open a bug report please, showing where exactly this
    > breaks. I'll make sure that when the XML is stored the name is properly
    > escaped.
    >
    > Andrus
    >
    >
    > On Jul 1, 2004, at 3:32 PM, Tore Halset wrote:
    >
    > > Hello.
    > >
    > > I have a database created by a import/export tool called ogr2ogr. It
    > > creates tables and columns with captial letters as shown in the
    > > example below. I am having trouble mapping this in cayenne. Using "s
    > > in the Modeler makes the mapping xml file unparsable.
    > >
    > > Perhaps cayenne should use "s around every table name and field name
    > > for every query? Perhaps only for postgresql databases? This would
    > > make "TABLENAME" work, but will potensially break lots of old mapping
    > > files. Perhaps this can be solved by configuring the database or the
    > > jdbc driver?
    > >
    > > toretest=> create table "TABLENAME" ("FIELD" int);
    > > CREATE TABLE
    > > toretest=> \d "TABLENAME"
    > > Table "public.TABLENAME"
    > > Column | Type | Modifiers
    > > --------+---------+-----------
    > > FIELD | integer |
    > >
    > > toretest=> select * from TABLENAME;
    > > ERROR: relation "tablename" does not exist
    > > toretest=> select FIELD from "TABLENAME";
    > > ERROR: column "field" does not exist
    > > toretest=> select "FIELD" from "TABLENAME";
    > > FIELD
    > > -------
    > > (0 rows)
    > >
    > > Regards,
    > > - Tore.
    > >
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Jul 06 2004 - 15:11:56 EDT