Re: Problem with null timestamp fields - Mailing list pgsql-general

From Jason Earl
Subject Re: Problem with null timestamp fields
Date
Msg-id 20010628031555.5488.qmail@web10003.mail.yahoo.com
Whole thread Raw
In response to Problem with null timestamp fields  ("Thomas T. Veldhouse" <veldy@veldy.net>)
List pgsql-general
There is a difference between "login_ts" and the
"login_ts " (notice the extra space) that I see in
your create statement.

I got the same error by using your example, but when I
changed the insert to look like this:

insert into user_history(id, userid, ipaddr,
"login_ts ") values (1, 2, '127.0.0.1', now());

Notice the " characters and the space.

Because of ambiguities like that I tend to create my
tables without the '"' character.  I also don't use
the formal 'timestamp with time zone' (but mostly
because timestamp is easier to type).

Try this:

CREATE TABLE user_history (
    id integer DEFAULT
nextval('user_history_id_seq'::text) NOT NULL,
    userid integer NOT NULL    ,
    ipaddr character(15) NOT NULL,
    login_ts  timestamp with time zone,
    logout_ts  timestamp with time zone,
    Constraint user_history_pkey Primary Key (id)
);


Jason

--- "Thomas T. Veldhouse" <veldy@veldy.net> wrote:
> Here is the table I have.
>
> CREATE TABLE "user_history" (
>         "id" integer DEFAULT
> nextval('"user_history_id_seq"'::text) NOT
> NULL,
>         "userid" integer NOT NULL,
>         "ipaddr" character(15) NOT NULL,
>         "login_ts " timestamp with time zone,
>         "logout_ts " timestamp with time zone,
>         Constraint "user_history_pkey" Primary Key
> ("id")
> );
>
>
> I try this:
>
> insert into user_history(id, userid, ipaddr,
> login_ts)
> values (1, 2, '127.0.0.1', now())
>
> And I get this:
>
> PostgreSQL said: ERROR: Relation 'user_history' does
> not have attribute
> 'login_ts'
>
> Obviously, I DO have login_ts.  The field is
> nullable, so why the headache?
>
> Thanks in advance,
>
> Tom Veldhouse
> veldy@veldy.net
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

pgsql-general by date:

Previous
From: Philip Molter
Date:
Subject: Re: Re: Red Hat to support PostgreSQL
Next
From: "Thomas T. Veldhouse"
Date:
Subject: Re: Problem with null timestamp fields