Subject | Re: [ib-support] Stored Procedure question |
---|---|
Author | Helen Borrie |
Post date | 2003-01-22T23:47:18Z |
At 11:21 PM 22/01/2003 +0000, you wrote:
doesn't apply to your example) you can't perform metadata operations from
PSQL either.
You can pass any constant as an argument. So (using your example) if you
wanted a proc that could delete rows from any one of a set of tables, you
can keep your declaration as it is, but use the table name parameter to
condition which table gets operated on, from a series of IF...ELSE.. blocks.
Create Procedure Delete_From_Table( ATableName Char(20)) as
begin
if (ATableName = 'Customer') then
begin
Delete from Customer;
end
else if (ATableName = 'CustOrder') then
begin
Delete from CustOrder;
end
else if.....
................
end ^
heLen
>This may be easy, but I haven't found anything in the documentationYou can't pass metadata objects to SPs or triggers at all. FWIW (though it
>to point me in the right direction.
>
>How could I pass a tablename in through a stored procedure?
>
>Ie
>
>Create Procedure Delete_From_Table( ATableName Char(20)) as
>begin
> Delete from :ATableName;
>end;
>
>I know the above doesn't work because that is what I tried, but I
>think you get the idea of what I am trying to do.
doesn't apply to your example) you can't perform metadata operations from
PSQL either.
You can pass any constant as an argument. So (using your example) if you
wanted a proc that could delete rows from any one of a set of tables, you
can keep your declaration as it is, but use the table name parameter to
condition which table gets operated on, from a series of IF...ELSE.. blocks.
Create Procedure Delete_From_Table( ATableName Char(20)) as
begin
if (ATableName = 'Customer') then
begin
Delete from Customer;
end
else if (ATableName = 'CustOrder') then
begin
Delete from CustOrder;
end
else if.....
................
end ^
heLen