I have a function as follows:
CREATE OR REPLACE FUNCTION func(a integer)
RETURNS integer AS
$BODY$
begin
for row in
Select id from table_a where quantity=1
loop
do something
end loop
end;
$BODY$
LANGUAGE plpgsql VOLATILE
I need to change this function to take another parameter which tells if to use table_a or table_b.
when whichtouse=1 I need to use table_a.
when whichtouse=2 I need to use table_b.
CREATE OR REPLACE FUNCTION func(a integer,whichtouse integer)
RETURNS integer AS
$BODY$
begin
for row in
Select id from ??? where quantity=1
loop
do something
end loop
end;
$BODY$
LANGUAGE plpgsql VOLATILE
How can I determin which table to use?