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!

Display SELECT data in "vertical" instead of "horizontal"

88440Oct 26 2006 — edited Oct 26 2006

Hello,

I know that subject is quite clueless, so I explain my need with a clear example.
I have a table, let's name it "LOG", with the following data:

TABLE: LOG

Time   Type   A    B    C    D
================================
15:01  INS    10   10   10   10 
15:02  UPD    10   20   10   10 
15:03  UPD    50   20   10   30 
15:04  UPD    50   10   10   30 

This table logs which action was taken (INSERT, UPDATE) in a certain table, and saves each field value (columns A to D).

My goal is to write a SELECT statement that, reading data from the LOG table, outputs the following:

Time   Type   Column   Oldvalue   Newvalue
============================================
15:01  INS    A        (NULL)     10
15:01  INS    B        (NULL)     10
15:01  INS    C        (NULL)     10
15:01  INS    D        (NULL)     10
15:02  UPD    B        10         20
15:03  UPD    A        10         50
15:03  UPD    D        10         30
15:04  UPD    B        20         10

That is, to display one record for each column value change.

Is there any chance to do it?
Thank you

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2006
Added on Oct 26 2006
6 comments
1,868 views