From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Sharon Cowling <sharon(dot)cowling(at)sslnz(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Problem with type in rule |
Date: | 2001-11-18 22:36:34 |
Message-ID: | 20011118143225.H39719-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, 18 Nov 2001, Sharon Cowling wrote:
> Hi
>
> I have rule for a view for inserting into one table and updating another.
> Problem: I get the following error when I create the rule:
>
> ERROR: Attribute 'permit_printed' is of type 'int4' but expression is of type 'varchar'
> You will need to rewrite or cast the expression
>
> I don't understand this as I am inserting 1 into the database, which is an int!
>
> INSERT into ltft_permit
> VALUES(new.permit_id,new.person_id,new.date_from,new.date_to,new.location,
> new.purpose,new.subpurpose,new.vehicle_rego,new.vehicle_type,new.dogs,
> new.permit_conditions,new.other_info,new.issued_by,new.issue_date,
> new.firearms_licence,new.drivers_licence,1);
As a suggestion, list the columns on your insert. That way it's much
easier to figure out what data goes with what column:
Looking at the columns below and the data above it looks like you put
the 1 in the wrong place. The last 3 columns should be permit_printed,
firearms_licence, drivers_license, where above you're using
firearms_licence, drivers_license, permit_printed. The ordering
is the table's ordering unless you specify column names.
> Table:
> user=> \d ltft_permit
> Table "ltft_permit"
> Attribute | Type | Modifier
> -------------------+------------------------+----------
> permit_id | integer | not null
> person_id | integer | not null
> date_from | date | not null
> date_to | date | not null
> location | character varying(30) | not null
> purpose | character varying(30) | not null
> subpurpose | character varying(30) | not null
> vehicle_rego | character varying(6) |
> vehicle_type | character varying(30) |
> dogs | character varying(3) |
> permit_conditions | character varying(200) |
> other_info | character varying(100) |
> issued_by | character varying(12) | not null
> issue_date | date |
> permit_printed | integer |
> firearms_licence | character varying(20) |
> drivers_licence | character varying(10) |
> Index: ltft_permit_pkey
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Ondruska | 2001-11-18 22:46:20 | build fails on Solaris 8 x_86 with Sun compiler |
Previous Message | David Wheeler | 2001-11-18 21:36:13 | Re: DBD::Pg BYTEA Character Escaping |