2

Is it possible to somehow log what a SQL-statement results in. For example:

INSERT INTO bonus SELECT ename, job, sal, comm FROM emp
WHERE comm > sal * 0.25;

How to get which rows that are acually inserted (or updated or deleted if it's another query), instead of just getting "5 rows inserted.". It would be especially nice if it's possible to get the change in SQL-form.

kaze
  • 4,299
  • 12
  • 53
  • 74

1 Answers1

1

This works in SQL Server, but I'm afraid I don't know of an Oracle equivalent. (Not what you're looking for, I know, but it might get you closer...)

create table foo (
    bar int
)

insert into foo
output inserted.*
values (1)

update foo
set bar = bar + 1
output deleted.*, inserted.*

delete
from foo
output deleted.*

All I know of in Oracle is the sql%rowcount variable: Number of rows affected by an UPDATE in PL/SQL

EDIT

Oracle does have an equivalent, the RETURNING clause: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm

Community
  • 1
  • 1
John N
  • 1,755
  • 17
  • 21