Retrieving counts from an insert operation
271736Jun 21 2007 — edited Jun 22 2007Hello,
I'm using SQL to do an insert (it needs to be done in SQL) and I want to get the count of the records inserted:
INSERT INTO target
(LINK,
ENGLISHNAME,
FRENCHNAME, ...
)
SELECT
a.LINK,
a.ENGLISHNAME,
a.FRENCHNAME, ...
FROM
source a,
target b
WHERE
(
(a.LINK = b.LINK(+))
AND (a.LINK IS NOT NULL)
AND (b.LINK(+) IS NULL)
);
Sql*plus will show the records inserted;
66 rows inserted
But I need to capture this count for a logging table that I've created.
Is there a simple way to do this? Right now I run the select statement twice, once to get the count and then the second time to do the insert...