How to query for columns without using column names [message #586363] |
Wed, 05 June 2013 09:23  |
bws93222
Messages: 27 Registered: April 2009
|
Junior Member |
|
|
I have limited permissions and am unable to create temp tables.
So I would like to use a cursor to "create" a table of sorts
then access/query it. But this "table"/cursor would have no column names so
how do I refer to the columns? Is there a way to refer to a column
by column number rather than column name in a query:
select column1 from tablename where column2 = 'abc'?
Below is a very rough and simplified code example that I hope gives you some idea
what I am trying to do--if it has errors, please don't focus on them or suggest
other approaches--instead, please understand that the only question I have is:
Is there a way in a query/update/insert to refer to a column by column number rather
than column name?
declare
cursor c1 is
select 'abc', '8-Apr-2013', pk_id from EMPLOYEE where pk_id = '153'
UNION
select '1xyz', '4-10-2013', pk_id from EMPLOYEE where pk_id = '154'
c1_val number;
begin
c1_val := 0;
for c1_val in c1
loop
update EMPLOYEE set EMPLOYEE.DATE = c1.(what?-I want to refer to the date value in the cursor above but it has no column name- I need to refer to column number #2 ) where pk_id = '153'
--- insert into tbl (columns) value (data);
end loop;
end;
[Updated on: Wed, 05 June 2013 09:24] Report message to a moderator
|
|
|
|
|
|
|