Solved

Execute a PL/SQL Database Modification function

Posted on 2014-10-02
5
245 Views
Last Modified: 2014-10-02
I know that
COMMENT on table EMPLOYEE is 'This is the employee table';
will embed a table comment.  

How can this be executed in a function or stored procedure?

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 200 total points
ID: 40358052
This was answered in your other question:
http://www.experts-exchange.com/Database/Oracle/Q_28529930.html#a40357466

I suggested there that DDL inside Pl/SQL is typically frowned upon.

Why do you want to perform DDL that should only be executed once inside a procedure?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 300 total points
ID: 40358058
CREATE OR REPLACE PROCEDURE set_comment(
    p_owner     IN VARCHAR2,
    p_table     IN VARCHAR2,
    p_comment   IN VARCHAR2
)
IS
BEGIN
    EXECUTE IMMEDIATE
        'comment on table "' || p_owner || '"."' || p_table || '" is ''' || p_comment || '''';
END;
0
 

Author Comment

by:Dovberman
ID: 40358146
There are no table or column comments at my current workplace.  I will create a form that populates table names in a list box.   The user selects a table. Then the selected table's columns are listed. A textbox accepts a comment entry. The save button triggers the action to add or update the comment.

I am new to Oracle and needed to know the best technique to use.

Thanks
0
 

Author Closing Comment

by:Dovberman
ID: 40358156
Thanks,
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40358273
>> The user selects a table. Then the selected table's columns are listed. A textbox accepts a comment entry. The save button triggers the action to add or update the comment.

You already accepted this before I could comment on this.

I believe you are over complicating the process with the one exception below:  Security.

Personally I wouldn't create an application for this.  The 'Users' of it would likely need to be the DBA's or developers that created the schema since they know what the tables and columns actually mean.

They should be able to provide you a simple SQL script with the correct COMMENT commands.  Then just execute the script.

It would be just as easy to create an Excel spreadsheet with the tables and columns then turn that into a script.

That said:
The only reason to create a procedure to do this is for security purposes.  The app connects to the database with a username that has only been granted execute on the procedure above.

If the app connects to the database as the owner of the tables, no need for the procedure.  ALL programming languages can execute native SQL.  No need for Pl/SQL.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question