On Sunday 02 December 2007 00:17:52 you 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;
Here was the culprit: 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 = old.id; OLD.id instead of 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 > [for Statement "UPDATE company__view SET modified = ?, shortname = ? WHERE > ( id = ? )" with ParamValues: 1='2007-12-01 23:03:10+0000', 3='68', > 2='diiasd'] at > /home/mario/Desktop/dev/projects/glue/code/glue/trunk/script/../lib/glueDB/ >Contact/Company.pm line 110 > > Running the given command from the pgadmin III Query Editor by hand works > also fine. > > I would be very thankfull if anyone could give me a hint where to hint this > error down. Greets, Mario ------------------------------------------------------- _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]