1
我需要pl/sql程序的幫助。我創建了一個過程,當客戶端表插入時,它將自動爲新客戶端生成用戶名和密碼。該過程通過執行該過程的觸發器來初始化。問題是插入客戶端表發生好,但沒有生成用戶名和密碼。爲了發生這種情況,我必須在插入後運行過程。使用pl/sql程序創建用戶
CREATE PROCEDURE procedure_new_clients
var_assign_user clients VARCHAR2(1000);
BEGIN
FOR my_c IN (SELECT client_fname, client_lname FROM clients)
LOOP
var_assign_user := 'CREATE USER "' || my_c.client_fname || '" IDENTIFIED BY "' || my_c.client_lname|| '"';
EXECUTE IMMEDIATE var_assign_user; COMMIT;
END LOOP;
END procedure_new_clients;
CREATE TRIGGER trigger_new_clients
AFTER INSERT ON clients
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
WHEN (NEW.client_id NOT NULL)
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
procedure_new_clients();
END;