Skip site navigation (1) Skip section navigation (2)

Calling Postgresql Function to delete user data

From: Rehan Saleem <pk_rehan(at)yahoo(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Calling Postgresql Function to delete user data
Date: 2012-02-11 19:53:37
Message-ID: 1328990017.24868.YahooMailNeo@web121603.mail.ne1.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hi ,
I have created this function to remove UserDataAccountid
from both tables
UserAccountDetails and UserAC 
CREATE OR REPLACE FUNCTION DeleteUserData(ACDetailsID int[])
RETURNS void AS $$
DECLARE _id int;
BEGIN
  -- postgresql has no table type, use a int array instead
  FOR _id IN array_lower(ACDetailsID,1) .. array_upper(ACDetailsID,1)
  LOOP
      DELETE FROM UserAccountDetails WHERE UserDataAcountId=
_id;
      DELETE FROM UserAC WHERE UserDataAcountId= _id;
    END;
  END LOOP;
  EXCEPTION WHEN OTHERS THEN
    RAISE WARNING 'some issue %', SQLERRM;
END;
$$ LANGUAGE plpgsql;
 
Now I am calling this function to delete userdataacountid
from both tables, say i have a user with userdataacountid '5', how can i delete
this user by calling this function , i have tried 

select DeleteUserData(5);
and
select * from DeleteUserData(5);

its not working ,
thanks

Responses

pgsql-sql by date

Next:From: Philip CoulingDate: 2012-02-12 13:02:20
Subject: Re: Calling Postgresql Function to delete user data
Previous:From: Jasen BettsDate: 2012-02-11 03:18:43
Subject: Re: time interval math

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group