From: Rehan Saleem <pk_rehan@yahoo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Calling Postgresql Function to delete user data
Date: Sat, 11 Feb 2012 11:53:37 -0800 (PST)
Message-ID: <1328990017.24868.YahooMailNeo@web121603.mail.ne1.yahoo.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pk_rehan@yahoo.com
Subject: Re: Calling Postgresql Function to delete user data
In-Reply-To: <1328990017.24868.YahooMailNeo@web121603.mail.ne1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox