From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Ângelo Marcos Rigo <angelo_rigo(at)yahoo(dot)com(dot)br> |
Cc: | Michael Glaesemann <grzm(at)myrealbox(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: How to set a Default Value |
Date: | 2006-01-13 18:29:54 |
Message-ID: | 20060113182954.GA98381@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Fri, Jan 13, 2006 at 05:40:25PM +0000, ngelo Marcos Rigo wrote:
> My table definition (i change the deafult to 'N') :
>
> CREATE TABLE pautaitem
> (
> cdpautaitem serial NOT NULL,
> arquivo varchar(255),
> item varchar(255),
> cdpauta varchar(255),
> cditem varchar(11) NOT NULL DEFAULT 'N',
> CONSTRAINT pauta_arquivos_pkey PRIMARY KEY
> (cdpautaitem)
> )
>
> My insert query:
>
> INSERT INTO PautaItem (
> CdPauta,
> Item,
> CdItem,
> Arquivo) VALUES (
> '"+this.sCdPauta',
> '"+this.sItem',
> '"+this.sCdItem',
> '"+this.sArqImagem')
What was the result and how does it differ from what you were
expecting? When I run the above statements I get
ERROR: value too long for type character varying(11)
I assume the '"+this.sCdItem' values aren't literal but are going
to be interpolated into the INSERT statement by your application.
If that's the case, what does the final INSERT statement look like?
I'd guess you're inserting an empty string instead of NULL into the
cditem column, in which case the default expression won't be used.
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | me | 2006-01-14 16:47:41 | help with query: advanced ORDER BY... |
Previous Message | Ângelo Marcos Rigo | 2006-01-13 17:40:25 | Re: How to set a Default Value |