PL/SQL (MOSC)

MOSC Banner

how to reference columns as dynamic selectables in select query

edited Jul 29, 2013 6:01AM in PL/SQL (MOSC) 5 commentsAnswered
cursor C1 is
select col1, col2 from table1;

/*  assume col1 is returning EMP_NAME & col2 is returning EMP_ID*/

in the code we are referring to C1 as below

OPEN C1

FETCH into l_col1, l_col2; /*l_col1 & l_col2 are user defined variables in the procedure */


select  l_col1,l_col2 fetch into l_emp_name, l_emp_id from EMP_DETAILS; /* l_emp_name and l_emp_id are user defined variables in the procedure */

/* we are expecting the query to be evaluated as below.

select EMP_NAME ,EMP_ID fetch into l_emp_name, l_emp_id from EMP_DETAILS;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center