Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using PL/SQL to retrieve column names and column values

666644Sep 26 2009 — edited Sep 30 2009
If I have a table as follows

Table A(
meal varchar2(32),
beverage varchar2(32),
desert varchar2(32));

and the table contains a row

meal beverage desert
-------------------------------------------------------
pork chops iced tea apple crisp


Is there a way in pl/sql to retrieve the column names along with the values. I have an object type
DATA_DEFINITION_T AS OBJECT (
"FIELD_NAME" VARCHAR2(32),
"FIELD_VALUE" VARCHAR2(32)

I need to store the column name in field_name and the column value in field_value.

So the result would be:

FIELD_NAME = meal
FIELD_VALUE = pork_chops

FIELD_NAME = beverage
FIELD_VALUE = iced tea

FIELD_NAME = desert
FIELD_VALUE = apple crisp

Thanks in advance.
This post has been answered by Peter Gjelstrup on Sep 26 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 28 2009
Added on Sep 26 2009
7 comments
5,515 views