Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Affected # of R...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 15528 of 17437
Post > Topic >>

Affected # of Rows After TRIGGER/RULE Return

by yazicivo@[EMAIL PROTECTED] (Volkan YAZICI) May 13, 2008 at 05:59 PM

Hi,

I'm trying to fake DELETEs to a table using below methods:

  CREATE OR REPLACE FUNCTION mobileunit_fake_delete() RETURNS trigger AS
$$
  BEGIN
      UPDATE mobileunit
         SET networkid = OLD.networkid + OLD.muid * 100000000000,
             groupid = 146688,
             plate = 'DELETED_' || OLD.plate
       WHERE muid = OLD.muid;
  
      RETURN NULL;
  END;
  $$ LANGUAGE plpgsql;
  
  CREATE TRIGGER mobileunit_fake_delete
      BEFORE DELETE ON mobileunit
      FOR EACH ROW EXECUTE PROCEDURE mobileunit_fake_delete();
  
or

  CREATE RULE mobileunit_fake_delete
  AS ON DELETE TO mobileunit
  DO INSTEAD
  UPDATE mobileunit
     SET networkid = CAST(OLD.networkid AS numeric(20)) + OLD.muid *
100000000000,
         groupid = 146688,
         plate = 'DELETED_' || OLD.plate
   WHERE muid = OLD.muid;

But unfortunately, both solutions make

  DELETE FROM mobileunit WHERE muid = ...

queries return 0 as # of affacted rows. And this causes JDBC
applications (specifically Hibernate) ROLLBACK query as some failure
occured. At least, shouldn't the latter one return 1 as # of affected
rows? Any ideas to fix this problem?


Regards.

P.S. Yep, I know code sucks badly. Trying to migrate a Microsoft SQL
     Server application to PostgreSQL.

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 5 Posts in Topic:
Affected # of Rows After TRIGGER/RULE Return
yazicivo@[EMAIL PROTECTED  2008-05-13 17:59:27 
Re: Affected # of Rows After TRIGGER/RULE Return
bopolissimus.lists@[EMAIL  2008-05-14 16:56:59 
Re: Affected # of Rows After TRIGGER/RULE Return
yazicivo@[EMAIL PROTECTED  2008-05-14 10:10:18 
Re: Affected # of Rows After TRIGGER/RULE Return
bopolissimus.lists@[EMAIL  2008-05-14 20:07:04 
Re: Affected # of Rows After TRIGGER/RULE Return
yazicivo@[EMAIL PROTECTED  2008-05-14 11:33:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 11:56:14 CST 2008.