Re: Using a function to delete rows

From: Godshall Michael <Michael_Godshall(at)gmachs(dot)com>
To: 'Derrick Betts' <Derrick(at)grifflink(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Using a function to delete rows
Date: 2003-10-09 17:30:53
Message-ID: A596FA3368757645AF862C701495CA0001B4474D@hor1mspmx01.gmachs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I think you need to set the input parameter equal to a declared variable

The input variable is referenced via

DECLARE

your_int4_paramter ALIAS FOR $1;

Begin
Delete from clientinfo where caseid = your_int4_parameter;

-----Original Message-----
From: Derrick Betts [mailto:Derrick(at)grifflink(dot)com]
Sent: Thursday, October 09, 2003 12:25 PM
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Using a function to delete rows

How do I create a function that takes as input (int4) and then deletes rows
from several tables. This is what I have tried, but I can't get it to
execute:

CREATE OR REPLACE FUNCTION public.deleteclient(int4)
RETURNS Void AS
'
BEGIN
Delete from clientinfo where caseid = $1;
Delete from caseinfo where caseid = $1;
Delete from tracking where caseid = $1;
Delete from casenotes where caseid = $1;
Delete from creditinfo where caseid = $1;
Delete from debts where caseid = $1;
Delete from education where caseid = $1;
Delete from employer where caseid = $1;
Delete from family where caseid = $1;
Delete from formeremployer where caseid = $1;
Delete from income where caseid = $1;
Delete from other where caseid = $1;
Delete from specialinterests where caseid = $1;
Delete from tracking where caseid = $1;
END'
LANGUAGE 'plpgsql' VOLATILE;

Thanks,
Derrick

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Fromme 2003-10-09 17:42:43 Re: Using a function to delete rows
Previous Message Slava Gorski 2003-10-09 17:29:03 get diagnostics not supported by ecpg?