views:

77

answers:

1
CREATE PROCEDURE A(tab IN <table - what should I write here?>) AS
BEGIN
   INSERT INTO tab VALUES(123);
END A;

How can I specify that the parameter tab is a table name?

+6  A: 

You can't. Instead you need to pass it in as a VARCHAR2 string and then use Dynamic SQL:

CREATE PROCEDURE A(tab IN VARCHAR2) AS
BEGIN
   EXECUTE IMMEDIATE 'INSERT INTO ' || tab || 'VALUES(123)';
END A;

Read up about Dynamic SQL and be aware of the issues it can bring if used unwisely, such as poorer performance, scalability and security.

Tony Andrews
@Tony: thanks! Please have a look at [this question](http://stackoverflow.com/questions/3440516).
Amoeba