Home » SQL & PL/SQL » SQL & PL/SQL » Dynamic creation of Table using triggers.
Dynamic creation of Table using triggers. [message #1835] Mon, 03 June 2002 21:03 Go to next message
Vinu Menon
Messages: 1
Registered: June 2002
Junior Member
Hi !

I've create a table named "A" with 4 fields viz. ID, Name, Age and Sex.

Now , I want to create a trigger on this table, which should fire the following event :-

After a new record is inserted in to the table, the trigger should automatically create a new table by the name entered in the Name field by the user.
For example, if I enter "VINU" in the Name field, then
the trigger should automatically create a new table by the name VINU with some fields.

I would be really greatful, if you could provide a soulution for the aforesaid problem.

Thanks and regards

Vinu Menon
Re: Dynamic creation of Table using triggers. [message #1840 is a reply to message #1835] Tue, 04 June 2002 02:49 Go to previous messageGo to next message
JoJo
Messages: 18
Registered: January 2002
Junior Member
i think you can t use DDL (data manipulation language: ie create,drop...) in a trigger ,you can only use DML(data manipulation language:ie select,update,etc..).
Re: Dynamic creation of Table using triggers. [message #1854 is a reply to message #1835] Tue, 04 June 2002 23:22 Go to previous message
JoJo
Messages: 18
Registered: January 2002
Junior Member
And if you use oracle version prior to 8i ,you can use:

declare
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur, 'create TABLE table_test(id number )', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;

I found it in the PL/SQL FAQ of this site,it is full of great info.
Previous Topic: update table with another table
Next Topic: Re: Find Numbers
Goto Forum:
  


Current Time: Fri Apr 26 15:25:15 CDT 2024