Quick Trick About Using Dbms_Metadata With Forms_DDL In Oracle Forms

Example is given below to fetch any Oracle objects DDL script using DBMS_Metadata.Get_DDL command in Oracle Forms using Forms_DDL command.
 
You can download this form for free including source code with following link from Google Drive Dbms_Utility.fmb

You may need to create a table in current schema/user by which you are logging with and below is the script for this:

Create Table DDL_Script (ddl varchar2(1000));


I will add further more tabs related to Dbms utility tasks to this form and will share also.
 
 
Following is the code written in Show DDL push button:
DECLARE
   v        VARCHAR2 (4000);
   objtpe   VARCHAR2 (100);
BEGIN
   --    v := dbms_metadata.get_ddl('TABLE', :objname, user);
   SELECT object_type
     INTO objtpe
     FROM user_objects
    WHERE object_name = :objname;
 
   :objtype := objtpe;
 
   FORMS_DDL ('drop table ddl_script');
   FORMS_DDL(   'create table ddl_script as select dbms_metadata.get_ddl('
             || CHR (39)
             || objtpe
             || CHR (39)
             || ','
             || CHR (39)
             || :objname
             || CHR (39)
             || ', user) ddl from dual');
 
   IF FORM_SUCCESS
   THEN
      SELECT ddl
        INTO :ddltxt
        FROM ddl_script
       WHERE ROWNUM = 1;
   ELSE
      :statbar := 'Message: Object does not exists.';
      FORMS_DDL ('create table ddl_script (ddl varchar2(1000))');
   END IF;
END;
 
Following is the code written in When-new-form-instance trigger:
 
set_window_property(forms_mdi_window, window_state, maximize);
 
DECLARE
   rg_list_id   RECORDGROUP;
   rg_name      VARCHAR2 (20) := 'OBJECTTYPES';
   ret_code     NUMBER;
   --The following holds a SELECT query from which the list elements are derived.
   v_select     VARCHAR2 (300);
BEGIN
   BEGIN
      FORMS_DDL ('drop table ddl_script');
   EXCEPTION
      WHEN OTHERS
      THEN
         NULL;
   END;
 
   BEGIN
      FORMS_DDL ('create table ddl_script (ddl varchar2(1000))');
   EXCEPTION
      WHEN OTHERS
      THEN
         NULL;
   END;
 
   ret_code := POPULATE_GROUP ('OBJECTNAMES');
   POPULATE_LIST ('OBJNAME', 'OBJECTNAMES');
END;
 
You can find the record group details itself in form which I am sharing with this post.
posted @ 2016-12-25 19:15  全威儒  阅读(422)  评论(0编辑  收藏  举报