Thread: DELETE FROM fails

DELETE FROM fails

From
chris Günther
Date:
Hi folks,

I have the problem that I can't delete datasets out of my tables. It's like that:
I have a table:
tblshop
    ID_Shop    oid with sequence
    -------
    Sh_Name
    ID_Country
    ...

there is an index on ID_Country


I have a second table:
tblcountry
    ID_Country    oid with sequence
    ----------
    C_Name
    ...

I have a reference between these two tables pointing from tblshop.ID_Country to
tblcountry.ID_Country

When I try to delete a row from tblshop I get the error that postgres can't find
the attribute id_shop. My SQL-command looks like follows:

    DELETE FROM tblshop WHERE tblshop."ID_Shop" = 12

the same happens when I try to do:

    DELETE FROM tblshop WHERE tblshop."ID_Country" = 3

I also tried this query without quotes, with simple quotes (') without the leading
tablename and so on, but I always get the error-message:

    ERROR:  Attribute 'id_shop' not found

Please, can anyone help me out? It is really anoying when you can't delete datasets
especially because my application is already online (I use postgres with PHP) and
there are 20 tables with alltogether 120 MB of data in it

    chris

--
+-----------------------------+
| chris                       |
| Database Developer          |
| uscreen GmbH                |
|                             |
| --------------------------- |
| eMail   guenther@uscreen.de |
| Fon   (02 02) 24 49 88 - 23 |
+-----------------------------+

Re: DELETE FROM fails

From
Manuel Sugawara
Date:
chris Günther <guenther@uscreen.de> writes:

> Please, can anyone help me out? It is really anoying when you can't delete datasets
> especially because my application is already online (I use postgres with PHP) and
> there are 20 tables with alltogether 120 MB of data in it

try to figure out exactly how postgres thinks that columns are named,
use pg_dump program as

$ pg_dump -s -t <table-name-goes-here>

Then use the names as they are dumped

HTH,
Manuel.

Re: DELETE FROM fails

From
Vijay Deval
Date:
Are the  attribute names case sensative?  The query may not tolerate any accidental
space in the wrong place.

Vijay

"chris Günther" wrote:

> Hi folks,
>
> I have the problem that I can't delete datasets out of my tables. It's like that:
> I have a table:
> tblshop
>         ID_Shop oid with sequence
>         -------
>         Sh_Name
>         ID_Country
>         ...
>
> there is an index on ID_Country
>
> I have a second table:
> tblcountry
>         ID_Country      oid with sequence
>         ----------
>         C_Name
>         ...
>
> I have a reference between these two tables pointing from tblshop.ID_Country to
> tblcountry.ID_Country
>
> When I try to delete a row from tblshop I get the error that postgres can't find
> the attribute id_shop. My SQL-command looks like follows:
>
>         DELETE FROM tblshop WHERE tblshop."ID_Shop" = 12
>
> the same happens when I try to do:
>
>         DELETE FROM tblshop WHERE tblshop."ID_Country" = 3
>
> I also tried this query without quotes, with simple quotes (') without the leading
> tablename and so on, but I always get the error-message:
>
>         ERROR:  Attribute 'id_shop' not found
>
> Please, can anyone help me out? It is really anoying when you can't delete datasets
> especially because my application is already online (I use postgres with PHP) and
> there are 20 tables with alltogether 120 MB of data in it
>
>         chris
>
> --
> +-----------------------------+
> | chris                       |
> | Database Developer          |
> | uscreen GmbH                |
> |                             |
> |