Re: problem with Pl/Pgsql function - Mailing list pgsql-sql

From Josh Berkus
Subject Re: problem with Pl/Pgsql function
Date
Msg-id web-70261@davinci.ethosmedia.com
Whole thread Raw
In response to problem with Pl/Pgsql function  ("Matteo Centenaro" <gente_che_mixa@hotmail.com>)
List pgsql-sql
Matteo,

> The error riported is:
> 
> Fail to add null value in not null attribute prefisso
> 
> The line which the error refere is:
> 
> id_lista := nextval('tab_estrazioni_id_seq');
> insert into tab_estrazioni values (id_lista, pre, tel);
> 
> Has Anybody any suggest? Thanks!

While my Italian isn't really good enough to analyze your function, the
above error seems simple.  tab_estrazioni probably has the field
prefisso, which is defined as NOT NULL with no default.  In the above
code, you're trying to add a record to tab_estrazioni filling in only
the columns id_lista, pre, and tel.  Without a default or a supplied
value, this inserts NULL into the prefisso column, which the database
rejects.

Thus the solution is to either: a) Change prefisso to NULL, b) give
prefisso a default, or c) supply a value for prefisso.  Unfortunatley,
the first two require dropping and re-creating the table.

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


pgsql-sql by date:

Previous
From: "Michael Richards"
Date:
Subject: finding a maximum or minimum sum
Next
From: "Josh Berkus"
Date:
Subject: Re: Table design issue....