473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Re: dbms_metadata for Synonym


I have managed to figure out the solution for the 1st one. All I had to
do was set filter to the current schema. So please just consider the
2nd problem:
2. when generating triggers, certain triggers are not being extracted
completely. I repeat only certain triggers. rest of them are being
extracted ok. can someone please explain why this is happening and
how can i avoid it?

Thanks,
Hari

Originally posted by wallflowers
Hi,

I am using dbms_metadata for generating all the ddl in the current
schema. Although there are a couple of problems i am facing.

1. when i try to generate the ddl for all synonyms, it seems to be
generating the ddl for all public synonyms, i need only the ones
owned by the current schema. how do i do that?

2. when generating triggers, certain triggers are not being extracted
completely. I repeat only certain triggers. rest of them are being
extracted ok. can someone please explain why this is happening and
how can i avoid it?

Any help is highly appreciated. Thanks in advance.
Hari

--
Posted via http://dbforums.com
Jun 27 '08 #1
7 3287
DBMS_METADATA.GET_DDL returns a CLOB. Therefore, just change the value
of your variable "long" to a bigger value, and you'll be OK (from
SQL*Plus, "set long 50000").

Daniel

wallflowers <me*********@dbforums.comwrote in message news:<31****************@dbforums.com>...
I have managed to figure out the solution for the 1st one. All I had to
do was set filter to the current schema. So please just consider the
2nd problem:
2. when generating triggers, certain triggers are not being extracted
completely. I repeat only certain triggers. rest of them are being
extracted ok. can someone please explain why this is happening and
how can i avoid it?

Thanks,
Hari

Originally posted by wallflowers
Hi,

I am using dbms_metadata for generating all the ddl in the current
schema. Although there are a couple of problems i am facing.

1. when i try to generate the ddl for all synonyms, it seems to be
generating the ddl for all public synonyms, i need only the ones
owned by the current schema. how do i do that?

2. when generating triggers, certain triggers are not being extracted
completely. I repeat only certain triggers. rest of them are being
extracted ok. can someone please explain why this is happening and
how can i avoid it?

Any help is highly appreciated. Thanks in advance.
Hari
Jun 27 '08 #2

Daniel,

Well, I am using it programmatically from a PL/SQL package and its all
within a loop. It extracts the source code for all triggers and saves
them in a separate file for each trigger. so when I look at the files,
certain triggers are extracted completely , while some are not. Thats
what I am unable to understand, why would it happen for only certain
trigger. Let me know if you need any further information.

Thanks,
Hari

Originally posted by Daniel Roy
DBMS_METADATA.GET_DDL returns a CLOB. Therefore, just change the value
of your variable "long" to a bigger value, and you'll be OK (from
SQL*Plus, "set long 50000").

Daniel

wallflowers wrote in message news:news:...
I have managed to figure out the solution for the 1st one. All I
had to
do was set filter to the current schema. So please just consider
the
2nd problem:
2. when generating triggers, certain triggers are not being
extracted
completely. I repeat only certain triggers. rest of them are
being
extracted ok. can someone please explain why this is
happening and
how can i avoid it?

Thanks,
Hari

Originally posted by wallflowers
Hi,
>
I am using dbms_metadata for generating all the ddl in the
current
schema. Although there are a couple of problems i am
facing.
>
1. when i try to generate the ddl for all synonyms, it seems
to be
generating the ddl for all public synonyms, i need only the
ones
owned by the current schema. how do i do that?
>
2. when generating triggers, certain triggers are not being
extracted
completely. I repeat only certain triggers. rest of them
are being
extracted ok. can someone please explain why this is
happening and
how can i avoid it?
>
Any help is highly appreciated. Thanks in advance.
>
Hari
--
Posted via http://dbforums.com
Jun 27 '08 #3

Also, I am using the procedure dbms_metadata.fetch_ddl and not the
function dbms_metadata.get_ddl.

Here is core code :

** Begin Code
LOOP

triggerDDLs := dbms_metadata.fetch_ddl(triggerOpenHandle);
EXIT WHEN triggerDDLs IS NULL; -- Get out when no more
triggers

-- Get the trigger DDL object from the collection although there
is only one since we requested only 1 DDL per fetch
triggerDDL := triggerDDLs(1);
.... some processing code

-- Write the DDL text to our output file
write_lob(triggerDDL.ddltext, fileHandle);

Note: write_lob is from the oracle sample program for dbms_metadata

-- Package-private routine to write a CLOB to an output file.

PROCEDURE write_lob(doc IN CLOB, fileHandle UTL_FILE.FILE_TYPE) IS

outString varchar2(32760);
cloblen number;
offset number := 1;
amount number;

BEGIN

cloblen := dbms_lob.getlength(doc);

WHILE cloblen 0
LOOP

IF cloblen 32760 THEN
amount := 32760;
ELSE
amount := cloblen;
END IF;

outString := dbms_lob.substr(doc, amount, offset);
utl_file.put(fileHandle, outString);
utl_file.fflush(fileHandle);
offset := offset + amount;
cloblen := cloblen - amount;

END LOOP;
RETURN;
END;

** End Code

Hope this helps.

Thanks,
Hari
Originally posted by wallflowers
Daniel,

Well, I am using it programmatically from a PL/SQL package and its all
within a loop. It extracts the source code for all triggers and saves
them in a separate file for each trigger. so when I look at the files,
certain triggers are extracted completely , while some are not. Thats
what I am unable to understand, why would it happen for only certain
trigger. Let me know if you need any further information.

Thanks,
Hari

--
Posted via http://dbforums.com
Jun 27 '08 #4
According to the specs, fetch_ddl returns a variable of type KU$_DDLS
(no typo, you read it right!). This is certainly a new data type for
me. I found a good example on
http://download-west.oracle.com/docs...d2.htm#1024601
(at around 75% of the page). Take a look at it, and let us know if
that helps.

Daniel
Jun 27 '08 #5

Thats the example based on which I wrote the entire package.
Originally posted by Daniel Roy
According to the specs, fetch_ddl returns a variable of type KU$_DDLS
(no typo, you read it right!). This is certainly a new data type for
me. I found a good example on
http://download-west.oracle.com/docs...appdev.920/a9-
6612/d_metad2.htm#1024601"]http://download-west.oracle.com/docs/cd/B1-
0501_01/appdev.920/a96612/d_metad2.htm#1024601[/url]
(at around 75% of the page). Take a look at it, and let us know if
that helps.
Daniel

--
Posted via http://dbforums.com
Jun 27 '08 #6
If you want, email me the whole piece of code, and I can take a look
at it (remove the "junk" from my username for my real email address).

Daniel
Jun 27 '08 #7
I installed your package, and tested with some triggers. So far,
everything works perfectly. Which cases didn't work with you? Does it
seem random? Is it the very triggers with lots of text?

Daniel
If you want, email me the whole piece of code, and I can take a look
at it (remove the "junk" from my username for my real email address).

Daniel
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jaffa | last post by:
hi all, i'm currently designing a search engine. I'd like certain keywords to have affiliated synonyms listed so that I can find out which keywords are symantically related to each other. Is...
3
by: Thierry B. | last post by:
Hi, from SQL*Plus, i use: DESCRIBE MyTable and I get this result (example): Nom NULL ? Type ----------------------------------------- --------...
0
by: wallflowers | last post by:
Hi, I am using dbms_metadata PL/SQL supplied package to extract all the objects from the oracle database into files. So far I have generated the source code for Functions & Triggers. Functions...
14
by: Bit Byte | last post by:
I have the following struct: typedef struct { string symbol; string synonym; Synonym(string _synonym, string _symbol) { synonym = _synonym; symbol = _symbol; }
7
by: keyser soze | last post by:
hi i have a stored proc, pointed by a synonym i wish to execute it vía: cmd.commandType= adStoredProc cmd.commandText= "s_MyStoredProc" cmd.parameters.refresh ---to get the collection the...
1
by: wallflowers | last post by:
Hi Daniel, The only common thing among all the incompletely extracted triggers is that all of them have large number of trigger columns, approximately 25-30 columns. So all the triggers end...
5
by: zcabeli | last post by:
Hello, i'm looking for the equivalent perl symbol that match #define in C/C++ anybody have an idea if any such feature exists ... thanks,
1
by: Richard | last post by:
This is highly unusual. I do this only out of desperation. I am DB2 DBA on unix and recent had to take on Oracle admin as well. This question is really about Oracle export/import. Why I post here...
3
by: pankajit09 | last post by:
Like we run an EXE in Windows by double clicking on it or from the DOS prompt what is that in LINUX ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.