Using dbms_metadata.get_ddl to capture the alter table
Hi there,
I know you can capture table ddl using dbms_metadata.get_ddl. However, I want to capture all the changes after the table got created. If you created a table then add one or more columns. I just want to capture the change as the new columns added.
Here's an example.
Create table test (id number, name varchar2(20);
then
alter table test add (type varchar2(40);
I want to capture the syntax "alter table test add (type varchar(40)". Is this possible?
Thanks
I dont belive you could easily use dbma_metadata to do this... but you can use a database or schema level trigger e.g. :
create or replace trigger test.test_trigger
AFTER ALTER
ON DATABASE
DECLARE
sql_text ora_name_list_t;
v_stmt VARCHAR2(2000);
n number;
BEGIN
n := ora_sql_txt(sql_text);
FOR i IN 1..n
LOOP
v_stmt := v_stmt || sql_text(i);
END LOOP;
INSERT INTO test.test_table2
VALUES
(v_stmt);
END;
This will capture all alter commands fired at the database... so you would then need to filter them using the System-Defined Event Attributes see
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#i1006211
Similar Messages
-
CTAS using dbms_metadata.get_ddl for Partitioned table
Hi,
I would like to create a temporary table from a partitioned table using CTAS. I plan to use the following steps in a PL/SQL procedure:
1. Use dbms_metadata.get_ddl to get the script
2. Use raplace function to change the tablename to temptable
3. execute the script to get the temp table created.
SQL> create or replace procedure p1 as
2 l_clob clob;
3 str long;
4 begin
5 SELECT dbms_metadata.get_ddl('TABLE', 'FACT_TABLE','USER1') into l_clob FROM DUAL;
6 dbms_output.put_line('CLOB Length:'||dbms_lob.getlength(l_clob));
7 str:=dbms_lob.substr(l_clob,dbms_lob.getlength(l_clob),1);
8 dbms_output.put_line('DDL:'||str);
9 end;
12 /
Procedure created.
SQL> exec p1;
CLOB Length:73376
DDL:
PL/SQL procedure successfully completed.
I cannot see the DDL at all. Please help.Thanks Adam. The following piece of code is supposed to do that. But, its failing because the dbms_lob.substr(l_clob,4000,4000*v_intIdx +1); is putting newline and therefore dbms_sql.parse
is failing.
Please advice.
create table my_metadata(stmt_no number, ddl_stmt clob);
CREATE OR REPLACE package USER1.genTempTable is
procedure getDDL;
procedure createTempTab;
end;
CREATE OR REPLACE package body USER1.genTempTable is
procedure getDDL as
Description: get a DDL from a partitioned table and change the table name
Reference: Q: How Could I Format The Output From Dbms_metadata.Get_ddl Utility? [ID 394143.1]
l_clob clob := empty_clob();
str long;
l_dummy varchar2(25);
dbms_lob does not have any replace function; the following function is a trick to do that
procedure lob_replace( p_lob in out clob, p_what in varchar2, p_with in varchar2 )as
n number;
begin
n := dbms_lob.instr( p_lob, p_what );
if ( nvl(n,0) > 0 )
then
dbms_lob.copy( p_lob,
p_lob,
dbms_lob.getlength(p_lob),
n+length(p_with),
n+length(p_what) );
dbms_lob.write( p_lob, length(p_with), n, p_with );
if ( length(p_what) > length(p_with) )
then
dbms_lob.trim( p_lob,
dbms_lob.getlength(p_lob)-(length(p_what)-length(p_with)) );
end if;
end if;
end lob_replace;
begin
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
DBMS_METADATA.SET_TRANSFORM_PARAM (DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
execute immediate 'truncate table my_metadata';
-- Get DDL
SELECT dbms_metadata.get_ddl('TABLE', 'FACT','USER1') into l_clob FROM DUAL;
-- Insert the DDL into the metadata table
insert into my_metadata values(1,l_clob);
commit;
-- Change the table name into a temporary table
select ddl_stmt into l_clob from my_metadata where stmt_no =1 for update;
lob_replace(l_clob,'"FACT"','"FACT_T"');
insert into my_metadata values(2,l_clob);
commit;
-- execute immediate l_clob; <---- Cannot be executed in 10.2.0.5; supported in 11gR2
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');
end getDDL;
Procedure to create temporary table
procedure createTempTab as
v_intCur pls_integer;
v_intIdx pls_integer;
v_intNumRows pls_integer;
v_vcStmt dbms_sql.varchar2a;
l_clob clob := empty_clob();
l_str varchar2(4000);
l_length number;
l_loops number;
begin
select ddl_stmt into l_clob from my_metadata where stmt_no=2;
l_length := dbms_lob.getlength(l_clob);
l_loops := ceil(l_length/4000);
for v_intIdx in 0..l_loops loop
l_str:=dbms_lob.substr(l_clob,4000,4000*v_intIdx +1);
l_str := replace(l_str,chr(10),'');
l_str := replace(l_str,chr(13),'');
l_str := replace(l_str,chr(9),'');
v_vcStmt(v_intIdx) := l_str;
end loop;
for v_intIdx in 0..l_loops loop
dbms_output.put_line(v_vcStmt(v_intIdx));
end loop;
v_intCur := dbms_sql.open_cursor;
dbms_sql.parse(
c => v_intCur,
statement => v_vcStmt,
lb => 0,
--ub => v_intIdx,
ub => l_loops,
lfflg => true,
language_flag => dbms_sql.native);
v_intNumRows := dbms_sql.execute(v_intCur);
dbms_sql.close_cursor(v_intCur);
end createTempTab;
end;
/ -
How to put the ";" at the end when using dbms_metadata.get_ddl?
Hi there,
Is there a to put the semicolon ";" at the end of each DDL when I use dbms_metadata.get_ddl for (TABLE or TRIGGER)?
ThanksUse:
exec dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM, 'SQLTERMINATOR', TRUE ); -
Getting table script using dbms_metadata.get_ddl, but with clob field
So, Oracle 11g R2..
I'm using dbms_metadata.get_ddl to get table scripts and it's working fine..
now, I have a table with clob field, and it's not working... I got an 'missing right parenthesis (ora-0907)' error...
I could paste a script that I got, but I don't think it makes any sense..
does anybody have some experience on using this package on clob tables?
tnxthis is script that I got... it's long, and it looks like it's not good
CREATE TABLE "COMMON"."TEST_AAA2"
( "ID" NUMBER(10,0),
"TEKST" VARCHAR2(200 CHAR),
"UPDATESTAMP" DATE,
"OBJEKAT" CLOB,
CONSTRAINT "TEST_PART_PK2" PRIMARY KEY ("ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
ALTER INDEX "COMMON"."TEST_PART_PK2" UNUSABLE ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
PARTITION BY RANGE ("UPDATESTAMP")
(PARTITION "P_201012" VALUES LESS THAN (TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201101" VALUES LESS THAN (TO_DATE(' 2011-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201102" VALUES LESS THAN (TO_DATE(' 2011-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201103" VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201104" VALUES LESS THAN (TO_DATE(' 2011-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201105" VALUES LESS THAN (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "USERS" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201106" VALUES LESS THAN (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_ARCHIVE"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_201107" VALUES LESS THAN (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ,
PARTITION "P_MAXVALUE" VALUES LESS THAN (MAXVALUE)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "COMMON_DATA"
LOB ("OBJEKAT") STORE AS BASICFILE (
TABLESPACE "COMMON_ARCHIVE" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)) NOCOMPRESS ) -
How to suppress SCHEMA_OWNER when using DBMS_METADATA.GET_DDL
Hi,
I was wondering, is it possible to suppress the owner when using dbms_metadata.get_ddl?
SQL> select * from v$version where rownum = 1
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
SQL> exec dbms_metadata.set_transform_param (dbms_metadata.session_transform,'SEGMENT_ATTRIBUTES',false)
SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual
DBMS_METADATA.GET_DDL('TABLE','EMP')
CREATE TABLE "SCOTT"."EMP"
( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
"ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0)
)I would like to get rid of the "SCOTT". Alternatively to change it into something else.
Is that possible, without post processing the output, that is?
Regards
PeterHi Karthick,
I was afraid that would be the answer. It can be done, but it seems rather convoluted:
SQL> create or replace function get_table_ddl(table_name varchar2
,schema varchar2 default user
,new_owner varchar2 default null)
return clob
is
v_handle number;
v_transhandle number;
v_ddl clob;
begin
v_handle := dbms_metadata.open('TABLE');
dbms_metadata.set_filter(v_handle, 'SCHEMA', schema);
dbms_metadata.set_filter(v_handle, 'NAME', table_name);
v_transhandle := dbms_metadata.add_transform(v_handle, 'MODIFY');
dbms_metadata.set_remap_param(v_transhandle,'REMAP_SCHEMA',schema,new_owner);
v_transhandle := dbms_metadata.add_transform(v_handle, 'DDL');
dbms_metadata.set_transform_param(v_transhandle,'SEGMENT_ATTRIBUTES',false);
v_ddl := dbms_metadata.fetch_clob(v_handle);
dbms_metadata.close(v_handle);
return v_ddl;
end;
Function created.
SQL> select get_table_ddl('EMP') from dual
GET_TABLE_DDL('EMP')
CREATE TABLE "EMP"
( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
"ENAME" VARCHAR2(10),
"JOB" VARCHAR2(9),
"MGR" NUMBER(4,0),
"HIREDATE" DATE,
"SAL" NUMBER(7,2),
"COMM" NUMBER(7,2),
"DEPTNO" NUMBER(2,0)
1 row selected.Regards
Peter -
Hello.
I'm getting such warnings on server startup:
12:57:33,241 WARN [StoreRepository] Warning - table: store_user appears in item descriptors: store and user but not using a pattern recognized by the GSA table invalidation mechanism. Cached values from this table will not be updated when user's properties are modified. These properties for this table are: [storeUsers]
12:57:33,241 WARN [StoreRepository] Missing a src id property in item-descriptor user's table named store_user whose column-names are store_id
12:57:33,242 WARN [StoreRepository] Missing a dst id property in item-descriptor store's table named store_user whose column-names are user_id
12:57:33,242 WARN [StoreRepository] Missing a dst multi property in item-descriptor store's table named store_user whose column-name is store_id
12:57:33,242 WARN [StoreRepository] Warning - table: store_user appears in item descriptors: user and store but not using a pattern recognized by the GSA table invalidation mechanism. Cached values from this table will not be updated when store's properties are modified. These properties for this table are: [userStores]
12:57:33,243 WARN [StoreRepository] Missing a src id property in item-descriptor store's table named store_user whose column-names are user_id
12:57:33,243 WARN [StoreRepository] Missing a dst id property in item-descriptor user's table named store_user whose column-names are store_id
12:57:33,243 WARN [StoreRepository] Missing a dst multi property in item-descriptor user's table named store_user whose column-name is user_id
Here's repository definition file:
<item-descriptor name="user" id-space-name="user" display-name="User" display-property="name">
<table name="user_tbl" type="primary" id-column-name="user_id">
<property name="id" column-name="user_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="user_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="user_id" multi-column-name="store_id">
<property name="userStores" display-name="User Stores" data-type="map" column-names="email" component-data-type="string">
<attribute name="propertySortPriority" value="-1" />
<attribute name="uiwritable" value="false" />
</property>
</table>
</item-descriptor>
<item-descriptor name="store" id-space-name="store" display-name="Store" display-property="name">
<table name="store_tbl" type="primary" id-column-name="store_id">
<property name="id" column-name="store_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="store_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="store_id" multi-column-name="user_id">
<property name="userStores" display-name="User Stores" data-type="map" column-names="email" component-data-type="string">
<attribute name="propertySortPriority" value="-1" />
<attribute name="uiwritable" value="false" />
</property>
</table>
</item-descriptor>
I'll appreciate it, if someone tell me what's wrong with my definition.
Thank you in advance,
Jurii.Hi Jurii,
You are right about ATG docs do not have info about M-M that can fit into your requirement. So we have to give it a try :-)
Please try with the below definition to see it it works.
user_tbl and store_tbl - no changes
store_user table has three columns - user_id, store_id and email
<item-descriptor name="user" id-space-name="user" display-name="User" display-property="name">
<table name="user_tbl" type="primary" id-column-name="user_id">
<property name="id" column-name="user_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="user_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="user_id">
<property name="store" display-name="Stores" data-type="set" column-names="store_id" component-item-type="store"/>
<property name="email" display-name="User Store Email" data-type="set" column-names="email" component-data-type="string"/>
</table>
</item-descriptor>
<item-descriptor name="store" id-space-name="store" display-name="Store" display-property="name">
<table name="store_tbl" type="primary" id-column-name="store_id">
<property name="id" column-name="store_id" data-type="string" display-name="Id">
<attribute name="uiwritable" value="false" />
<attribute name="propertySortPriority" value="-1" />
</property>
<property name="name" column-name="store_name" data-type="string" display-name="Name">
<attribute name="propertySortPriority" value="-1" />
</property>
</table>
<table name="store_user" type="multi" id-column-names="store_id">
<property name="user" display-name="Users" data-type="set" column-names="user_id" component-item-type="user"/>
<property name="email" display-name="User Store Email" data-type="set" column-names="email" component-data-type="string"/>
</table>
</item-descriptor>
Thanks,
Gopinath Ramasamy -
Unable to capture the adf table column sort icons using open script tool
Hi All,
I am new to OATS and I am trying to create script for testing ADF application using open script tool. I face issues in recording two events.
1. I am unable to record the event of clicking adf table column sort icons that exist on the column header. I tried to use the capture tool, but that couldn't help me.
2. The second issue is I am unable to capture the panel header text. The component can be identified but I was not able to identify the supporting attribute for the header text.Hi keerthi,
1. I have pasted the code for the first issue
web
.button(
122,
"/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1824fhkchs_6']/web:form[@id='pt1:_UISform1' or @name='pt1:_UISform1' or @index='0']/web:button[@id='pt1:MA:0:n1:1:pt1:qryId1::search' or @value='Search' or @index='3']")
.click();
adf
.table(
"/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1c9nk1ryzv_6']/web:ADFTable[@absoluteLocator='pt1:MA:n1:pt1:pnlcltn:resId1']")
.columnSort("Ascending", "Name" );
} -
Error while using DBMS_METADATA.GET_DDL package.
Hi all,
I want script of DDL of all tables in Database not in particular schema,
As I am using below query
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
FROM ALL_TABLES u
WHERE u.nested='NO'
AND (u.iot_type is null or u.iot_type='IOT')
but it gives error as below.
ORA-31603: object "ICOL$" of type TABLE not found in schema "SCOTT"
It should give DDL of all tables, also I am not having DBA Privs.
Please help me.
Thanks & Regards
Rajiv.It could be helpful if you have a look into [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1016867]documentation.
Security Model
The object views of the Oracle metadata model implement security as follows:
Nonprivileged users can see the metadata of only their own objects.
SYS and users with SELECT_CATALOG_ROLE can see all objects.
Nonprivileged users can also retrieve public synonyms, system privileges granted to them, and object privileges granted to them or by them to others. This also includes privileges granted to PUBLIC.
If callers request objects they are not privileged to retrieve, no exception is raised; the object is simply not retrieved.
If nonprivileged users are granted some form of access to an object in someone else's schema, they will be able to retrieve the grant specification through the Metadata API, but not the object's actual metadata.
In stored procedures, functions, and definers-rights packages, roles (such as SELECT_CATALOG_ROLE) are disabled. Therefore, such a PL/SQL program can only fetch metadata for objects in its own schema. If you want to write a PL/SQL program that fetches metadata for objects in a different schema (based on the invoker's possession of SELECT_CATALOG_ROLE), you must make the program invokers-rights.
Best regards
Maxim -
Stange error when using dbms_metadata.get_ddl in PL/SQL procedure
Basic info:
Oracle 10.2.0.4.0 on linux.
I'm trying to extract ddl of indexes that I drop and recreate frequently during monthly loads and store it in a table.
This statement works on the command line:
insert into saved_indexes
select index_name,dbms_metadata.get_ddl('INDEX',index_name,owner_name)
from sys.all_indexes
where owner = owner_name
and table_name = table_name;
commit;
The table 'saved_indexes' is a two column table with a varchar2(40) and a CLOB.
When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.
PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2) IS
v_errorcode number(8);
v_errortext varchar2(1000);
v_start_time date;
BEGIN
insert into saved_indexes
select index_name,dbms_metadata.get_ddl('INDEX',index_name,v_owner)
from sys.all_indexes
where owner = v_owner
and table_name = v_table;
commit;
EXCEPTION
WHEN others THEN
v_errorcode := sqlcode;
v_errortext := substr(sqlerrm, 1, 1000);
dbms_output.put_line(v_errortext || ' ' || v_errorcode);
END;
Alternatively I have tried it this way:
PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2 ) IS
v_errorcode number(8);
v_errortext varchar2(1000);
v_index_ddl CLOB;
BEGIN
for x in (select index_name
from sys.all_indexes
where owner = v_owner
and table_name = v_table)
loop
select dbms_metadata.get_ddl('INDEX',x.index_name,v_owner) into v_index_ddl from dual;
insert into saved_indexes
values(v_table,v_index_ddl);
end loop;
commit;
EXCEPTION
WHEN others THEN
v_errorcode := sqlcode;
v_errortext := substr(sqlerrm, 1, 1000);
dbms_output.put_line(v_errortext || ' ' || v_errorcode);
END;
Always with the same result. I have poured over the documentation on this and have not found anything. All objects are in the same schema, so there is not an issues with invokers rights, or privileges.
Any suggestions would be helpful...qwe11126 wrote:
When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.There is nothing wrong with SP. Post a snippet of SQL*Plus code showing how you call SP along with errors.
SY. -
Using dbms_metadata to get defination of large table
Hi,
I have very very large table definition table with partitions and sub-partitions and I want to create that table in some other db.
I am trying below spooled query but its not retrieving complete definition of the table, any other setting I should follow
spool t.sql
set pagesize 0
set long 2000000
select dbms_metadata.get_ddl
I am using oracle 10g r2
Thanks,
PankajThanks you all for your replied, following are observation after settings suggested
With setting
==================
set longchunksize 2000000
set long 2000000
set lines 2000
set pages 0
-sh-3.00$ cat t.sql | wc
10819 23419 21635001
=================
With setting
set long 100000
set pages 0
-sh-3.00$ cat t.sql | wc
3452 7326 279269
Result => None worked for me :( -
Error while viewing Scripts using dbms_metadata.get_ddl
select dbms_metadata.get_ddl('TABLE',table_name,'DWHOWN') from user_tables
DBMS_METADATA.GET_DDL('TABLE',TABLE_NAME,'DWHOWN')
CREATE TABLE "DWHOWN"."T_DWBN_RELATION_MASTER"
( "BUSINESS_DATE" DATE NOT
CREATE TABLE "DWHOWN"."TMP_CS_CUST_UD_CODES"
( "BUSINESS_DATE" DATE NOT N
ERROR:
ORA-31603: object "BIN$IpUrdJVTS9/gRAADup0xmQ==$0" of type TABLE not found in
schema "DWHOWN"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 105
ORA-06512: at "SYS.DBMS_METADATA", line 2697
ORA-06512: at "SYS.DBMS_METADATA", line 4220
ORA-06512: at line 1ORA-31603: object "BIN$IpUrdJVTS9/gRAADup0xmQ==$0" of type TABLE not found in<br>This table come from the recycle bin. You maybe need to purge this one :<br>
purge recyclebin;<br>
Furthermore, it seems that you'll need to set long to bigger for more well output.<br>
<br>
Nicolas. -
Hi,
I'm trying to extract schema DDL from a database (10.2.0.4.0 - 64bit Enterprise Edition on Solaris 10). I run the query below and get an ORA-00907: missing right parenthesis error.
SELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN ('TABLE_PARTITION','INDEX_PARTITION','LOB');
This is the output when running the above in sqlplus worksheet
select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects where object_type not in ('TABLE_PARTITION','INDEX_PARTITION','LOB')
ERROR at line 1:
ORA-00907: missing right parenthesis
removing the where clause gives the following:
select DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') as object_type, object_name) FROM user_objects
ERROR at line 1:
ORA-00907: missing right parenthesis
Any pointers would be gratefully received. I know I could get the DDL out using exp/imp but I want to understand why I'm getting the missing parenthesis error.
cheers,
EwanSELECT DBMS_METADATA.GET_DDL( REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN You don't need an alias here. Get rid of " AS object_type" and it should work.
-
Move_table_clause of the alter table command
Oracle Workspace Manager: 10.2.0.4.3
Database version: 10.2.0.4.0
Can one use the following technique to relocate a version enabled table from one tablespace to another? Is this supported?
exec dbms_wm.beginDDL(tablename)
alter table tablename_lts move tablespace ...
exec dbms_wm.commitDDL
I tried this in a development environment; the lt table moved, but the lck table remained behind. This history seems to be all there.Hi,
Yes, that is the supported method to move the LT table into a new tabelspace. It will also move the AUX table and the _VT table(if it exists).
Regards,
Ben -
How to use column with linkToItem in the Basic Table view style mode
Hi
I have already changed a normal column that I made to a column with linkToItem as follows.
<viewfields>
<FieldRef Name="MyColumn" linkToItem="TRUE">
and it worked.
But this column works only at the default view style mode in my case.
Does anyone know how to use linkedToItem column in the Basic Table mode?
hope someone help me.
thanksHi,
According to your description, my understanding is that you want to use linkToItem in the Basic Table view style.
Per my test, in the Default style view, we need to use linkToItem=”TRUE”. However, in Basic Table style view, we need to use LinkToItem=”TRUE” instead.
Best regards.
Thanks
Victoria Xia
TechNet Community Support -
Using a bean to capture the currently authenticated user information
Hi,
i have an ADF web based application . The authentication and authorization is managed by OID(LDAP) . I want to put user level access in the application. I have made a custom method in the application module, that handles the authorization at user level. But i do not know how to capture the info of currently logged in user. I'am aware i can do this using a bean. Can someone tell me howIt'd be better to post this to the JDeveloper forum where ADF is covered.
cheers
-steve-
Maybe you are looking for
-
Showing more than one row at the same time, trigger necessary?
hi I'm an absolute beginner in oracle forms, so i have a fundamental problem. i have a forms with 3 data-tables/data-blocks with following names and columns: table "connection type": con_id, con_descr table "connection": con_con_id (foreign key to "c
-
Xslt transformation rules for BPEL
Hi there, Can anyone advise where I can find the xslt transformation rules for BPEL. I am unable to find the mentioned file "114.XSLTTransformations". Best regards! Linda
-
Biw function module creation in se37 / unable to tranposrt to production
hi, i need data of a BW table to be transported to R/3. For this A RFC function module is exsisting in our BIW DEV server. that FM is as follows under TABLES DATA LIKE /BIC/AZGVDTL00 ODS Object ZGVDTL : Active Records UNDER SOURCE CODE FUNCTION ZGV_D
-
All SAP Gurus, I want to convert Message no. 61 322 from Warning to Error. But I'm unable to loacte/find it in SPRO. Can anyone please help me out? Regards,
-
b The nicest APEX app / feature /b
Hello, At ODTUG I'm doing the APEX vs ADF Shoot-out, together with Lucas Jellema. The last presentation Lucas and I did last year in the Netherlands. We decided to change some things in the presentation. One of them is to include "the nicest app or f