[clug-progsig] Help with PHP/Postgres problem?

Nick W nickw77 at shaw.ca
Thu Sep 16 08:26:59 PDT 2004


On September 16, 2004 12:40 am, Shawn wrote:
> I'm trying to do an insert into a postgres table, and either my eyes are
> shot, or there's something odd happening.
>
> Here's the error:
>
> Warning: pg_query(): Query failed: ERROR: ExecInsert: Fail to add null
> value in not null attribute time_id in /home/www/_timerecord.php on line 57
>

my guess...

since you didn't include time_id in your query, it's attempting to fill that 
field with NULL, and the field was specified to not allow NULL values, or is 
the primary key.

> and this is the SQL statement being executed:
>
> insert into time_record (user_id, client_id, svc_type, start_time,
> end_time, duration, comment) values ( 4, 2, 1, '15 Sep 2004 23:11', '15 Sep
> 2004 23:21', 10, 'TESTING')
>
> Now, the time_record table has an additional field called time_id.  At
> first glance it would appear that my problem is that I'm not inserting a
> value into this field.  However time_id is the primary key and is based on
> a sequence (serial datatype).  So, by NOT specifying the field, it should
> be getting the next ID from it's sequence.  But I'm seeing this error
> instead...
>
> I've checked the permissions on the table, and that is not the issue.  I've
> also ensured the permissions are correct on the sequence itself, with no
> difference.
>
> Any tips or suggestions?  (I'll feel stupid if I look at this tomorrow, and
> find a simple solution - but that's the case sometimes....)
>
> Shawn
>
> _______________________________________________
> clug-progsig mailing list
> clug-progsig at clug.ca
> http://clug.ca/mailman/listinfo/clug-progsig_clug.ca



More information about the clug-progsig mailing list