You are on page 1of 1

-------------------- EXAMPLE 4 - INSERTs WITHIN A TRANSACTION

------------------------
SELECT SYSTEM$STREAM_GET_TABLE_TIMESTAMP('employees_stream');

SELECT to_timestamp(SYSTEM$STREAM_GET_TABLE_TIMESTAMP('employees_stream')) as
stream_offset;

BEGIN;

show transactions;

-- insert values in employees table


insert into employees values(12,50000,9),
(86,90000,4),
(73,20000,1);

-- The stream records the inserted rows


select * from employees_stream;

COMMIT;

select * from employees_stream;

-- Consume the stream


create or replace table employees_consumer(employee_id number,
salary number);

insert into employees_consumer select employee_id, salary from employees_stream;

select * from employees_consumer;

DROP STREAM EMPLOYEES_STREAM;

ALTER STREAM EMPLOYEES_STREAM SET COMMENT = 'This stream is used to capture changes
from employees table';

SHOW STREAMS;

You might also like