Re: Problem with type in rule
От | Stephan Szabo |
---|---|
Тема | Re: Problem with type in rule |
Дата | |
Msg-id | 20011118143225.H39719-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Problem with type in rule (Sharon Cowling <sharon.cowling@sslnz.com>) |
Список | 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
В списке pgsql-general по дате отправления: