I am building a system. one of module needs to create a new table after a user insert a new record into an existed table. I make a procedure as follows:
CREATE OR REPLACE PROCEDURE my_create AS
v_maxtime usermeta.instime%TYPE;
v_tbname usermeta.uname%TYPE;
v_Sqlstring VARCHAR2(200);
BEGIN
SELECT MAX(instime) INTO v_maxtime FROM usermeta;
SELECT uname INTO v_tbname FROM usermeta WHERE instime=v_maxtime;
DBMS_OUTPUT.PUT_LINE(v_tbname);
v_SqlString:='CREATE TABLE ' || v_tbname || '(' || v_tbname || 'Date TIMESTAMP, '
||v_tbname||'Values NUMBER)';
DBMS_OUTPUT.PUT_LINE(v_sqlstring);
EXECUTE IMMEDIATE v_sqlstring;
END;
If the v_tbname:='Toms', I Want the SQL is 'CREATE TABLE Toms(TomsDate TIMESTAMP, TomsValues NUMBER). And I have a trigger as follows:
CREATE OR REPLACE TRIGGER my_insert
AFTER INSERT ON usermeta
DECLARE
v_maxtime mytemp1.instime%TYPE;
BEGIN
my_create;
END;
I compile it successful but run failed. Error code is: ORA-04092, ORA-06512, ORA-06512 and ORA-04088.
Ora-04092 describe as follows:
ORA-04092 cannot string in a trigger
Cause: A trigger attempted to commit or roll back.
Action: Rewrite the trigger so it does not commit or roll back.
Is a trigger can not commit? Or is there any other error in my program? How should I do to satisfy my need?