чего я хочу достичь, так это того, что у меня есть таблица заказов.
я хочу выполнить триггер до вставки в моей таблице заказов. я хочу захватить
имя пользователя лица, выполняющего вставку в таблицу.
одна таблица с именем info, содержащая пользователя.
это мой код
create table orders
(
order_id int,
quantity int,
cost int,
total_cost int,
created_date datetime,
created_by varchar(20)
)
create trigger beforeInsertdata
before insert
on orders
for each row
declare
v_username varchar2(10);
begin
-- Find username of person performing INSERT into table
SELECT user INTO v_username
FROM info;
-- Update create_date field to current system date
:new.create_date := sysdate;
-- Update created_by field to the username of the person performing the INSERT
:new.created_by := v_username;
END;
--user information--
create table info
(
userid int ,
user_name varchar(10)
)
insert into info values(1,'vivek')
select * from info