0

I have a procedure where I am using %TYPE to declare my variable. As of now its working for only one table i.e. EMPLOYEES:

CREATE OR REPLACE PROCEDURE MYPROCEDURE
DECLARE
filed2 EMPLOYEES.name%TYPE;
END;

Now I want to extent it for others table which have same few common tables. So I will pass the table name as parameter. Here how can use the TYPE syntax because table name is in variable. If I am trying this:

CREATE OR REPLACE PROCEDURE MYPROCEDURE (myTable IN VARCHAR2)
DECLARE
filed2 myTable.name%TYPE;
END; 

I am getting an error. How can I achieve it?

1 Answer 1

1

No, you can't. Type declaration is static. It can be inferred using %type, but that will still compile to a static type definition.

In your case, you try to reference a 'property' from a varchar2, which is not possible (Oracle doesn't have properties on varchar2).

Sign up to request clarification or add additional context in comments.

1 Comment

@CrazyC: need more help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.