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.
 
dbms_uti.JPG
 
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.

转载于:https://www.cnblogs.com/quanweiru/p/6220238.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值