About SP's and parameters

From: Alfonso Peniche <alfonso(at)iteso(dot)mx>
To: pgsql-general(at)postgresql(dot)org
Subject: About SP's and parameters
Date: 2001-02-08 22:40:27
Message-ID: 3A83205B.A4F2E2FC@iteso.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all:

Is there a way to pass a tablename as a parameter to a SP?

I'll try to explain myself. I want to create a SP that can, for
instance, do a delete from ...... so that any particular application all

it has to do is call the SP sending the table to be deleted.

Right now I have:

CREATE FUNCTION deleteanytable (bpchar)
returns integer
as '
begin
delete from $1;

return 1;
end;'
language 'plpgsql';

If I call it:
select deleteanytable ( mytable );

I get a message saying

ERROR: Attribute 'mytable' not found

Thanks for your help.

P.S. It would be very interesting if a columnname could also be sent as
a parameter to the Stored Procedure.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvar Freude 2001-02-08 23:05:39 Re: Varchar Indexing, Null Bytes
Previous Message The Hermit Hacker 2001-02-08 22:35:22 Re: [GENERAL] Re: full text searching