0
2つの表に複数の行を挿入するSQLを作成しました。しかし、最初の行を最初のテーブルに挿入するだけです。誰でもこの機会に私を助けてくれますか?ここでは、以下の::oracleは、1つの挿入クエリを使用して複数の表に複数の行を挿入します。
私の試み私の手順>>
PROCEDURE NEW_USER_PRIVELEGE_HIERCHY
(
IN_CREATED_BY IN VARCHAR2,
IN_MODIFIED_BY IN VARCHAR2,
IN_USERNAME IN VARCHAR2
)
AS
L_USER_ID INTEGER;
L_PRIVILEGE_ID INTEGER;
L_HIERCHY_ID INTEGER;
N_USER_ID INTEGER := hibernate_sequence.NEXTVAL;
BEGIN
SELECT case
when exists(SELECT USER_ID FROM T_MT_USER WHERE USERNAME = IN_USERNAME)
then
(SELECT USER_ID FROM T_MT_USER WHERE USERNAME = IN_USERNAME)
else 0
end into L_USER_ID
FROM dual;
IF (L_USER_ID = 0) THEN
INSERT INTO T_MT_USER
(USER_ID, ACCOUNT_EXPIRED_FLG, ACCOUNT_LOCKED_FLG, created_by, CREATED_TS, ACTIVE_FLG, end_effective_dt, modified_by, MODIFIED_TS, "password", password_expired, start_effective_dt, username)
VALUES
(N_USER_ID, 0, 0, IN_CREATED_BY, SYSTIMESTAMP, 1, NULL, IN_MODIFIED_BY, SYSTIMESTAMP, '$2a$10$3hoAeeVJ0AG.CQS2xX8rT.wUlt1rjoiYsHW0YflZEiQ5QYzG4HpYi', 0, SYSTIMESTAMP, IN_USERNAME); -- for Synergy1!
-- start inserting in privilege talbe
insert into T_MT_USER_PRIVILEGE (privilege_id,user_id, created_by, CREATED_TS, modified_by,MODIFIED_TS) values (8001,N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_PRIVILEGE (privilege_id,user_id, created_by, CREATED_TS, modified_by,MODIFIED_TS) values (8003,N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_PRIVILEGE (privilege_id,user_id, created_by, CREATED_TS, modified_by,MODIFIED_TS) values (8004,N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_PRIVILEGE (privilege_id,user_id, created_by, CREATED_TS, modified_by,MODIFIED_TS) values (8007,N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_PRIVILEGE (privilege_id,user_id, created_by, CREATED_TS, modified_by,MODIFIED_TS) values (8010,N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
-- start inserting in hierchy table
insert into T_MT_USER_HIER_NODE (hier_node_id, user_id, created_by, CREATED_TS, modified_by, MODIFIED_TS) values (101, N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_HIER_NODE (hier_node_id, user_id, created_by, CREATED_TS, modified_by, MODIFIED_TS) values (102, N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_HIER_NODE (hier_node_id, user_id, created_by, CREATED_TS, modified_by, MODIFIED_TS) values (103, N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_HIER_NODE (hier_node_id, user_id, created_by, CREATED_TS, modified_by, MODIFIED_TS) values (5626, N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
insert into T_MT_USER_HIER_NODE (hier_node_id, user_id, created_by, CREATED_TS, modified_by, MODIFIED_TS) values (6548, N_USER_ID, IN_CREATED_BY, sysdate, IN_MODIFIED_BY, sysdate);
END IF;
EXCEPTION
WHEN OTHERS THEN
log_api.fatal(log_ctx,'Exception in NEW_USER_PRIVELEGE_HIERCHY');
RAISE;
END NEW_USER_PRIVELEGE_HIERCHY;
は、私があまりにもinsert all
が、運を試してみましたが、私のプロシージャの呼び出し>>
execute USER_DEMO.NEW_USER('sbappi', 'sbappi', 'sumon8');
です。
プロシージャコールでエラーが発生しましたか。タイトルによれば、私は他の製品のタグを削除しました。 – Aleksej
いいえ、エラーは表示されません –
ここで 'log_ctx'が宣言されていますか? –