Is there an alternate way to create a table using a procedure?

    Requires Free Membership to View

You can use the EXECUTE IMMEDIATE command in your stored procedure to run DDL to create a table, similar to the following:
CREATE PROCEDURE my_proc AS
BEGIN
   EXECUTE IMMEDIATE 'CREATE TABLE foo (bar NUMER)';
END;
/
However, it is almost always poor design to run DDL inside a stored procedure. Typically, we do no let our users create tables on the fly by running a stored proc in their application code.

This was first published in May 2006

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.