On the use of VARCHAR2 vs. CHAR
I'm posting an e-mail thread that has been moving around in my organization, whith guidance from an Oracle representative.
The basic issue concerns the use of CHAR vs. VARCHAR2 when defining a table in Oracle.
I would like to get some comments from the community at large.
1. Business semantics should be represented in every aspect of a database, application, and design as far as I am concerned. Noteably, if the business rule at a corporate entity is clearly stated that when using Oracle the use of CHAR should be limited to those attribute implementations which have the following characteristics; a) The attribute may not be null, b) The attribute must have a character in each of the declared positions.
2. When the Visual Basic application began writing data to the CHAR columns in your application someone should have had a discussion with the developer to find out why this was happening. If the business semantics changed then the logical implemention of the business semantics should have changed as well. That the two were disconnected is not a problem with the CHAR type, it is a problem with the designer or the developer. The bottom line on this instance is that the column should have been defined as a VARCHAR2 data type since the business semantics no longer complied with the criteria set forth in the previous paragraph.
3. I think Oracle trys to load as much of the data from a table or index into shared memory, in this case the database block buffers, as it can in order to facilitate query operations. If Oracle has enough memory and can load a table or index into memory, it will do so. At the same time the database engine will move previously cached data out of memory to accommodate the new requirement.
-----Original Message-----
Thank you for the detail information on CHAR and VARCHAR2. It got me thinking with a DBA hat. I worked as a DBA before and I did use the CHAR type and I will share my experience/thought on CHAR.
I don't like to use the char type like Tom has advised because Oracle does not check to see if the value being inserted fills up the column or not which can lead to a problem. And there is no performance gain or save space in Oracle.
I worked as a DBA before, I used char type on the "must fill/always filled" column (pre DMDC). The application was written in VB with Oracle back end. At some point, VB started inserting values that are short of the column width and created a minor problem (it was supposed to be filled column). The problem was quickly identified and fixed, but it caused an issue.
I realize that I don’t want to define it as a "must fill/always filled" column if you can't enforce it by simply defining the char data type on a table and prevent possible issue in the future.
For a manager, in order to use the char properly, you have to hire client developers with Oracle experience or provide a basic Oracle training in order to avoid the problem I mentioned above in order to use the char type correctly.
I think you, Tom and I are saying the same thing really. Only difference is that Tom and I can not think of a good reason why anyone would like to indicate the business semantics using column type on the database, when it can lead to more work/issues.
In regards to wasted 25 million byes, why would Oracle load the table with 25 million rows? Shouldn't it use an index? Don't you have a serious problem if Oracle is loading table with the 25 million rows?
Just my two cents... : )
-----Original Message-----
May I beg to differ?
CHAR plays a vital role in the intuitive interpretation of a database schema. If designed correctly, the use of CHAR tells anyone who is in the know that this is a must fill column. Thus if a column is defined as CHAR(3) everyone should know that the column will always contain three characters. Defining the column as VARCHAR2(3) does not tell you anything about the data other than that the column may contain 0-3 characters.
Also, If a column is defined as CHAR the column should always be populated. One of the nice features of VARCHAR2 is that if the column is defined at the end of a table, there is no storage overhead until that column is actually populated. Thus if you have a table that has an identifier that is nine characters in length and will always be populated with nine characters, an attribute which describes the type of identifier which is contained in the first column and which must always be populated and is a must fill attribute, and another column which is descriptive and may vary in length or not be populated at time of insert; the following definition does not express the business semantics of the entity:
COL_CD VARCHAR2(9)
COL_TYP_TXT VARCHAR2(26)
COL_TYP_CD VARCHAR2(2)
The above definition also does not take advantage of inherent storage features of Oracle; notably there is a wasted place holder between COL_CD and COL_TYP_TXT and between COL_TYP_TXT and COL_TYP_CD. The next definition does take advantage of the storage features but does not represent the business semantics of the entity:
COL_CD VARCHAR2(9)
COL_TYP_CD VARCHAR2(2)
COL_TYP_TXT VARCHAR2(26)
The above definition does not waste space storing a place holder between COL_TYP_CD and COL_TYP_TXT if the COL_TYP_TXT may be null. The column separator will only be used when the column contains data. The below definition satisfies both the storage and business semantics issues:
COL_CD CHAR(9)
COL_TYP_CD CHAR(2)
COL_TYP_TXT VARCHAR2(26)
This may seem pedantic in nature until you consider the situation where there are 25 million rows in the table represented by the above entity. If each row has a NULL COL_TYP_TXT value then the first example wasted 25 million bytes of storage and 25 million bytes of memory if the full table is loaded into memory. This is an issue which cannot be ignored in high volume databases.
You may wish to know why it is important to define a must fill/always fill column as a CHAR to express the business semantics of an attribute. I can't give a definitive answer to that other than to say that it is just good database manners.
So please, continue to use CHAR when the shoe fits. Don't throw something away that has use just because it is not popular or in the mode.
Also, if I am mistaken in any of the above, please feel free to educate me.
Thanks.
-----Original Message-----
Subject: RE: Oracle on the use of VARCHAR2 vs. CHAR
Ignore if you already got this. This is just FYI.
-----Original Message-----
Below is a detailed answer to your VARCHAR2 or CHAR questions from our Database expert Tom Kyte. The short answer is VARCHAR2 is what you want to use. If you have any questions or want to discuss this in more detail let me know.
A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
The difference between a CHAR and a VARCHAR is that a CHAR(n) will ALWAYS be N bytes long, it will be blank padded upon insert to ensure this. A varchar2(n) on the other hand will be 1 to N bytes long, it will NOT be blank padded.
Using a CHAR on a varying width field can be a pain due to the search semantics of CHAR.
Consider the following examples:
ops$tkyte@8i> create table t ( x char(10) ); Table created.
ops$tkyte@8i> insert into t values ( 'Hello' );
1 row created.
ops$tkyte@8i> select * from t where x = 'Hello';
X
Hello
ops$tkyte@8i> variable y varchar2(25)
ops$tkyte@8i> exec :y := 'Hello'
PL/SQL procedure successfully completed.
ops$tkyte@8i> select * from t where x = :y; no rows selected
ops$tkyte@8i> select * from t where x = rpad(:y,10);
X
Hello
Notice how when doing the search with a varchar2 variable (almost every tool in the world uses this type), we have to rpad() it to get a hit.
If the field is in fact ALWAYS 10 bytes long, using a CHAR will not hurt -- HOWEVER, it will not help either.
The only time I personally use a CHAR type is for CHAR(1). And that is only because its faster to type char(1) then varchar2(1) -- it offers no advantages.
If you just use varchar2 everywhere, no problem
My advice is, has been, will be very loudly stated as:
IGNORE THE EXISTENCE OF CHAR.
period. If you never use char, you never compare char to varchar2, problem solved.
And if you use char and compare a char(n) to a char(m) they will never compare either.
Just say NO TO CHAR.
**************************************************
Hi,
>>A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
Ok, but on the other hands:
SGMS@ORACLE10> create table x (name char(10), name2 varchar2(10));
Table created.
SGMS@ORACLE10> insert into x values ('hello','hello');
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> select vsize(name),vsize(name2) from x;
VSIZE(NAME) VSIZE(NAME2)
10 5
SGMS@ORACLE10> select dump(name),dump(name2) from x;
DUMP(NAME) DUMP(NAME2)
Typ=96 Len=10: 104,101,108,108,111,32,32,32,32,32 Typ=1 Len=5: 104,101,108,108,111Cheers
Similar Messages
-
Why the objects of sysman are created with the data type varchar2 CHAR
Hi,
I have an environment with the following properties,
NLS_LENGTH_SEMANTICS BYTE
NLS_CHARACTERSET AL32UTF8
After I have created the db control repository, I find the data type of the sysman's objects are
VARCHAR2 (64 CHAR)
Why?NLS_LENGTH_SEMANTICS does not apply to tables in SYS and SYSTEM. The data dictionary always uses byte semantics.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams127.htm -
DIFFERENCE BETWEEN THE DATA DECLARATIONS NVARCHAR2 AND VARCHAR2(x CHAR)
CAN ANYONE HELP ME FIND THE DIFFERENCE BETWEEN THE DATA DECLARATIONS; NVARCHAR2 AND VARCHAR2(x CHAR), WHERE X IS THE SIZE OF DATA TO BE HELD WITH THE VARIABLE OR ATTRIBUTE
Duplicate posting....
Difference between nvarchar2(10) and varchar2(10 char )
Difference between nvarchar2( 10) and varchar2( 10 char)
Please refer also...
Nvarchar2 -
Wield char with the use of matnr
Hi All,
my requirement is like:
I need 1 selection option which seems like parameter type mara-matnr.
when I put any material with the using of "*", it sud be fetch all the material with combination.
I did the code for that but somtime it fails..
TABLES: rqm00.
TYPES : BEGIN OF tp_matnr,
matnr TYPE mara-matnr,
END OF tp_matnr.
DATA: w_text TYPE string.
CONSTANTS: c_wild TYPE c VALUE '*',
c_per TYPE c VALUE '%'.
DATA: t_matnr TYPE STANDARD TABLE OF tp_matnr,
wa_matnr type tp_matnr.
SELECT-OPTIONS : s_matnr FOR mara-matnr NO INTERVALS NO-EXTENSION.
IF s_matnr-LOW CA c_wild.
W_TEXT = S_MATNR-LOW.
REPLACE ALL OCCURRENCES OF c_wild IN s_matnr-LOW WITH c_per.
ENDIF.
SELECT matnr
FROM mara
INTO TABLE t_matnr
WHERE matnr LIKE S_MATNR-LOW.
IF SY-SUBRC = 0.
loop at t_matnr into wa_matnr.
write: wa_matnr-matnr.
endloop.
ENDIF.
What should I do? what is the right solution which should not be fail in any condition.
Thanks & Regards,
Jaten Sangal
Edited by: Jaten.sangal on Nov 18, 2009 11:26 AMHi
I just Executed this Code and working Fine
TABLES: rqm00.
TYPES : BEGIN OF tp_matnr,
matnr TYPE mara-matnr,
END OF tp_matnr.
DATA: w_text TYPE string.
CONSTANTS: c_wild TYPE c VALUE '*',
c_per TYPE c VALUE '%'.
DATA: t_matnr TYPE STANDARD TABLE OF tp_matnr,
wa_matnr type tp_matnr.
parameters : s_matnr type mara-matnr. " Replace this Parameters and proceed further
*IF s_matnr-LOW CA c_wild.
*W_TEXT = S_MATNR-LOW.
REPLACE ALL OCCURRENCES OF c_wild IN s_matnr WITH c_per.
*ENDIF.
SELECT matnr
FROM mara
INTO TABLE t_matnr
WHERE matnr LIKE S_MATNR.
IF SY-SUBRC = 0.
loop at t_matnr into wa_matnr.
write:/ wa_matnr-matnr.
endloop.
ENDIF.
Did you try this one
Cheerz
Ram
Edited by: Ramchander Krishnamraju on Nov 18, 2009 11:41 AM -
Primary Keys and VARCHAR2 vs CHAR datatypes???
Could someone please tell me if there is documentation concerning the performance implications of creating a Primary Key using a VARCHAR2 datatype vs a CHAR datatype?
Well with a CHAR datatype, a value of ‘abc’ equates to ‘abc ’.
So that if the value of ‘abc’ already existed in the PK in the table and someone tried to Insert another row with a value of ‘abc ‘, it would return a unique constraint violation (the rule from the user being that a value with or without trailing spaces is the same value).
But if the PK column is defined as VARCHAR2, both the 'abc' and the 'abc ' could be Inserted into the Table because in the nonpadded comparison they are not equal.
Would defining the column as a VARCHAR2 with a Check Constraint to RTRIM the column be a better way to go? -
Problem creating cache group for a table with data type varchar2(1800 CHAR)
Hi,
I am using TimesTen 7.0 with Oracle 10.2.0.4 server. While creating Cache Group for one of my table I'm getting the following error.
5121: Non-standard type mapping for column TICKET.DESCRIPTION, cache operations are restricted
5168: Restricted cache groups are deprecated
5126: A system managed cache group cannot contain non-standard column type mapping
The command failed.
One of my filed type in oracle table is Varchar2(1800 CHAR). If I change the filed size to <=1000 it (E.g. Varchar2(1000 CHAR)) then the Create Cache command works fine.
MyDatabase Character Set is UTF8.
Is it possible to solve without changing the filed size in the Oracle Table?
Request your help on this.
Thanks,
SunilHi Chris.
The TimesTen server and the Oracle Client is installed on a 32-bit system.
1. ttVersion
TimesTen Release 7.0.5.0.0 (32 bit Linux/x86) (timesten122:17000) 2008-04-04T00:09:04Z
Instance admin: root
Instance home directory: /appl/TimesTen/timesten122
Daemon home directory: /var/TimesTen/timesten122
Access control enabled.
2. Oracle DB details
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Oracle Client - Oracle Client 10.2.0.4 running in a 32 bit Linux/x86
3. ODBC Details
Driver=/appl/TimesTen/timesten122/lib/libtten.so
DataStore=/var/TimesTen/data
PermSize=1700
TempSize=244
PassThrough=2
UID=testuser
OracleId=oraclenetservice
OraclePwd=testpwd
DatabaseCharacterSet=UTF8
Thanks,
Sunil -
Bug? using MAX() function on char(1) column returns something larger
details:
-- we have a complex nested query, where we are essentially returning the max() value into a variable
-- the max() function is being used on a char(1) column
-- where MAX() is part of an inner select, we have started getting
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
errors.
SELECT MAX(X) INTO var FROM ... works in 9i and 10g
SELECT X INTO var FROM (SELECT MAX(X) X FROM ... worked in 9i, does not work in 10g!
-- We never had problems with the code until upgrading to 10g release 2.
-- the Solution is to cast the final value with TO_CHAR(). The cast MUST be done at the outer most point of the select:
SELECT TO_CHAR(X) INTO var FROM (SELECT MAX(X) X FROM ... works
SELECT X INTO var FROM (SELECT TO_CHAR(MAX(X)) X FROM ... causes an error!
The following script demonstrates the issue, and includes the solution:
* October 3, 2006
* Possible SQL bug introduced with Oracle 10G
* Natalie Gray DBA/Developer, Environment Canada
* Description:
* Have discovered a problem with using the MAX() function
* on columns of type char(1)
* only an issue when used in an inner select
* solution (see test 4)
CREATE TABLE SQL_BUG_TEST
X NUMBER,
Y NUMBER,
Z CHAR(1)
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,1,'A');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,1,'B');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,2,'C');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,2,'D');
DECLARE
TYPE REC IS RECORD (
x SQL_BUG_TEST.X%TYPE,
y SQL_BUG_TEST.Y%TYPE,
z SQL_BUG_TEST.Z%TYPE
v_rec REC;
BEGIN
-- DISPLAY THE TABLE DATA
BEGIN
DBMS_OUTPUT.PUT_LINE('TABLE DATA:');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * FROM SQL_BUG_TEST ORDER BY X,Y,Z;');
FOR crs IN (SELECT *
FROM SQL_BUG_TEST
ORDER BY X,Y,Z) LOOP
DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
END LOOP;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 1
-- returning result from MAX into a variable when the MAX is in the outer most select
-- does not cause an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 1');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y');
FOR crs IN (SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y
ORDER BY X,Y,Z) LOOP
DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
END LOOP;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 2
-- returning MAX() from an inner select to an outer select and then into a variable
-- causes an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 2');
DBMS_OUTPUT.PUT_LINE('THIS DID NOT CAUSE AN ERROR WITH ORACLE 9i');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT * INTO v_rec
FROM
(SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 3
-- casting the result from MAX to char before returning to the outer select
-- still causes an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 3');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, to_char(MAX(Z)) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT * INTO v_rec
FROM
(SELECT X, Y, to_char(MAX(Z)) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 4 - SOLUTION
-- the return value of MAX must be cast with to_char at the point where it is assigned to
-- variable (outer most select)
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 4 SOLUTION');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT X, Y, TO_CHAR(Z) Z INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT X, Y, TO_CHAR(Z) Z INTO v_rec
FROM
(SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
END;I certainly looks like a bug, but you should raise an iTAR on Metalink since Oracle does not monitor this forum.
I was able to replicate your results on my 10.2.0.1 database.
There is an easier workaround than yours. Try
ALTER TABLE sql_bug_test MODIFY (z VARCHAR2(1));That seems to eliminate the problem on my instance.
John -
Difference between varchar2(4000 byte) & varchar2(4000 char
Hi,
My existing database NLS parameters as follows
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
created a test database to support globalization, I changed as follows
CHARACTER SET UTF8
NATIONAL CHARACTER SET UTF8
some of the table column datatypes are varchar2(4000)
I would like to know what is difference between VARCHAR2(4000 BYTE) and VARCHAR2(4000 CHAR).
ThanksIndeed, VARCHAR2(x BYTE) means that the column will hold as much characters as will fit into x bytes. Depending on the character set and particular characters this may be x or less characters.
For example, a VARCHAR2(20 BYTE) column in an AL32UTF8 database can hold 20 characters from the ASCII range, 10 Latin letters with umlaut, 10 Cyryllic, 10 Hebrew, or 10 Arabic letters (2 bytes per character), or 6 Chinese, Japanese, Korean, or Devanagari (Indic) characters. Or a mixture of these characters of any total length up to 20 bytes.
VARCHAR2(x CHAR) means that the column will hold x characters but not more than can fit into 4000 bytes. Internally, Oracle will set the byte length of the column (DBA_TAB_COLUMNS.DATA_LENGTH) to MIN(x * mchw, 4000), where mchw is the maximum byte width of a character in the database character set. This is 1 for US7ASCII or WE8MSWIN1252, 2 for JA16SJIS, 3 for UTF8, and 4 for AL32UTF8.
For example, a VARCHAR2(3000 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 4000 bytes. It will hold up to 3000 characters from the ASCII range (the character limit), but only 1333 Chinese characters (the byte limit, 1333 * 3 bytes = 3999 bytes). A VARCHAR2(100 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 400 bytes. It will hold up to any 100 Unicode characters.
The above implies that the CHAR limit works optimally if it is lower than 4000/mchw. With such restriction, the CHAR limit guarantees that the defined number of characters will fit into the column. Because the widest character in any Oracle character set has 4 bytes, if x <= 1000, VARCHAR2(x CHAR) is guaranteed to hold up to x characters in any database character set.
The declaration VARCHAR2(x):
- for objects defined in SYS schema means VARCHAR2(x BYTE),
- for objects defined in other schemas it means VARCHAR2(x BYTE) or VARCHAR2(x CHAR), depending on the value of the NLS_LENGTH_SEMANTICS parameter of the session using the declaration (see the NLS_SESSION_PARAMETERS view).
After an object is defined, its BYTE vs CHAR semantics is stored in the data dictionary and it does not depend on the NLS_LENGTH_SEMANTICS any longer. Even Export/Import will not change this.
Character length semantics rules are valid for table columns and for PL/SQL variables.
-- Sergiusz -
Difference between VARCHAR2(40 BYTE) and VARCHAR2(40 CHAR)
What is the difference between using VARCHAR2(40), VARCHAR2(40 BYTE0, and VARCHAR2(40 CHAR)
With a single byte character set the two definitions are effictively equal, but with a multibyte character set the two definitions will be different. Say you have built Oracle using a fixed 2 byte character set. 40 characters would be 80 bytes so the varchar2(40 BYTES) would hold only 20 characters.
Search on NLS parameters and database character set for more information.
HTH -- Mark D Powell -- -
Whats the use of having pragma autonomous transaction
Hii All,
The below is the procedure developed by our predecessors.We are making use of this for writing our debug messages.
I'm aware of pragma autonomous transaction ,this allows my code to run independently of the calling program.
But here we are just using utl_File and we are neither using any DML(Inserting error messages into a table) or DDL statements in the below code.
What is real use of having pragma autonomous transaction.???This code is working in the same way even without the pragma...I dont' find any difference .
Please let me know the use of having pragma autonomous transaction in the below procedure and where it actually comes into usage.
Create or replace Procedure logmesg
p_file_name in varchar2,
p_mesg_text in varchar2,
p_dir_path in varchar2 default fn_get_debug_path,
p_file_ext in varchar2 default 'log',
p_append_flag in varchar2 default 'Y'
) Is
pragma autonomous_transaction;
l_utl_file utl_file.file_type;
l_append_flag varchar2(1);
l_mesg_text varchar2(32000);
l_file_name varchar2(3000);
l_dir_path varchar2(32000);
l_delimeter_occurance number;
l_buffer_str varchar2(32000);
Begin
if trim(p_dir_path) is null then
l_dir_path := fn_get_debug_path ;
else
l_dir_path := p_dir_path;
end if;
l_mesg_text := p_mesg_text;
l_append_flag := nvl(p_append_flag,'Y');
l_file_name := p_file_name||'_'||to_char(sysdate,'ddmmyyyyhh')||'.'||p_file_ext;
l_append_flag := Case l_append_flag
When 'Y' then 'a'
When 'N' then 'w'
End;--l_append_flag
Begin
l_utl_file := utl_file.fopen(l_dir_path,l_file_name,l_append_flag);
Exception
When Others Then
l_utl_file := utl_file.fopen(l_dir_path,l_file_name,'w');
End;
if dbms_lob.getlength(l_mesg_text) > 32000 then
loop
exit when dbms_lob.getlength(l_mesg_text) < 32000;
l_delimeter_occurance := dbms_lob.instr(l_mesg_text,chr(32),1,1);
l_buffer_str := dbms_lob.substr(l_mesg_text,l_delimeter_occurance-1);
utl_file.put_line(l_utl_file,l_buffer_str);
l_mesg_text := dbms_lob.substr(l_mesg_text,l_delimeter_occurance+1);
utl_file.fflush(l_utl_file);
end loop;
end if;
utl_file.put_line(l_utl_file,l_mesg_text);
utl_file.fflush(l_utl_file);
utl_file.fclose(l_utl_file);
End logmesg;
/HerePlease let me know the use of having pragma autonomous transaction in the below procedure and where it actually comes into usage.Seems it is redundant in that procedure, and doesn't add any value, since the procedure isn't doing anything 'transactional'.
I would remove it. -
Issue: Not getting response when the document is having special chars
Please help following issue: Not getting response when the document is having special chars(Use any doc with special char(ex: &, $, <, >,.....) TestErrorFour.doc
Error message:
System.FormatException: Invalid length for a Base-64 char array. at
System.Convert.FromBase64String(String s) at
Summarize.Summarizer.AccumulateBroadcast(String filedata, String givenWords) in
c:\DocumentSummarizer\App_Code\Summarizer.cs:line 66
Code:
File 1:
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.extractor.*;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PRTokeniser;
import com.lowagie.text.pdf.PdfReader;
public class DocumentSummarizerClient {
static Properties loadProperties() {
Properties prop = new Properties();
try {
prop.load(DocumentSummarizerClient.class.getClassLoader().getResourceAsStream("vep.properties"));
} catch (Exception ioe) {
ioe.printStackTrace();
return prop;
public String getSummary(String fileName,String noOfWordsOrPercentage ){
String summaryInputData ="";
String summarizedData="";
String summarizerURL = loadProperties().getProperty("Summarizer.serviceURL");
try {
String fileExtension=fileName.substring(fileName.lastIndexOf(".")+1, fileName.length());
if (fileExtension.equalsIgnoreCase("doc")|| fileExtension.equalsIgnoreCase("txt")|| fileExtension.equalsIgnoreCase("pdf")) {
if (fileExtension.equalsIgnoreCase("txt")) {
BufferedReader bufferedReader = new BufferedReader(
new FileReader(fileName));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
summaryInputData += line;
if(fileExtension.equalsIgnoreCase("doc")){
POIFSFileSystem fs = null;
fs = new POIFSFileSystem(new FileInputStream(fileName));
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
String[] paragraphs = we.getParagraphText();
for( int i=0; i<paragraphs .length; i++ ) {
paragraphs[i] = paragraphs.replaceAll("\\cM?\r?\n","");
summaryInputData+= paragraphs[i];
if(fileExtension.equalsIgnoreCase("pdf")){
Document document = new Document();
document.open();
PdfReader reader = new PdfReader(fileName);
int pageCount =reader.getNumberOfPages();
for(int i=1;i<=pageCount;i++){
byte[] bytes = reader.getPageContent(i);
PRTokeniser tokenizer = new PRTokeniser(bytes);
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());
summaryInputData += buffer.toString();
else{
System.out.println("This is Invalid document. Presntly we support only text,word and PDF documents ");
// String encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String encoded=Base64Utils.base64Encode(summaryInputData.getBytes());
// encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String parameters= "base64String="+encoded+"&noOfWordsOrPercentage="+noOfWordsOrPercentage;
summarizedData= postRequest(parameters,summarizerURL);
String slength= "<string xmlns=\"http://tempuri.org/\">";
if(summarizedData.contains("</string>")){
summarizedData= summarizedData.substring(summarizedData.indexOf(slength)+slength.length(),summarizedData.indexOf("</string>"));
summarizedData = replaceVal(summarizedData);
//System.out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?><![CDATA["+summarizedData+"]]>");
// System.out.println("Summarized data "+summarizedData);
if(summarizedData.contains("Please enter the percentage")){
summarizedData="Data given cannot be summarized further";
else{
System.out.println("Data given cannot be summarized further");
summarizedData="";
} catch (FileNotFoundException e) {
return("The File is not found \n\n"+e.toString());
} catch (IOException e) {
return("The File is already in use \n\n"+e.toString());
} catch (Exception e) {
return(e.toString());
return summarizedData;
public static String postRequest(String parameters,String webServiceURL) throws Exception{
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", loadProperties().getProperty("proxyHost"));
systemSettings.put("http.proxyPort", loadProperties().getProperty("proxyPort"));
System.setProperties(systemSettings);
String responseXML = "";
try {
URL url = new URL(webServiceURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
byte[] requestXML = parameters.getBytes();
httpConn.setRequestProperty("Content-Length", String
.valueOf(requestXML.length));
httpConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
OutputStream out = httpConn.getOutputStream();
out.write(requestXML, 0, requestXML.length);
out.close();
InputStreamReader isr = new InputStreamReader(httpConn
.getInputStream());
BufferedReader br = new BufferedReader(isr);
String temp;
String tempResponse = "";
while ((temp = br.readLine()) != null)
tempResponse = tempResponse + temp;
responseXML = tempResponse;
br.close();
isr.close();
} catch (java.net.MalformedURLException e) {
System.out
.println("Error in postRequest(): Secure Service Required");
} catch (Exception e) {
System.out.println("Error in postRequest(): " + e.getMessage());
return responseXML;
public String replaceVal(String value) {
if (value == null) {
value = "";
value = value.replace("<", "<");
value = value.replace(">", ">");
value = value.replace("&", "&");
return value;
public static void main(String[] args) {
DocumentSummarizerClient testdoc=new DocumentSummarizerClient();
System.out.println("hello");
testdoc.getSummary("C:\\working_folder\\vep\\UnitTestCases\\VEP1.0\\DocumentSummarizerTestData\\TestErrorFour.doc","100%");
Note: Use any doc with special char(ex: &, $, <, >,.....) TestErrorFour.doc
File 2:
---------public class Base64Utils {
private static byte[] mBase64EncMap, mBase64DecMap;
* Class initializer. Initializes the Base64 alphabet (specified in RFC-2045).
static {
byte[] base64Map = {
(byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F',
(byte)'G', (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L',
(byte)'M', (byte)'N', (byte)'O', (byte)'P', (byte)'Q', (byte)'R',
(byte)'S', (byte)'T', (byte)'U', (byte)'V', (byte)'W', (byte)'X',
(byte)'Y', (byte)'Z',
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f',
(byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l',
(byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r',
(byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x',
(byte)'y', (byte)'z',
(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
(byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'};
mBase64EncMap = base64Map;
mBase64DecMap = new byte[128];
for (int i=0; i<mBase64EncMap.length; i++)
mBase64DecMap[mBase64EncMap[i]] = (byte) i;
* This class isn't meant to be instantiated.
private Base64Utils() {
* Encodes the given byte[] using the Base64-encoding,
* as specified in RFC-2045 (Section 6.8).
* @param aData the data to be encoded
* @return the Base64-encoded <var>aData</var>
* @exception IllegalArgumentException if NULL or empty array is passed
public static String base64Encode(byte[] aData) {
if ((aData == null) || (aData.length == 0))
throw new IllegalArgumentException("Can not encode NULL or empty byte array.");
byte encodedBuf[] = new byte[((aData.length+2)/3)*4];
// 3-byte to 4-byte conversion
int srcIndex, destIndex;
for (srcIndex=0, destIndex=0; srcIndex < aData.length-2; srcIndex += 3) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] >>> 2) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] >>> 4) & 017 |
(aData[srcIndex] << 4) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+2] >>> 6) & 003 |
(aData[srcIndex+1] << 2) & 077];
encodedBuf[destIndex++] = mBase64EncMap[aData[srcIndex+2] & 077];
// Convert the last 1 or 2 bytes
if (srcIndex < aData.length) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] >>> 2) & 077];
if (srcIndex < aData.length-1) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] >>> 4) & 017 |
(aData[srcIndex] << 4) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] << 2) & 077];
else {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] << 4) & 077];
// Add padding to the end of encoded data
while (destIndex < encodedBuf.length) {
encodedBuf[destIndex] = (byte) '=';
destIndex++;
String result = new String(encodedBuf);
return result;
* Decodes the given Base64-encoded data,
* as specified in RFC-2045 (Section 6.8).
* @param aData the Base64-encoded aData.
* @return the decoded <var>aData</var>.
* @exception IllegalArgumentException if NULL or empty data is passed
public static byte[] base64Decode(String aData) {
if ((aData == null) || (aData.length() == 0))
throw new IllegalArgumentException("Can not decode NULL or empty string.");
byte[] data = aData.getBytes();
// Skip padding from the end of encoded data
int tail = data.length;
while (data[tail-1] == '=')
tail--;
byte decodedBuf[] = new byte[tail - data.length/4];
// ASCII-printable to 0-63 conversion
for (int i = 0; i < data.length; i++)
data[i] = mBase64DecMap[data[i]];
// 4-byte to 3-byte conversion
int srcIndex, destIndex;
for (srcIndex = 0, destIndex=0; destIndex < decodedBuf.length-2;
srcIndex += 4, destIndex += 3) {
decodedBuf[destIndex] = (byte) ( ((data[srcIndex] << 2) & 255) |
((data[srcIndex+1] >>> 4) & 003) );
decodedBuf[destIndex+1] = (byte) ( ((data[srcIndex+1] << 4) & 255) |
((data[srcIndex+2] >>> 2) & 017) );
decodedBuf[destIndex+2] = (byte) ( ((data[srcIndex+2] << 6) & 255) |
(data[srcIndex+3] & 077) );
// Handle last 1 or 2 bytes
if (destIndex < decodedBuf.length)
decodedBuf[destIndex] = (byte) ( ((data[srcIndex] << 2) & 255) |
((data[srcIndex+1] >>> 4) & 003) );
if (++destIndex < decodedBuf.length)
decodedBuf[destIndex] = (byte) ( ((data[srcIndex+1] << 4) & 255) |
((data[srcIndex+2] >>> 2) & 017) );
return decodedBuf;
issue 2: Exception when passing 2MB .txt file
Steps to reproduce:
Call getSummary() with 2MB .txt file
Actual:
The following exception has occured:
1. Error in postRequest(): Unexpected end of file from server
java.lang.NullPointerException
Please provide your precious feedback/suggestions.
Thanks in advance…..
Edited by: EJP on 15/03/2011 16:52: added code tags. Please use them. Code is unreadable otherwise.Thanks for your response….
This is enhancement project and some one develops long back.
Regarding point (b) You should be using the java.net.URLEncoder to encode URL parameters, not a base64 encoder.
DocumentSummarizerClient.java I am using base64
Ex:
// String encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String encoded=Base64Utils.base64Encode(summaryInputData.getBytes());
// encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String parameters= "base64String="+encoded+"&noOfWordsOrPercentage="+noOfWordsOrPercentage;
summarizedData= postRequest(parameters,summarizerURL);
String slength= "<string xmlns=\"http://tempuri.org/\">";
if(summarizedData.contains("</string>")){
summarizedData= summarizedData.substring(summarizedData.indexOf(slength)+slength.length(),summarizedData.indexOf("</string>"));
summarizedData = replaceVal(summarizedData);
//System.out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?><![CDATA["+summarizedData+"]]>");
System.out.println("Summarized data "+summarizedData);
if(summarizedData.contains("Please enter the percentage")){
summarizedData="Data given cannot be summarized further";
Above specific please I need to modify to resolve above issue.
Could you please suggest me what changes I need to do.
Waiting for positive response. -
What is the use of COL_SELECT_MASK IN fm gui_download?
Hi i Just want to know what is the use of col_select_mask in GUI_DOWNLOAD.
currently i need to work on one report where they are passing this parameter to gui_download.
result is it is taking only 255 char column length in the downloaded excel...
i need to add extra fields to the downloaded excel..but it is taking only 255 how to over come this issue?
i tried commented the COL_SELECT_MASK but it is taking unnecessary fields in the internal table i dont know how come they are excluding some fields without downloading ?Any one any idea?
Regards
sas .Well thanks for the information.
Now i understood that
in itab there are 10 fields where user wants to see in the excel only 8 fields.
so they use col_mask parameter what ever columns we pass only those o/p we can see in the output.
so now that col_mask need to increase to few more fields in result which the size of excel is more than 255 char which in result need to display 8 + my 6 fileds = 14 fields.
due to over size it is displaying only 10 fields. Rest 4 are missing.
so using COL_MASK is there any way to define more than 255 char column length?
Regards
sas....
DiD you check the FM where it is written as if col_sel = 'X'.
COL_SLE_MASK = 'xxx'.
then it will download 1 , 3 5 columns???/
what is this i dont understand???
Regards
sas -
The usefulness (?) of XMLDIFF in database change management
I post my example here as well, because maybe it is useful to some, for instance, regarding the use of the syntax. The example is explained more deeply here (at least the reasons why I did what I did).: http://www.liberidu.com/blog/?p=394
Some help is still appreciated from you ("you" as in you the "XMLTable and/or XQuery wizards") regarding the "LINE" problem at the end of the post/example given here.
Have a look here (and enjoy the examples).
M.
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
SQL> set long 10000000
SQL> set pages 5000
SQL> set lines 200
SQL> create table A
2 (id number(10));
Table created.
SQL> create table B
2 (id number(15));
Table created.
SQL> create table C
2 (id number(10),
3 extra varchar2(50));
Table created.
SQL> select dbms_metadata.get_ddl('TABLE','A') from dual;
DBMS_METADATA.GET_DDL('TABLE','A')
CREATE TABLE "SYSTEM"."A"
( "ID" NUMBER(10,0)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
SQL> select dbms_metadata.get_ddl('TABLE','B') from dual;
DBMS_METADATA.GET_DDL('TABLE','B')
CREATE TABLE "SYSTEM"."B"
( "ID" NUMBER(15,0)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
SQL> select dbms_metadata.get_ddl('TABLE','C') from dual;
DBMS_METADATA.GET_DDL('TABLE','C')
CREATE TABLE "SYSTEM"."C"
( "ID" NUMBER(10,0),
"EXTRA" VARCHAR2(50)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
TABLESPACE "SYSTEM"
SQL> SELECT dbms_metadata.compare_alter('TABLE','A','B',USER,USER) from dual;
DBMS_METADATA.COMPARE_ALTER('TABLE','A','B',USER,USER)
ALTER TABLE "SYSTEM"."A" MODIFY ("ID" NUMBER(15,0))
ALTER TABLE "SYSTEM"."A" RENAME TO "B"
SQL> SELECT dbms_metadata.compare_alter('TABLE','A','C',USER,USER) from dual;
DBMS_METADATA.COMPARE_ALTER('TABLE','A','C',USER,USER)
ALTER TABLE "SYSTEM"."A" ADD ("EXTRA" VARCHAR2(50))
ALTER TABLE "SYSTEM"."A" RENAME TO "C"
SQL> SELECT dbms_metadata.compare_alter('TABLE','B','C',USER,USER) from dual;
DBMS_METADATA.COMPARE_ALTER('TABLE','B','C',USER,USER)
ALTER TABLE "SYSTEM"."B" ADD ("EXTRA" VARCHAR2(50))
ALTER TABLE "SYSTEM"."B" MODIFY ("ID" NUMBER(10,0))
ALTER TABLE "SYSTEM"."B" RENAME TO "C"
SQL> SELECT dbms_metadata.compare_alter_xml('TABLE','A','B',USER,USER) from dual;
DBMS_METADATA.COMPARE_ALTER_XML('TABLE','A','B',USER,USER)
<ALTER_XML xmlns="http://xmlns.oracle.com/ku" version="1.0">
<OBJECT_TYPE>TABLE</OBJECT_TYPE>
<OBJECT1>
<SCHEMA>SYSTEM</SCHEMA>
<NAME>A</NAME>
</OBJECT1>
<OBJECT2>
<SCHEMA>SYSTEM</SCHEMA>
<NAME>B</NAME>
</OBJECT2>
<ALTER_LIST>
<ALTER_LIST_ITEM>
<SQL_LIST>
<SQL_LIST_ITEM>ALTER TABLE "SYSTEM"."A" MODIFY ("ID" NUMBER(15,0))</SQL_LIST_ITEM>
</SQL_LIST>
</ALTER_LIST_ITEM>
<ALTER_LIST_ITEM>
<SQL_LIST>
<SQL_LIST_ITEM>ALTER TABLE "SYSTEM"."A" RENAME TO "B"</SQL_LIST_ITEM>
</SQL_LIST>
</ALTER_LIST_ITEM>
</ALTER_LIST>
</ALTER_XML>
SQL> SELECT dbms_metadata.compare_sxml('TABLE','A','B',USER,USER) from dual;
DBMS_METADATA.COMPARE_SXML('TABLE','A','B',USER,USER)
<TABLE xmlns="http://xmlns.oracle.com/ku" version="1.0">
<SCHEMA>SYSTEM</SCHEMA>
<NAME value1="A">B</NAME>
<RELATIONAL_TABLE>
<COL_LIST>
<COL_LIST_ITEM>
<NAME>ID</NAME>
<DATATYPE>NUMBER</DATATYPE>
<PRECISION value1="10">15</PRECISION>
<SCALE>0</SCALE>
</COL_LIST_ITEM>
</COL_LIST>
<PHYSICAL_PROPERTIES>
<HEAP_TABLE>
<SEGMENT_ATTRIBUTES>
<PCTFREE>10</PCTFREE>
<PCTUSED>40</PCTUSED>
<INITRANS>1</INITRANS>
<STORAGE>
<INITIAL>65536</INITIAL>
<NEXT>1048576</NEXT>
<MINEXTENTS>1</MINEXTENTS>
<MAXEXTENTS>2147483645</MAXEXTENTS>
<PCTINCREASE>0</PCTINCREASE>
<FREELISTS>1</FREELISTS>
<FREELIST_GROUPS>1</FREELIST_GROUPS>
<BUFFER_POOL>DEFAULT</BUFFER_POOL>
</STORAGE>
<TABLESPACE>SYSTEM</TABLESPACE>
<LOGGING>Y</LOGGING>
</SEGMENT_ATTRIBUTES>
<COMPRESS>N</COMPRESS>
</HEAP_TABLE>
</PHYSICAL_PROPERTIES>
</RELATIONAL_TABLE>
</TABLE>
SQL> SELECT dbms_metadata.get_sxml('TABLE', 'A', USER) from dual;
DBMS_METADATA.GET_SXML('TABLE','A',USER)
<TABLE xmlns="http://xmlns.oracle.com/ku" version="1.0">
<SCHEMA>SYSTEM</SCHEMA>
<NAME>A</NAME>
<RELATIONAL_TABLE>
<COL_LIST>
<COL_LIST_ITEM>
<NAME>ID</NAME>
<DATATYPE>NUMBER</DATATYPE>
<PRECISION>10</PRECISION>
<SCALE>0</SCALE>
</COL_LIST_ITEM>
</COL_LIST>
<PHYSICAL_PROPERTIES>
<HEAP_TABLE>
<SEGMENT_ATTRIBUTES>
<PCTFREE>10</PCTFREE>
<PCTUSED>40</PCTUSED>
<INITRANS>1</INITRANS>
<STORAGE>
<INITIAL>65536</INITIAL>
<NEXT>1048576</NEXT>
<MINEXTENTS>1</MINEXTENTS>
<MAXEXTENTS>2147483645</MAXEXTENTS>
<PCTINCREASE>0</PCTINCREASE>
<FREELISTS>1</FREELISTS>
<FREELIST_GROUPS>1</FREELIST_GROUPS>
<BUFFER_POOL>DEFAULT</BUFFER_POOL>
</STORAGE>
<TABLESPACE>SYSTEM</TABLESPACE>
<LOGGING>Y</LOGGING>
</SEGMENT_ATTRIBUTES>
<COMPRESS>N</COMPRESS>
</HEAP_TABLE>
</PHYSICAL_PROPERTIES>
</RELATIONAL_TABLE>
</TABLE>
-- dbms_metadata.set_transform_param
-- http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_metada.htm#i1000135
SQL> exec dbms_metadata.set_transform_param( dbms_metadata.session_transform, 'STORAGE', FALSE);
PL/SQL procedure successfully completed.
SQL> select dbms_metadata.get_ddl('TABLE','A') from dual;
DBMS_METADATA.GET_DDL('TABLE','A')
CREATE TABLE "SYSTEM"."A"
( "ID" NUMBER(10,0)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "SYSTEM"
SQL> exec dbms_metadata.set_transform_param( dbms_metadata.session_transform, 'DEFAULT');
PL/SQL procedure successfully completed.
SQL> select dbms_metadata.get_ddl('TABLE','A') from dual;
DBMS_METADATA.GET_DDL('TABLE','A')
CREATE TABLE "SYSTEM"."A"
( "ID" NUMBER(10,0)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SYSTEM"
SQL> exec dbms_metadata.set_transform_param( dbms_metadata.session_transform, 'SEGMENT_ATTRIBUTES', FALSE);
PL/SQL procedure successfully completed.
SQL> select dbms_metadata.get_ddl('TABLE','A') from dual;
DBMS_METADATA.GET_DDL('TABLE','A')
CREATE TABLE "SYSTEM"."A"
( "ID" NUMBER(10,0)
-- dbms_metadata.set_transform_param ONLY for DDL statements...
-- http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_metada.htm#i1019414
SQL> select dbms_metadata.get_xml('TABLE','A') from dual;
DBMS_METADATA.GET_XML('TABLE','A')
<?xml version="1.0"?><ROWSET><ROW>
<TABLE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>2 </VERS_MINOR>
<OBJ_NUM>58932</OBJ_NUM>
<SCHEMA_OBJ>
<OBJ_NUM>58932</OBJ_NUM>
<DATAOBJ_NUM>58932</DATAOBJ_NUM>
<OWNER_NUM>5</OWNER_NUM>
<OWNER_NAME>SYSTEM</OWNER_NAME>
<NAME>A</NAME>
<NAMESPACE>1</NAMESPACE>
<TYPE_NUM>2</TYPE_NUM>
<TYPE_NAME>TABLE</TYPE_NAME>
<CTIME>2008-03-19 11:16:45</CTIME>
<MTIME>2008-03-19 11:16:45</MTIME>
<STIME>2008-03-19 11:16:45</STIME>
<STATUS>1</STATUS>
<FLAGS>0</FLAGS>
<SPARE1>6</SPARE1>
<SPARE2>1</SPARE2>
<SPARE3>5</SPARE3>
</SCHEMA_OBJ>
<STORAGE>
<FILE_NUM>1</FILE_NUM>
<BLOCK_NUM>65369</BLOCK_NUM>
<TYPE_NUM>5</TYPE_NUM>
<TS_NUM>0</TS_NUM>
<BLOCKS>8</BLOCKS>
<EXTENTS>1</EXTENTS>
<INIEXTS>8</INIEXTS>
<MINEXTS>1</MINEXTS>
<MAXEXTS>2147483645</MAXEXTS>
<EXTSIZE>128</EXTSIZE>
<EXTPCT>0</EXTPCT>
<USER_NUM>5</USER_NUM>
<LISTS>1</LISTS>
<GROUPS>1</GROUPS>
<BITMAPRANGES>2147483645</BITMAPRANGES>
<CACHEHINT>0</CACHEHINT>
<SCANHINT>0</SCANHINT>
<HWMINCR>58932</HWMINCR>
<FLAGS>4325377</FLAGS>
</STORAGE>
<TS_NAME>SYSTEM</TS_NAME>
<BLOCKSIZE>8192</BLOCKSIZE>
<DATAOBJ_NUM>58932</DATAOBJ_NUM>
<COLS>1</COLS>
<PCT_FREE>10</PCT_FREE>
<PCT_USED>40</PCT_USED>
<INITRANS>1</INITRANS>
<MAXTRANS>255</MAXTRANS>
<FLAGS>1</FLAGS>
<AUDIT_VAL>--------------------------------------</AUDIT_VAL>
<INTCOLS>1</INTCOLS>
<KERNELCOLS>1</KERNELCOLS>
<PROPERTY>536870912</PROPERTY>
<PROPERTY2>0</PROPERTY2>
<XMLSCHEMACOLS>N</XMLSCHEMACOLS>
<TRIGFLAG>0</TRIGFLAG>
<SPARE1>736</SPARE1>
<SPARE6>19-MAR-08</SPARE6>
<COL_LIST>
<COL_LIST_ITEM>
<OBJ_NUM>58932</OBJ_NUM>
<COL_NUM>1</COL_NUM>
<INTCOL_NUM>1</INTCOL_NUM>
<SEGCOL_NUM>1</SEGCOL_NUM>
<PROPERTY>0</PROPERTY>
<NAME>ID</NAME>
<TYPE_NUM>2</TYPE_NUM>
<LENGTH>22</LENGTH>
<PRECISION_NUM>10</PRECISION_NUM>
<SCALE>0</SCALE>
<NOT_NULL>0</NOT_NULL>
<CHARSETID>0</CHARSETID>
<CHARSETFORM>0</CHARSETFORM>
<BASE_INTCOL_NUM>1</BASE_INTCOL_NUM>
<BASE_COL_TYPE>0</BASE_COL_TYPE>
<SPARE1>0</SPARE1>
<SPARE2>0</SPARE2>
<SPARE3>0</SPARE3>
</COL_LIST_ITEM>
</COL_LIST>
<CON0_LIST/>
<CON1_LIST/>
<CON2_LIST/>
<REFPAR_LEVEL>0</REFPAR_LEVEL>
</TABLE_T>
</ROW></ROWSET>
SQL> select dbms_metadata.get_xml('TABLE','B') from dual;
DBMS_METADATA.GET_XML('TABLE','B')
<?xml version="1.0"?><ROWSET><ROW>
<TABLE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>2 </VERS_MINOR>
<OBJ_NUM>58933</OBJ_NUM>
<SCHEMA_OBJ>
<OBJ_NUM>58933</OBJ_NUM>
<DATAOBJ_NUM>58933</DATAOBJ_NUM>
<OWNER_NUM>5</OWNER_NUM>
<OWNER_NAME>SYSTEM</OWNER_NAME>
<NAME>B</NAME>
<NAMESPACE>1</NAMESPACE>
<TYPE_NUM>2</TYPE_NUM>
<TYPE_NAME>TABLE</TYPE_NAME>
<CTIME>2008-03-19 11:17:05</CTIME>
<MTIME>2008-03-19 11:17:05</MTIME>
<STIME>2008-03-19 11:17:05</STIME>
<STATUS>1</STATUS>
<FLAGS>0</FLAGS>
<SPARE1>6</SPARE1>
<SPARE2>1</SPARE2>
<SPARE3>5</SPARE3>
</SCHEMA_OBJ>
<STORAGE>
<FILE_NUM>1</FILE_NUM>
<BLOCK_NUM>65377</BLOCK_NUM>
<TYPE_NUM>5</TYPE_NUM>
<TS_NUM>0</TS_NUM>
<BLOCKS>8</BLOCKS>
<EXTENTS>1</EXTENTS>
<INIEXTS>8</INIEXTS>
<MINEXTS>1</MINEXTS>
<MAXEXTS>2147483645</MAXEXTS>
<EXTSIZE>128</EXTSIZE>
<EXTPCT>0</EXTPCT>
<USER_NUM>5</USER_NUM>
<LISTS>1</LISTS>
<GROUPS>1</GROUPS>
<BITMAPRANGES>2147483645</BITMAPRANGES>
<CACHEHINT>0</CACHEHINT>
<SCANHINT>0</SCANHINT>
<HWMINCR>58933</HWMINCR>
<FLAGS>4325377</FLAGS>
</STORAGE>
<TS_NAME>SYSTEM</TS_NAME>
<BLOCKSIZE>8192</BLOCKSIZE>
<DATAOBJ_NUM>58933</DATAOBJ_NUM>
<COLS>1</COLS>
<PCT_FREE>10</PCT_FREE>
<PCT_USED>40</PCT_USED>
<INITRANS>1</INITRANS>
<MAXTRANS>255</MAXTRANS>
<FLAGS>1</FLAGS>
<AUDIT_VAL>--------------------------------------</AUDIT_VAL>
<INTCOLS>1</INTCOLS>
<KERNELCOLS>1</KERNELCOLS>
<PROPERTY>536870912</PROPERTY>
<PROPERTY2>0</PROPERTY2>
<XMLSCHEMACOLS>N</XMLSCHEMACOLS>
<TRIGFLAG>0</TRIGFLAG>
<SPARE1>736</SPARE1>
<SPARE6>19-MAR-08</SPARE6>
<COL_LIST>
<COL_LIST_ITEM>
<OBJ_NUM>58933</OBJ_NUM>
<COL_NUM>1</COL_NUM>
<INTCOL_NUM>1</INTCOL_NUM>
<SEGCOL_NUM>1</SEGCOL_NUM>
<PROPERTY>0</PROPERTY>
<NAME>ID</NAME>
<TYPE_NUM>2</TYPE_NUM>
<LENGTH>22</LENGTH>
<PRECISION_NUM>15</PRECISION_NUM>
<SCALE>0</SCALE>
<NOT_NULL>0</NOT_NULL>
<CHARSETID>0</CHARSETID>
<CHARSETFORM>0</CHARSETFORM>
<BASE_INTCOL_NUM>1</BASE_INTCOL_NUM>
<BASE_COL_TYPE>0</BASE_COL_TYPE>
<SPARE1>0</SPARE1>
<SPARE2>0</SPARE2>
<SPARE3>0</SPARE3>
</COL_LIST_ITEM>
</COL_LIST>
<CON0_LIST/>
<CON1_LIST/>
<CON2_LIST/>
<REFPAR_LEVEL>0</REFPAR_LEVEL>
</TABLE_T>
</ROW></ROWSET>
SQL> desc a
Name Null? Type
ID NUMBER(10)
SQL> desc b
Name Null? Type
ID NUMBER(15)
SQL> exec dbms_metadata.set_transform_param( dbms_metadata.session_transform, 'DEFAULT');
PL/SQL procedure successfully completed.
SQL> select XMLDIFF(
2 xmltype(dbms_metadata.get_xml('TABLE','A')),
3 xmltype(dbms_metadata.get_xml('TABLE','B'))
4 ) as "DIFFERENCES"
5 from dual;
DIFFERENCES
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd"
xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]">
<xd:content>B</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/CTIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/MTIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/STIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/BLOCK_NUM[1]/text()[1]">
<xd:content>65377</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/HWMINCR[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/PRECISION_NUM[1]/text()[1]">
<xd:content>15</xd:content>
</xd:update-node>
</xd:xdiff>
SQL> select XMLDIFF(
2 xmltype(dbms_metadata.get_xml('TABLE','B')),
3 xmltype(dbms_metadata.get_xml('TABLE','A'))
4 ) as "DIFFERENCES"
5 from dual;
DIFFERENCES
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd"
xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-al
gorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]">
<xd:content>A</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/CTIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/MTIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/STIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/BLOCK_NUM[1]/text()[1]">
<xd:content>65369</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/HWMINCR[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/PRECISION_NUM[1]/text()[1]">
<xd:content>10</xd:content>
</xd:update-node>
</xd:xdiff>
SQL> WITH tabxml AS
2 (SELECT XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','B'))
5 ) xmlset
6 FROM dual)
7 SELECT u.element_name
8 , u.element_value
9 FROM tabxml
10 , XMLTABLE
11 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
12 ,'//xd:update-node'
13 PASSING xmlset
14 COLUMNS element_name xmltype PATH '//xd:update-node/@xd:xpath'
15 , element_value xmltype PATH '//xd:content/text()'
16 ) u
17 ;
ELEMENT_NAME
ELEMENT_VALUE
/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ_NUM[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/OBJ_NUM[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/DATAOBJ_NUM[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]
B
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/CTIME[1]/text()[1]
2008-03-19 11:17:05
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/MTIME[1]/text()[1]
2008-03-19 11:17:05
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/STIME[1]/text()[1]
2008-03-19 11:17:05
/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/BLOCK_NUM[1]/text()[1]
65377
/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/HWMINCR[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/DATAOBJ_NUM[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/OBJ_NUM[1]/text()[1]
58933
/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_ITEM[1]/PRECISION_NUM[1]/text(
)[1]
15
12 rows selected.
SQL> WITH tabxml AS
2 (SELECT XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','B'))
5 ) xmlset
6 FROM dual)
7 SELECT u.element_name
8 , u.element_value
9 FROM tabxml
10 , XMLTABLE
11 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
12 ,'//xd:update-node'
13 PASSING xmlset
14 COLUMNS element_name xmltype PATH '//xd:update-node[@xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]"]'
15 , element_value xmltype PATH '//xd:content/text()'
16 ) u
17 WHERE u.element_name is not null
18 ;
ELEMENT_NAME
ELEMENT_VALUE
<xd:update-node xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xd:node-type="t
ext" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]"><xd
:content>B</xd:content></xd:update-node>
B
SQL> col NAME for a60
SQL> col VALUE for a20
SQL> WITH tabxml AS
2 (SELECT XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','B'))
5 ) xmlset
6 FROM dual)
7 SELECT extract(u.element_name,'//@xd:xpath','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "NAME"
8 , u.element_value as "VALUE"
9 FROM tabxml
10 , XMLTABLE
11 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
12 ,'//xd:update-node'
13 PASSING xmlset
14 COLUMNS element_name xmltype PATH '//xd:update-node[@xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]"]'
15 , element_value xmltype PATH '//xd:content/text()'
16 ) u
17 WHERE u.element_name is not null
18 ;
NAME VALUE
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1] B
SQL> select XMLCONCAT(XMLDIFF(
2 xmltype(dbms_metadata.get_xml('TABLE','A')),
3 xmltype(dbms_metadata.get_xml('TABLE','B'))
4 ),
5 XMLDIFF(
6 xmltype(dbms_metadata.get_xml('TABLE','B')),
7 xmltype(dbms_metadata.get_xml('TABLE','A'))
8 ) )
9 from dual;
XMLCONCAT(XMLDIFF(XMLTYPE(DBMS_METADATA.GET_XML('TABLE','A')),XMLTYPE(DBMS_METAD
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns
.oracle.com/xdb/xdiff.xsd" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmln
s:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-al
gorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ
_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/NAME[1]/text()[1]">
<xd:content>B</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/CTIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/MTIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/STIME[1]/text()[1]">
<xd:content>2008-03-19 11:17:05</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STO
RAGE[1]/BLOCK_NUM[1]/text()[1]">
<xd:content>65377</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STO
RAGE[1]/HWMINCR[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DAT
AOBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL
_LIST[1]/COL_LIST_ITEM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58933</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL
_LIST[1]/COL_LIST_ITEM[1]/PRECISION_NUM[1]/text()[1]">
<xd:content>15</xd:content>
</xd:update-node>
</xd:xdiff>
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns
.oracle.com/xdb/xdiff.xsd" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmln
s:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-al
gorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ
_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/DATAOBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/NAME[1]/text()[1]">
<xd:content>A</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/CTIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/MTIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCH
EMA_OBJ[1]/STIME[1]/text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STO
RAGE[1]/BLOCK_NUM[1]/text()[1]">
<xd:content>65369</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STO
RAGE[1]/HWMINCR[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DAT
AOBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL
_LIST[1]/COL_LIST_ITEM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL
_LIST[1]/COL_LIST_ITEM[1]/PRECISION_NUM[1]/text()[1]">
<xd:content>10</xd:content>
</xd:update-node>
</xd:xdiff>
SQL> WITH tabxml AS
2 ( select XMLCONCAT(XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','B'))
5 ),
6 XMLDIFF(
7 xmltype(dbms_metadata.get_xml('TABLE','B')),
8 xmltype(dbms_metadata.get_xml('TABLE','A'))
9 ) ) xmlset
10 from DUAL)
11 SELECT extract(u.element_name,'//@xd:xpath','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "NAME"
12 , u.element_value as "VALUE"
13 FROM tabxml
14 , XMLTABLE
15 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
16 ,'//xd:update-node'
17 PASSING xmlset
18 COLUMNS element_name xmltype PATH '//xd:update-node[@xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]"]'
19 , element_value xmltype PATH '//xd:content/text()'
20 ) u
21 WHERE u.element_name is not null
22 ;
NAME VALUE
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1] B
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1] A
SQL> WITH tabxml AS
2 ( select XMLCONCAT(XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','B'))
5 ),
6 XMLDIFF(
7 xmltype(dbms_metadata.get_xml('TABLE','B')),
8 xmltype(dbms_metadata.get_xml('TABLE','A'))
9 ) ) xmlset
10 from DUAL)
11 SELECT extract(u.element_name,'//@xd:xpath','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "NAME"
12 , u.element_value as "VALUE"
13 FROM tabxml
14 , XMLTABLE
15 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
16 ,'/xd:xdiff/xd:update-node'
17 PASSING xmlset
18 COLUMNS element_name xmltype PATH '/xd:update-node[@xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1]"]'
19 , element_value xmltype PATH '/xd:update-node/xd:content/text()'
20 ) u
21 WHERE u.element_name is not null
22 ;
NAME VALUE
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1] B
/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/text()[1] A
SQL> select XMLCONCAT(XMLDIFF(
2 xmltype(dbms_metadata.get_xml('TABLE','A')),
3 xmltype(dbms_metadata.get_xml('TABLE','C'))
4 ),
5 XMLDIFF(
6 xmltype(dbms_metadata.get_xml('TABLE','C')),
7 xmltype(dbms_metadata.get_xml('TABLE','A'))
8 ) )
9 from DUAL
10 ;
XMLCONCAT(XMLDIFF(XMLTYPE(DBMS_METADATA.GET_XML('TABLE','A')),XMLTYPE(DBMS_METADATA.GET_XML('TABLE',
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdif
f.xsd" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/OBJ_NUM[1
]/text()[1]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/DATAOBJ_N
UM[1]/text()[1]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/t
ext()[1]">
<xd:content>C</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/CTIME[1]/
text()[1]">
<xd:content>2008-03-19 15:08:47</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/MTIME[1]/
text()[1]">
<xd:content>2008-03-19 15:08:47</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/STIME[1]/
text()[1]">
<xd:content>2008-03-19 15:08:47</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/BLOCK_NUM[1]
/text()[1]">
<xd:content>65385</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/HWMINCR[1]/t
ext()[1]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DATAOBJ_NUM[1]/text()[1
]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COLS[1]/text()[1]">
<xd:content>2</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/INTCOLS[1]/text()[1]">
<xd:content>2</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/KERNELCOLS[1]/text()[1]
">
<xd:content>2</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_IT
EM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58935</xd:content>
</xd:update-node>
<xd:append-node xd:node-type="element" xd:parent-xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]">
<xd:content>
<COL_LIST_ITEM>
<OBJ_NUM>58935</OBJ_NUM>
<COL_NUM>2</COL_NUM>
<INTCOL_NUM>2</INTCOL_NUM>
<SEGCOL_NUM>2</SEGCOL_NUM>
<PROPERTY>0</PROPERTY>
<NAME>EXTRA</NAME>
<TYPE_NUM>1</TYPE_NUM>
<LENGTH>50</LENGTH>
<NOT_NULL>0</NOT_NULL>
<CHARSETID>873</CHARSETID>
<CHARSETFORM>1</CHARSETFORM>
<BASE_INTCOL_NUM>2</BASE_INTCOL_NUM>
<BASE_COL_TYPE>0</BASE_COL_TYPE>
<SPARE1>0</SPARE1>
<SPARE2>0</SPARE2>
<SPARE3>50</SPARE3>
</COL_LIST_ITEM>
</xd:content>
</xd:append-node>
</xd:xdiff>
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdif
f.xsd" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/OBJ_NUM[1
]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/DATAOBJ_N
UM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/NAME[1]/t
ext()[1]">
<xd:content>A</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/CTIME[1]/
text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/MTIME[1]/
text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/SCHEMA_OBJ[1]/STIME[1]/
text()[1]">
<xd:content>2008-03-19 11:16:45</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/BLOCK_NUM[1]
/text()[1]">
<xd:content>65369</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/STORAGE[1]/HWMINCR[1]/t
ext()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/DATAOBJ_NUM[1]/text()[1
]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COLS[1]/text()[1]">
<xd:content>1</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/INTCOLS[1]/text()[1]">
<xd:content>1</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/KERNELCOLS[1]/text()[1]
">
<xd:content>1</xd:content>
</xd:update-node>
<xd:update-node xd:node-type="text" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST_IT
EM[1]/OBJ_NUM[1]/text()[1]">
<xd:content>58932</xd:content>
</xd:update-node>
<xd:delete-node xd:node-type="element" xd:xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]/COL_LIST
_ITEM[2]"/>
</xd:xdiff>
SQL> col LENGTH for a10
SQL> WITH tabxml AS
2 ( select XMLCONCAT(XMLDIFF(
3 xmltype(dbms_metadata.get_xml('TABLE','A')),
4 xmltype(dbms_metadata.get_xml('TABLE','C'))
5 ),
6 XMLDIFF(
7 xmltype(dbms_metadata.get_xml('TABLE','C')),
8 xmltype(dbms_metadata.get_xml('TABLE','A'))
9 ) ) xmlset
10 from DUAL)
11 SELECT extract(v.append_name,'//@xd:parent-xpath','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "NAME"
12 , extract(v.append_value,'//COL_LIST_ITEM/NAME/text()','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "VALUE"
13 , extract(v.append_value,'//COL_LIST_ITEM/LENGTH/text()','xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd"') as "LENGTH"
14 FROM tabxml
15 , XMLTABLE
16 (XMLNAMESPACES ('http://xmlns.oracle.com/xdb/xdiff.xsd' AS "xd")
17 ,'/xd:xdiff/xd:append-node'
18 PASSING xmlset
19 COLUMNS append_name xmltype PATH '/xd:append-node[@xd:parent-xpath="/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1]"]'
20 , append_value xmltype PATH '/xd:append-node/xd:content'
21 ) v
22 WHERE v.append_name is not null
23 ;
NAME VALUE LENGTH
/ROWSET[1]/ROW[1]/TABLE_T[1]/COL_LIST[1] EXTRA 50
SQL> drop procedure proc_01;
Procedure dropped.
SQL>
SQL> create or replace procedure proc_01
2 as
3 begin
4 null;
5 end;
6 /
Procedure created.
SQL>
SQL> drop procedure proc_02;
Procedure dropped.
SQL>
SQL> create or replace procedure proc_02
2 as
3 begin
4 NULL;
5 -- this is extra
6 end;
7 /
Procedure created.
SQL> select dbms_metadata.get_ddl('PROCEDURE','PROC_01') from dual;
DBMS_METADATA.GET_DDL('PROCEDURE','PROC_01')
CREATE OR REPLACE PROCEDURE "SYSTEM"."PROC_01"
as
begin
null;
end;
SQL> select dbms_metadata.get_ddl('PROCEDURE','PROC_02') from dual;
DBMS_METADATA.GET_DDL('PROCEDURE','PROC_02')
CREATE OR REPLACE PROCEDURE "SYSTEM"."PROC_02"
as
begin
NULL;
-- this is extra
end;
SQL> select dbms_metadata.get_xml('PROCEDURE','PROC_01') from dual;
DBMS_METADATA.GET_XML('PROCEDURE','PROC_01')
<?xml version="1.0"?><ROWSET><ROW>
<PROCEDURE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>1 </VERS_MINOR>
<OBJ_NUM>58937</OBJ_NUM>
<TYPE_NUM>7</TYPE_NUM>
<SCHEMA_OBJ>
<OBJ_NUM>58937</OBJ_NUM>
<OWNER_NUM>5</OWNER_NUM>
<OWNER_NAME>SYSTEM</OWNER_NAME>
<NAME>PROC_01</NAME>
<NAMESPACE>1</NAMESPACE>
<TYPE_NUM>7</TYPE_NUM>
<TYPE_NAME>PROCEDURE</TYPE_NAME>
<CTIME>2008-03-19 16:39:34</CTIME>
<MTIME>2008-03-19 16:39:34</MTIME>
<STIME>2008-03-19 16:39:34</STIME>
<STATUS>1</STATUS>
<FLAGS>0</FLAGS>
<SPARE1>6</SPARE1>
<SPARE2>65535</SPARE2>
<SPARE3>5</SPARE3>
</SCHEMA_OBJ>
<SOURCE_LINES>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58937</OBJ_NUM>
<LINE>1</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>18</POST_NAME_OFF>
<POST_KEYW>11</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>procedure proc_01
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58937</OBJ_NUM>
<LINE>2</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>as
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58937</OBJ_NUM>
<LINE>3</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>begin
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58937</OBJ_NUM>
<LINE>4</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE> null;
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58937</OBJ_NUM>
<LINE>5</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>end;</SOURCE>
</SOURCE_LINES_ITEM>
</SOURCE_LINES>
</PROCEDURE_T>
</ROW></ROWSET>
SQL> select dbms_metadata.get_xml('PROCEDURE','PROC_02') from dual;
DBMS_METADATA.GET_XML('PROCEDURE','PROC_02')
<?xml version="1.0"?><ROWSET><ROW>
<PROCEDURE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>1 </VERS_MINOR>
<OBJ_NUM>58938</OBJ_NUM>
<TYPE_NUM>7</TYPE_NUM>
<SCHEMA_OBJ>
<OBJ_NUM>58938</OBJ_NUM>
<OWNER_NUM>5</OWNER_NUM>
<OWNER_NAME>SYSTEM</OWNER_NAME>
<NAME>PROC_02</NAME>
<NAMESPACE>1</NAMESPACE>
<TYPE_NUM>7</TYPE_NUM>
<TYPE_NAME>PROCEDURE</TYPE_NAME>
<CTIME>2008-03-19 16:39:34</CTIME>
<MTIME>2008-03-19 16:39:34</MTIME>
<STIME>2008-03-19 16:39:34</STIME>
<STATUS>1</STATUS>
<FLAGS>0</FLAGS>
<SPARE1>6</SPARE1>
<SPARE2>65535</SPARE2>
<SPARE3>5</SPARE3>
</SCHEMA_OBJ>
<SOURCE_LINES>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58938</OBJ_NUM>
<LINE>1</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>18</POST_NAME_OFF>
<POST_KEYW>11</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>procedure proc_02
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58938</OBJ_NUM>
<LINE>2</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>as
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58938</OBJ_NUM>
<LINE>3</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0</POST_KEYW>
<PRE_NAME_LEN>0</PRE_NAME_LEN>
<SOURCE>begin
</SOURCE>
</SOURCE_LINES_ITEM>
<SOURCE_LINES_ITEM>
<OBJ_NUM>58938</OBJ_NUM>
<LINE>4</LINE>
<PRE_NAME>0</PRE_NAME>
<POST_NAME_OFF>0</POST_NAME_OFF>
<POST_KEYW>0<Hi ,
Document link :http://docs.oracle.com/cd/E23943_01/doc.1111/e10792/c04_settings.htm#CSMSP463
This gives details and sample for the configuration of JDBC storage with WCC .
Thanks,
Srinath -
Difference between nvarchar2( 10) and varchar2( 10 char)
Hi ,
I had to enhance my application's DB to support unicode data entries(Multilingual data entries) and retrieval. I want to know the basic difference between the following data type decalrations:
nvarchar2( 10) and varchar2( 10 char)
Can any one suggest me which would be a optimum choice?
regards,
SiddarthYes, you are almost correct.
Can you read Japanese Character ? (There is no need to understand Japanese words meanings).
Are you ready? Let's go!
SQL> create table tab_size(col varchar(3));
Table created.
SQL> insert into tab_size values ('abc');
1 row created.
SQL> insert into tab_size values ('abcd');
insert into tab_size values ('abcd')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
SQL> insert into tab_size values('アイウ'); /* This is 3 characters (3byte) */
1 row created.
SQL> insert into tab_size values('アイウエ'); /* This is 4 characters (4byte) */
insert into tab_size values('アイウエ')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
SQL> insert into tab_size values ('あ'); /* This is 1 character (2bytes) */
1 row created.
SQL> insert into tab_size values ('あい'); /* This is 2 characters (4bytes) */
insert into tab_size values ('あい')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
SQL> insert into tab_size values ('aあ'); /* This is 2 characters (3bytes) */
1 row created.
SQL> insert into tab_size values ('abあ'); /* This is 3 characters (4bytes) */
insert into tab_size values ('abあ')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_SIZE"."COL" (actual: 4, maximum: 3)
SQL> drop table tab_size;
Table dropped.
SQL> create table tab_char (col varchar2(3 char));
Table created.
SQL> insert into tab_char values ('abc');
1 row created.
SQL> insert into tab_char values ('abcd');
insert into tab_char values ('abcd')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4,
maximum: 3)
SQL> insert into tab_char values ('あいう'); /* This is 3 characters (6bytes) */
1 row created.
SQL> insert into tab_char values ('あいうえ'); /* This is 4 characters (8bytes) */
insert into tab_char values ('あいうえ')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4, maximum: 3)
SQL> insert into tab_char values ('aあい'); /* This is 3 characters (5bytes) */
1 row created.
SQL> insert into tab_char values ('abあい'); /* This is 4 characters (6bytes) */
insert into tab_char values ('abあい')
ERROR at line 1:
ORA-12899: value too large for column "USHI"."TAB_CHAR"."COL" (actual: 4, maximum: 3)谢谢。
ありがとう。
Thank you for reading. -
We have purchased 5 apple minis and would like them all on one account, that way we can monitor the use of these units. They will be used strickly for a business application. Can I use one account in itunes or must i have multiple.
Not going to happen the way you want it to.
When you add a gift card balance to the Apple ID, it's available for the Apple ID.
Probably best to create unique Apple ID's for each... this will also make things easier in the future as purchases are eternally tied to the Apple ID they were purchased with.
Maybe you are looking for
-
Use of SQL fetchlet to create a custom management plug-in
Hi, I would appreciate if you anyone could help me out on this: I need to fetch some data from EMF tables and create a custom Management plug-in in OEM so that it can be monitored from OEM itself. For getting the data from database table i am using S
-
Flash player security annoyance - connecting to URL from local file
I am trying to test some links for a button I have in my flash file. Everytime I try to do this, it brings up this ridiculous security screen window, saying that Flash has stopped a potentially unsafe operation. I then goto the settings pain. 'Always
-
Application server : Enterprise Manager ias Console - No response
Hi All, We have 10gApplication server infrastructure and the middle tier servives for discoverer installed In the infrastructure tier the Enterprise Manager ias Console is starting up with out any error message, but in the discoverer middle tier the
-
Get-ADUser -Filter {extensionAttribute1 -ne "aaa"} to get the users
I need get these users who's extensionAttribute1 is null or blank. I can run this commamd well : Get-ADUser -Filter {extensionAttribute1 -eq "aaa"} -SearchBase "OU=Sales,OU=aaa,DC=ccc,DC=ddd,DC=org" but when i change the "-eq" with "-ne", this comman
-
Sandy Bridge notebooks - when will they show up?
Anybody have any ideas as to when the Sandy Bridge laptops will arrive at stores?