[Dbix-class] Error on updating a row in a rewritten view doesn't work

Mario Minati mario.minati at googlemail.com
Sun Dec 16 22:35:46 GMT 2007


On Sunday 16 December 2007 02:56:12 Matt S Trout wrote:
> On Sun, Dec 02, 2007 at 12:17:52AM +0100, Mario Minati wrote:
> > I have got a problem updating a view ;-)
> >
> > The class was working smoothly as long as I used the table ('company')
> > itself to crud the data.
> >
> > Now I switched to a view with the following rules:
> >
> > CREATE OR REPLACE RULE company__view__ins_instead AS
> >     ON INSERT TO company__view DO INSTEAD
> > INSERT INTO company (name, subname, website, shortname, uuid, modified,
> > legalform_id, historic_id)
> > VALUES (new.name, new.subname, new.website, new.shortname, new.uuid,
> > new.modified, new.legalform_id, 0);
> >
> > CREATE OR REPLACE RULE company__view__upd_instead AS
> >     ON UPDATE TO company__view DO INSTEAD
> > UPDATE company SET name = new.name, subname = new.subname, website =
> > new.website, shortname = new.shortname, modified = new.modified,
> > legalform_id = new.legalform_id
> > WHERE company.id = new.id;
> >
> > Reading and inserting is working fine as expected.
> >
> > But updating creates an error:
> >
> > DBIx::Class::Relationship::CascadeActions::update(): DBI Exception:
> > DBD::Pg::st execute failed: ERROR:  bind message supplies 3 parameters,
> > but prepared statement "dbdpg_22" requires 2
>
> That's usually prepared statements getting confused because you've changed
> the schema and DBIC didn't know to reconnect.
>
> If a server restart didn't fix it, next thing would be to try a DBIC_TRACE
> and see where dbdpg_22 is originally created.

Thanks Matt,

it was exactly that. 
I thought I posted my solution on this topic already. Sorry if I fogot about 
it. 

Greets,
Mario



More information about the DBIx-Class mailing list