Q:

PL/SQL table and column alias

I want to know if there is something like an alias for table and columns in plsql.
I want to do something like this (pseudocode):
if (foo) 
then
   alias bla_table = tablenameA
   alias bla_column = coulmnnameA
else
   alias bla_table = tablenameB
   alias bla_column = coulmnnameB
end

select bla_column from bla_table;

A:

There are some ways to archive a similar effect; probably the easiest way is to declare a cursor and, depending on the if path, open it for different queries.
Example taken from the Oracle Documentation:
CREATE PACKAGE emp_data AS
   TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
   PROCEDURE open_emp_cv (emp_cv IN OUT EmpCurTyp, choice IN INT);
END emp_data;

CREATE PACKAGE BODY emp_data AS
   PROCEDURE open_emp_cv (emp_cv IN OUT EmpCurTyp, choice IN INT) IS
   BEGIN
      IF choice = 1 THEN
         OPEN emp_cv FOR SELECT * FROM emp WHERE comm IS NOT NULL;
      ELSIF choice = 2 THEN
         OPEN emp_cv FOR SELECT * FROM emp WHERE sal > 2500;
      ELSIF choice = 3 THEN
         OPEN emp_cv FOR SELECT * FROM emp WHERE deptno = 20;
      END IF;
   END;
END emp_data;

