Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute a PL/SQL Database Modification function

Posted on 2014-10-02
5
Medium Priority
?
246 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 800 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 1200 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

721 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