Thread: Please help me out on this insert error

Please help me out on this insert error

From
Vernon Wu
Date:
Command:

Insert into profile (userid, haveChildren)values('id98', 'No');

Error:

ERROR:  Relation 'profile' does not have attribute 'havaChildren'

Table:
                Table "profile"   Column    |         Type          | Modifiers
--------------+-----------------------+----------userid       | character varying(25) | not nullsex          |
character(1)         | not nulldob          | date                  | not nullpob          | character varying(20)
|status      | character varying(20) | not nullethnicity    | character varying(20) | not nullreligion     | character
varying(20)| not nullbodytype     | character varying(20) | not nullheight       | numeric(3,0)          | not
nullweight      | numeric(2,0)          | not nulleducation    | character varying(20) |occupation   | character
varying(20)| not nullincomelow    | numeric(6,0)          | not nullincomeup     | numeric(6,0)          | not
nullhaveChildren| character varying(20) | not nullwantChildren | character varying(20) | not nulldrinking     |
charactervarying(20) |smoking      | character varying(20) | not nullnarration    | text                  |
 
Primary key: pro_pkey


What is wrong here?

Thanks.





Re: Please help me out on this insert error

From
Joe Conway
Date:
Vernon Wu wrote:
> Command:
> 
> Insert into profile (userid, haveChildren)values('id98', 'No');
> 
> Error:
> 
> ERROR:  Relation 'profile' does not have attribute 'havaChildren'
  ^^^From the error message, looks like you spelled haveChildren wrong.
 

HTH,

Joe



Re: Please help me out on this insert error

From
Stephan Szabo
Date:
On Thu, 13 Jun 2002, Vernon Wu wrote:

>
> Command:
>
> Insert into profile (userid, haveChildren)values('id98', 'No');

You presumably used double quotes when creating the column, so
you need to use them to refer to the column from that point on:

insert into profile(userid, "haveChildren") ...




Re: Please help me out on this insert error

From
Stephan Szabo
Date:
On Thu, 13 Jun 2002, Vernon Wu wrote:

> I, however, didn't use double quote mark when I created the table at all.

If you used an interface to generate the table def, alot of them add the
quote marks behind your back when they do the creation. In general, it's
safer to just use all lowercase names. :)



Re: Please help me out on this insert error

From
Manfred Koizar
Date:
On Thu, 13 Jun 2002 13:16:29 +0800, Vernon Wu
<vernonw@gatewaytech.com> wrote:
>
>Command:
>
>Insert into profile (userid, haveChildren)values('id98', 'No');
>
>Error:
>
>ERROR:  Relation 'profile' does not have attribute 'havaChildren'
^                                cut'n'paste error here ?
 

>Table:
>                 Table "profile"
>    Column    |         Type          | Modifiers
>--------------+-----------------------+----------
> userid       | character varying(25) | not null
> [...]
> haveChildren | character varying(20) | not null

Anyway, try
Insert into profile (userid, "haveChildren") values('id98', 'No');

ServusManfred


Re: Please help me out on this insert error

From
Vernon Wu
Date:
You are right, Steve. It needs the double quote mark. After I use the double quote mark, an error message is:

ERROR:  ExecAppend: Fail to add null value in not null attribute ...

which is right since I don't have non-null value to non-null field yet.

I, however, didn't use double quote mark when I created the table at all.

Now, I need to figure out how to add double quote mark in Java code query string.

v.

6/14/2002 6:12:18 AM, Stephan Szabo <sszabo@megazone23.bigpanda.com> wrote:

>On Thu, 13 Jun 2002, Vernon Wu wrote:
>
>>
>> Command:
>>
>> Insert into profile (userid, haveChildren)values('id98', 'No');
>
>You presumably used double quotes when creating the column, so
>you need to use them to refer to the column from that point on:
>
>insert into profile(userid, "haveChildren") ...
>
>
>





Re: Please help me out on this insert error

From
Vernon Wu
Date:
6/14/2002 6:31:16 AM, Stephan Szabo <sszabo@megazone23.bigpanda.com> wrote:

>
>On Thu, 13 Jun 2002, Vernon Wu wrote:
>
>> I, however, didn't use double quote mark when I created the table at all.
>
>If you used an interface to generate the table def, alot of them add the
>quote marks behind your back when they do the creation. 

That must be what really happended without my knowledge. I used the pgAdmin to create the table. So, it is safer to 
create tables using the command line.

In general, it's
>safer to just use all lowercase names. :)
>
>

That is a separated issue, is it?

Thanks.

v