Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Pierre.

Asked: September 01, 2009 - 11:12 am UTC

Last updated: April 04, 2012 - 12:03 pm UTC

Version: 10.2.0

Viewed 10K+ times! This question is

You Asked

Hi Tom,


Oracle has just shipped 11g release 2 for Linux on OTN.
What are your favorites features of release 2 with respect to release 1 ?

Thanks.

and Tom said...

I'll be posting a few of them in the Nov/Dec Oracle Magazine - but what I chose to write about was:

o data guard: automatic block level recovery using standby (we see something corrupt, we get good block from standby and fix it right away).
http://docs.oracle.com/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08777

Also - having a query "SLA" (service level agreement) of sorts, the ability to ship your read only queries to the standby as long as the standby is 'current enough', reducing workload on production.
http://docs.oracle.com/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08794


o the killer feature - Edition Based Redefinition
http://docs.oracle.com/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08709


o automated "do it yourself (DIY) parallelism. I've given "DIY" methods in the past:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:10498431232211
https://www.oracle.com/technetwork/issue-archive/2006/06-jan/o16asktom-101983.html

but now it is builtin

http://docs.oracle.com/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08597


o listagg :)

SQL> select deptno,
  2         listagg( ename, '; ' )
  3         within group
  4         (order by ename) enames
  5    from emp
  6   group by deptno
  7   order by deptno
  8  /

    DEPTNO ENAMES
---------- --------------------
        10 CLARK; KING; MILLER
        20 ADAMS; FORD; JONES;
           SCOTT; SMITH

        30 ALLEN; BLAKE;
           JAMES; MARTIN;
           TURNER; WARD




o EXECUTE privs on a directory (for use with the preprocesser option of external tables)

http://docs.oracle.com/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08784


o recursive subquery factoring

http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08835

o flashback data archive flexibility (supports DDL operations now)

http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#sthref11


o a file watcher

http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#sthref15


o deferred segment creation

http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/tables002.htm#CHDGJAGB


Rating

  (57 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

and

Sokrates, September 07, 2009 - 3:53 am UTC

... and ...
" Preprocessing Data for ORACLE_LOADER Access Driver in External Tables"
looks very nice, doesn't it ?
( http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08785 )

Now you can "mount" an Excel-xls-File as external-table, just write an appropriate pre-processor (xls2csv)

... and ...

"Recursive with Clause"
http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08835

allows you to solve SQL-Puzzles very simple like Mikito Harakiri did
http://vadimtropashko.wordpress.com/2008/11/18/finally
(no need to write Fourier Transformations in SQL)


... and ...
IGNORE_ROW_ON_DUPKEY_INDEX Hint for INSERT Statement
http://download.oracle.com/docs/cd/E11882_01/server.112/e10881/chapter1.htm#FEATURENO08842

: kind of hidden "when others then null;"

?

correction

Sokrates, September 07, 2009 - 4:57 am UTC

IGNORE_ROW_ON_DUPKEY_INDEX of course is not a hidden
"when others then null;"
but a hidden
"when dup_val_on_index then null;"

new possibilities of collect function

RC, September 09, 2009 - 3:23 pm UTC

I like the 2 new possibilities of the collect function.

1. the possibility to add distinct
2. the possibility to and order by.


Read here: http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions024.htm .

This is old news because they where already present in 11g1 but it escaped my attention because those two new possibilities aren't mentioned in the new features guide of 11gr1 or 11gr2.

You can use them to make your own specialized 'listagg' functions.


upgrade from 10g to 11g

tony wang, October 06, 2009 - 4:21 pm UTC

Hi Tom,
11g sounds great, but how to upgrade from 10g to 11g?
Thanks.
Tony
Tom Kyte
October 08, 2009 - 7:17 am UTC

start by reading the answer to this same exact question you posted on another page.

why do people do that? post the same there here, there, everywhere?

LISTAGG

Martijn, October 08, 2009 - 8:40 am UTC

Hi Tom,

Regarding this great thread:
http://asktom.oracle.com/pls/asktom/f?p=100:11:2119231749211243::::P11_QUESTION_ID:229614022562

And in 11g nowadays we can use LISTAGG
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/functions087.htm#SQLRF30030

Out-of-curiosity-question:
Were you in any way involved creating and/or designing LISTAGG?
Is it perhaps based on your TRANSPOSE function under it's covers?

A reader, October 08, 2009 - 9:56 am UTC

While executing the following statement , I am getting the error ORA-01489.
This is because of the resultant value exceeds 4000 characters .

Per manual
<quote>
The return data type is RAW if the measure column is RAW; otherwise the return value is VARCHAR2.
</quote>

Is there are any way to circumvent this limitation of varchar2?

Select m_id , bii_tag , listagg(a_value , '~') within group ( order by seq_no  ) ans_vald
          from ca
            where m_id = 100987
           group by m_id , bii_tag

ORA-01489: result of string concatenation is too long

Server Pool Vs Services

A reader, October 08, 2009 - 12:37 pm UTC

Tom .

What is the difference between Server Pool in 11gR2 and Services in 11r1/10g .... ?

Read the manual . I did not get differnce . Thanks for your time.

Oleksandr Alesinskyy, October 08, 2009 - 2:41 pm UTC

With all due respect -
would be second volume of your "Expert Oracle Database Architecture: 9i and 10g ..." named "
Expert Oracle Database Architecture: 12x and 13x" ?

what version is better between 11gr1 and 11gr2

John, October 10, 2009 - 7:48 pm UTC

Hi Tom,

if we have to upgrade to 11g, what release is better between the 11gr1 and 11gr2?


Thanks

recursive subquery factoring

James Su, October 11, 2009 - 11:32 am UTC

Dear Tom,
Can you show an example using the recursive subquery factoring feature that can not be achieved by using "connect by"?
Thanks.

... and some bug

Massimiliano Piccinini mp, October 19, 2009 - 8:16 am UTC

If you open the same cursor for thousands time (something like 10000)
in a 2 nodes rac, with CURSOR_SHARING similar, the gv$Sql_plan fill up of all similar lines, with an ora0600 - 17059.

Alexander, October 20, 2009 - 11:10 am UTC

Tom,

Can you explain why you like "Edition Based Redefinition" so much? I was reading about it, I guess I don't get it. In my experience modifying objects does not take long. Also, if you are doing an application upgrade, the application is going to be down, whether the database can remain active or not, don't you think? Trying to think of a useful real world situation where this would really save me.
Tom Kyte
October 22, 2009 - 4:59 pm UTC

... Also, if you are doing an application upgrade, the
application is going to be down, whether the database can remain active or not,
don't you think? ...

No, it doesn't have to be - and that is the entire point.

Installing the code - can be impossible in a production system without taking an outage.

If you want to install 5 'fixed' procedures - you cannot do it while they are running - you need to a) stop everyone, b) compile the five procedures c) make sure everything went Ok, recompile dependents - fix whatever and then you can let them back in.

EBR (edition based redefinition) removes step (a). They continue while you are doing your thing.

Of the 36 hours it takes to upgrade Oracle Apps - how many hours do you think is spent compiling plsql? (hint: it is double digits of hours)

Any change requires an outage in the past, now it doesn't.

My next three Oracle Magazine columns (starting in April I thing) will be about EBR - doing the simple easy case (patching - something we do very very often - no schema changes but code fixes - no downtime code fixes now). Then a harder case - to minimize the downtime to go to version two - we'll stage not only our code but ALSO ALL OF OUR SCHEMA MODIFICATIONS. Then the last case whereby you run version 1 and version 2 at the same time for some period.


11g performance tuning features

A reader, October 23, 2009 - 2:34 am UTC

Hi Tom

can you please list top 10 -20 new performance improvement featurs which are introduced in 11g.

I know only one - adoptive cursor sharing, which resolved the bind variable peeking issue and so in turn reduce the chances of a query suddenly start taking a bad path.which is great.

I have also read about "Database Smart Flash Cache"
and then Stored Outlines Migration to SQL Plan Management and some more as given in new featurs guide.

can you please list some more -specially with respect to code and server side .

Thanks

Tom Kyte
October 23, 2009 - 2:18 pm UTC

all of the diagnostic and tuning pack stuff has been updated and improved. There is not any 'top n' of them - my first choice might not be relevant to you and what you do at all.

here are a couple
http://docs.oracle.com/docs/cd/E11882_01/server.112/e10821/whatsnew.htm#i974246

performance tuning improvements

A reader, October 24, 2009 - 1:56 am UTC

Tom

thanks for the link, very useful it is.

thanks

RESULT_CACHE got just better

Guru, November 06, 2009 - 10:22 am UTC

With Oracle 11gR2, RELIES_ON clause is done away in RESULT_CACHE. From Release 11.2, result caches in Oracle RAC Environment are no longer private. Nice ones though.

An example of "Recursive Subquery Factoring"

Anton, November 12, 2009 - 10:11 am UTC

An example of something using "Recursive Subquery Factoring" which can't be done using "connect by":
http://technology.amis.nl/blog/6404/oracle-rdbms-11gr2-solving-a-sudoku-using-recursive-subquery-factoring
Tom Kyte
November 15, 2009 - 2:11 pm UTC

Anton,

I hope you don't mind, but I've been using that in my "top 11 things about 11g" since I saw it appear on Reddit.com a while back :)

I open up your website as an embedded link in my presentation.

It never fails to get a good chuckle, well done!

great, anton !

Sokrates, November 16, 2009 - 2:22 am UTC


Anton, November 16, 2009 - 9:10 am UTC

Of course I don't mind if you mention my blog.

A reader, December 10, 2009 - 8:45 am UTC

listagg dose not support distinct. if distinct set is required then we have to use stragg?
Tom Kyte
December 10, 2009 - 3:19 pm UTC

ops$tkyte%ORA11GR2> select deptno, listagg(job,';') within group (order by job) jobs
  2    from  scott.emp
  3   group by deptno
  4   order by deptno
  5  /

    DEPTNO JOBS
---------- ------------------------------
        10 CLERK;MANAGER;PRESIDENT
        20 ANALYST;ANALYST;CLERK;CLERK;MA
           NAGER

        30 CLERK;MANAGER;SALESMAN;SALESMA
           N;SALESMAN;SALESMAN


ops$tkyte%ORA11GR2> select deptno, listagg(job,';') within group (order by job) jobs
  2    from (select distinct deptno, job from scott.emp)
  3   group by deptno
  4   order by deptno
  5  /

    DEPTNO JOBS
---------- ------------------------------
        10 CLERK;MANAGER;PRESIDENT
        20 ANALYST;CLERK;MANAGER
        30 CLERK;MANAGER;SALESMAN



would do it as well in most cases.

Alexander the ok, December 10, 2009 - 1:28 pm UTC

Tom, about EBR, is this something intended to be built into application upgrades? As opposed to a DBA running the edition commands for a gazillion objects? I'm trying to get a feel for how this feature is intended to be used.
Tom Kyte
December 10, 2009 - 3:27 pm UTC

you wouldn't run a gazillion edition commands, you would edition a schema, create a new edition - and then if you simply alter your session - you are working in that new edition.

Say you want to patch - fix a broken procedure (or a dozen, whatever)

you would in general

a) edition the schema (one time command)
b) create an edition
c) grant use on that edition to the schema
d) log into schema and alter session
e) issue as many create or replaces as you need


that is for patching (no schema changes). That is something the DBA could do by themselves. For more advanced stuff, yes, the developers would be involved and would help to program the upgrade.

If you watch for the next three issues of Oracle Magazine - I'm doing EBR over the three issues - going from the simple to the more complex.

Top 10 reasons to upgrade to oracle 11g

Danny, January 06, 2010 - 12:18 am UTC

Tom:

We have oracle 11g upgrade goal planned this year.
we want to present to our application team to migrate their application/databases to 11g.

Could you list out top 10 reasons why upgrading current 9i/10g databases to 11g is better one ? we have 9i/10g OLTP and Dataware house databases.

I am looking for reasons from application development and DBA point of view. How much savings from DB storage point as well as performance improvement gains.
Tom Kyte
January 06, 2010 - 8:21 am UTC

asktom.oracle.com -> files tab

grab any of my 11gr2 updates if you want my top "11" things about 11g

Killer feature

Jischaj, January 20, 2010 - 9:53 am UTC

Hi Tom, I've readed your article in the Oracle Magazin and make some tests in our application.
I quite agree with you and was very happy to read this great news.
Now i found the killing object in my apllication, the public synonym.
I think i can't use the feature Edition Base Redefiniton, because every object in my application have a public synonym.
I am inconsolable about it.

Tom Kyte
January 20, 2010 - 11:45 am UTC

you should be, using public synonyms is a really bad practice. Always has been, always will be. They should be the rare rare exception and never the rule.

Recursive subquery factoring

MK, January 23, 2010 - 11:25 am UTC

Hi Tom,
I am trying to use the latest recursive subquery factoring for a problem where I have to traverse a table's records in such a fashion that it obeys the following rules

1. In table TF (trx-item), all trxs must contain the item_id = parent_item. Filtering out the rest. 
2. Then we retrieve the list of trx-item where each item > parent_item in the trx. 
3. We let through only the items that appear in more than 3 such trxs from list in 2. Those will be the CHILD items retrieved. The process is then repeated for each recursion depth first till there are no more children left.

Below is what I tried out, maybe you can help find a solution to this tricky one. 


SQL> select * from tf;
 
       TRX       ITEM
---------- ----------
         1          1
         1          3
         1          6
         1         13
         1         16
         2          1
         2          2
         2          3
         2          6
         2         13
         3          2
         3          6
         4          2
         4          3
         4         16
         5          1
         5          3
         5          6
         5         13
         5         16
 
20 rows selected


with projection(item,
treelevel,
path) as
 ( /* Anchor Block */
  select distinct tf.item, 1, to_char(tf.item)
    from tf
   where tf.item = 1
  union all
  /* Recursive Block */
  select v.item,
   px.treelevel + 1, px.path || '/' || to_char(px.item)
   from projection px,
   ( select distinct (CASE
         WHEN COUNT(t.trx) OVER(PARTITION BY t.item) >= 3 THEN
          t.item
       END) item
  from tf t
 where exists (select 'x'
          from tf x
         where x.trx = t.trx
           and x.item = px.item)
   and t.item > px.item
   ) v
 ) search depth first by item set seq
select item, treelevel, path, seq from projection;

ORA-00904: "PX"."ITEM": invalid identifier

I was looking at the documentation and my understanding is that I cannot use DISTINCT or GROUP BY in the recursive block, but I am allowed to use analytics. Is there a way then to simulate a group by - having clause using just analytical functions and then suppressing the duplicates in the end? 

Your help will be most appreciated. this is a university application where I am trying to prove that a recursive SQL in Oracle can do this job. 

Thanks,
MK
 

Tom Kyte
January 25, 2010 - 6:09 am UTC

...
1. In table TF (trx-item), all trxs must contain the item_id = parent_item.
Filtering out the rest.
....

huh? what does that mean. and unfortunately, your table hasn't any columns item_id nor parent_item

and further, there is no create, no inserts...

and I did not read past #1, not sure if the rest of the specification needs work or not, but I stopped at #1 since I had no idea what it mean.

recursive subquery factoring

MK, January 23, 2010 - 11:30 am UTC

To add to the previous post,
I am expecting a tree structure like

1
|- 3
| |- 6
| | |- 13
| |
| |- 13
|- 6
| |- 13
| |
|- 13
|

Is ACFS high on your 11.2 features list?

Stuart, January 25, 2010 - 5:21 pm UTC

How does ACFS rate in your list of 11.2 hot features?

I'm planning an upgrade of our 10.2.0.4 databases to 11.2 this year (they are non-RAC/ASM), and am installing 11.2 fresh on a new server with the intention of looking at moving to ASM.

Would you recommend I take the time to investigate ACFS, or is this more targeted at RAC sites?
Tom Kyte
January 29, 2010 - 8:41 am UTC

ACFS is mostly about RAC. It would give you an unbuffered cooked file system accessible from many nodes in a cluster. If you have one machine - not so much to it.

ASM on the other hand is very useful in single or multi-instance Oracle.

11g R2 on Windows

A reader, February 01, 2010 - 12:38 pm UTC

When can we expect 11g R2 on Windows ?
( In metalink , where can I see this information and certification matrix)
Tom Kyte
February 01, 2010 - 12:40 pm UTC

metalink doesn't show release dates into the future, just what is actually "here"

windows is expected very soon as of this writing.

EBR (Edition-based redefinition)

Carl Bruneau, February 20, 2010 - 7:05 pm UTC

Hello Tomas,

I read you first two columns about EBR in the Oracle Magazine. It clarifies many many things for us. Congratulation!

There is only one thing that I am not sure to understand in your example involving the modification on the EMPLOYEE table during and after the mass-move the existing data from the PHONE_NUMBER column to the PHONE# and COUNTRY_CODE columns:

Since the creation of the FORWARD CROSS-EDITION is not included in a transaction with the mass update, how can we be sure that the legacy system always deal correctly with the data in the table? Doesn't it leave a milli-second open door for a bad behavior?

Best regards,

Carl








Tom Kyte
March 01, 2010 - 5:25 am UTC

Three things to note:

a) the forward cross edition trigger is created before the mass update
b) the mass update will touch ALL rows that exist when the mass update is initiated
c) any rows that are added *after* the mass update begins (and might not be touched by the mass update) will be "migrated" by the forward cross edition trigger.


So, by putting in the forward cross edition trigger AND THEN updating every currently existing row - you ensure that all currently existing rows get sent through the forward cross edition trigger AT LEAST ONCE (and maybe more of course, the legacy application could still be touching them). And since the forward cross edition trigger is in place - all newly inserted data that is not touched by the mass update will go through the forward cross edition trigger AT LEAST ONCE as well.

11g R2 Database, Windows Availability

Mike Collins, February 24, 2010 - 3:46 pm UTC

There aren't any exact dates given but here is the doc I found on Oracle Support (MetaLink) for 11g R2 Database availability on Windows: 742060.1.

unlistagg

A reader, March 06, 2010 - 7:29 pm UTC

Listagg is nice. Sometimes I'd like to be able to do the reverse though. Do you have any comments about this implementation? Do you know of better ways to do this? Does this one have any major issues in your opinion? Will something like unlistagg ever be included as a built in function?


create or replace type split_type is table of varchar2 (4000);

create or replace function split_string (p_string in varchar2)
  return split_type
as
  l_data   split_type := split_type ();
  cursor c_list
  is
     select  trim (both ' ' from regexp_substr (str, '[^,]+', 1, level)) as single_element
           from (select p_string str from dual)
     connect by instr (str, ',', 1, level - 1) > 0;
begin
  for list_rec in c_list
  loop
     l_data.extend;
     l_data (l_data.count) := list_rec.single_element;
  end loop;
  return l_data;
end;

create table t (id number, value varchar2(255));
insert into t values (1,'one,two,three');
insert into t values (2,'four, five, six');
insert into t values (3,'seven,eight, nine ');
commit;

select * from t;

select t1.id, t2.column_value num
 from  (select id, split_string (value) v from t) t1 natural join
table (t1.v) t2;

drop table t purge;

Edition-based redefinition

Isaac Chocron, May 06, 2010 - 4:03 am UTC

Hello Tom,

Actually we are checking to use this new fascinating feature.
But we think that these good news are for simple standalone systems, that are not Oracle connected to others system on the same DB.

For example, on our DB there are 4 main system: (1)Patients manager, (2)Clinics, (3)Laboratories and a (4)little HR.
Every system own their private Schema, and also there is a 'global' schema that contain pl/sql objects, user-defined object types that are not dependent on any system, for example packages on Strings, Tokens, Clobs, AQ, etc. These packages service any system.
On this configuration, there are privates synonym between the 4 systems. For example systems 1 and 2 can see any to the other and on some features even can call pl/sql packages that perform updates, so there is dependencies between these system. Also there are public synonyms for objects that at the 'global' schema, so every system can use any pl/sql or user_defined object.
Using the new Edition-based redefinition even for only pl/sql objects is almost impossible or at least very very difficult.

All the examples that I see are good for simple scenarios.
Do you can to help us (some sample, links or something) to simplify on these scenarios?

Thanks
Tom Kyte
May 06, 2010 - 2:35 pm UTC

... Using the new Edition-based redefinition even for only pl/sql objects is almost
impossible or at least very very difficult.
....

why? I don't understand why you would say that.

Give a scenario.

Recursive Subquery Factoring

James Su, May 17, 2010 - 12:07 pm UTC

Tom, can you look at these queries on 11GR2, is there a bug?

WITH t(dt) AS (
SELECT TO_DATE('2010-1-1','YYYY-MM-DD') FROM DUAL
UNION ALL
SELECT dt+1
FROM t
WHERE dt <TO_DATE('2010-1-10','YYYY-MM-DD')
)
SELECT * FROM T;

SELECT dt+1
*
ERROR at line 4:
ORA-01790: expression must have same datatype as corresponding expression



WITH t(n,dt) AS (
SELECT 1,'2010-1-1' FROM DUAL
UNION ALL
SELECT n+1,TO_CHAR(TO_DATE(t.dt,'YYYY-MM-DD')+1,'YYYY-MM-DD') ---- supposed to b next day
FROM t
WHERE n<10
)
SELECT * FROM T;

surprisingly, the date in the result set is decreasing:

N DT
---------- ----------
1 2010-1-1
2 2009-12-31
3 2009-12-30
4 2009-12-29
5 2009-12-28
6 2009-12-27
7 2009-12-26
8 2009-12-25
9 2009-12-24
10 2009-12-23

10 rows selected.

In the document it says:

The recursive member cannot contain any of the following elements:

The DISTINCT keyword or a GROUP BY clause
The model_clause
An aggregate function. However, analytic functions are permitted in the select list.
..........

When I tried to use analytic functions:

WITH t(n) AS (
SELECT 1 FROM DUAL
UNION ALL
SELECT MAX(1+t.n) OVER()
FROM t
WHERE n<10
)
SELECT *
FROM T;

FROM T
*
ERROR at line 9:
ORA-32486: unsupported operation in recursive branch of recursive WITH clause

Can you give an example using analytic functions in the recursive member?

Thank you.
Tom Kyte
May 24, 2010 - 8:51 am UTC

yeah, that is wrong - I'll bug that.


as for the last bit about the ora-32486 - it says:
ops$tkyte%ORA11GR2> !oerr ora 32486
32486, 00000, "unsupported operation in recursive branch of recursive WITH clause "
// *Cause: The recursive component of the UNION ALL in a recursive WITH clause
//         element used an operation that was currently not supported.  The
//         following should not be used in the recursive branch of the 
//         UNION ALL operation: GROUP BY, DISTINCT, MODEL, grouping sets,
//         CONNECT BY, <b>window functions</b>, HAVING, aggregate functions.
// *Action: Rewrite the query without the unsupported operation.



you have a window function

Subprogram Inlining

V.Hariharaputhran, June 27, 2010 - 1:19 pm UTC

Mr.Oracle

I just tried Subprogram In lining Feature in Oracle 11g, As oracle states the performance results are marginal, can you please let us know what would be the exact place one should use PRAGMA INLINE to get the maximum benefits,

Sample test case below with no SQL's

SQL>
SQL> alter session set plsql_optimize_level = 3;

Session altered.

Elapsed: 00:00:00.00
SQL>
SQL> create or replace FUNCTION FN_ADD_NOCACHE (
2 v1 IN PLS_INTEGER,
3 v2 IN PLS_INTEGER
4 ) RETURN PLS_INTEGER IS
5
6 BEGIN
7 RETURN v1+v2;
8 END FN_ADD_NOCACHE;
9 /

Function created.

Elapsed: 00:00:00.03
SQL>
SQL> DECLARE
2 v_Return pls_integer:=0;
3 BEGIN
4 For x in 1..1000000 loop
5 PRAGMA INLINE(FN_ADD_NOCACHE,'NO');
6 v_Return := v_Return + FN_ADD_NOCACHE(1,1);
7 End Loop;
8 DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
9 END;
10 /
v_Return = 2000000

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.29
SQL>
SQL> DECLARE
2 v_Return pls_integer:=0;
3 BEGIN
4 For x in 1..1000000 loop
5 PRAGMA INLINE(FN_ADD_NOCACHE,'YES');
6 v_Return := v_Return + FN_ADD_NOCACHE(1,1);
7 End Loop;
8 DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
9 END;
10 /
v_Return = 2000000

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.28

-- Tried Again ---
SQL>
SQL> DECLARE
2 v_Return pls_integer:=0;
3 BEGIN
4 For x in 1..1000000 loop
5 PRAGMA INLINE(FN_ADD_NOCACHE,'NO');
6 v_Return := v_Return + FN_ADD_NOCACHE(1,1);
7 End Loop;
8 DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
9 END;
10 /
v_Return = 2000000

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.28
SQL>
SQL> DECLARE
2 v_Return pls_integer:=0;
3 BEGIN
4 For x in 1..1000000 loop
5 PRAGMA INLINE(FN_ADD_NOCACHE,'YES');
6 v_Return := v_Return + FN_ADD_NOCACHE(1,1);
7 End Loop;
8 DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
9 END;
10 /
v_Return = 2000000

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.28
SQL>
SQL> spool off

Thanks for your time.

Regards
V.Hari
Tom Kyte
July 06, 2010 - 11:14 am UTC

... can you please let us know what would be the exact place one should use PRAGMA INLINE to get the maximum benefits, ...

with small routines that are frequently called. You may - or may not - see a difference. It would depend entirely on the cost of calling the procedure/function.


when you set to level 3, we automagically do it for you. You don't need to inline.


11g R2, OR clause issue??

Jay, July 08, 2010 - 10:32 am UTC

Hi Tom,
I am having an issue with a query when executed in 11g, R2 release.

Oracle 11g seems to be interpreting the codes below differently. Sample test case below.

SQL> select * from v$version
  2  /

BANNER                                                                          
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production    
PL/SQL Release 11.2.0.1.0 - Production                                          
CORE 11.2.0.1.0 Production                                                      
TNS for Solaris: Version 11.2.0.1.0 - Production                                
NLSRTL Version 11.2.0.1.0 - Production                                          

5 rows selected.

SQL> --Create Table
SQL> create table t (a number, d date)
  2  /

Table created.

SQL> --Insert records
SQL> insert into t values (1,to_date('06-jul-2010 00:00:00','dd-mon-yyyy hh24:mi:ss'));

1 row created.

SQL> insert into t values (50,to_date('05-jul-2010 00:00:00','dd-mon-yyyy hh24:mi:ss'));

1 row created.

SQL> insert into t values (100,to_date('04-jul-2010 00:00:00','dd-mon-yyyy hh24:mi:ss'));

1 row created.

SQL> --Select records
SQL> select *
  2    from t
  3  /

         A D                                                                    
---------- ---------                                                            
         1 06-JUL-10                                                            
        50 05-JUL-10                                                            
       100 04-JUL-10                                                            

3 rows selected.

SQL> --Test 1 (correct result)
SQL> select a
  2    from t
  3   where (d < to_date('04-jul-2010','dd-mon-yyyy') or d > sysdate)
  4   /

no rows selected

SQL> --Test 2 (Incorrect result)
SQL> select a
  2    from t
  3   where (d > sysdate or ( d < to_date('04-jul-2010','dd-mon-yyyy')))
  4  /

         A                                                                      
----------                                                                      
         1                                                                      
        50                                                                      
       100                                                                      

3 rows selected.

SQL> spool off


The only difference between the two queries above is in the OR clause statement where the order of comparison is switched.

Is this a bug? Please advise when you get a chance.

Thanks for your help!

Jay
Tom Kyte
July 08, 2010 - 2:07 pm UTC

I just filed bug 9889611

updated: found base bug 9495697, patches are already there - please contact support.

Jay, July 08, 2010 - 1:38 pm UTC

Thanks Tom!

No patch yet..

Jay, July 08, 2010 - 2:56 pm UTC

Tom,
It looks like they are still working on bug# 9495697. I don't believe they have released a patch for this one yet. Just wanted to let you know...
Thanks for your time!
Jay
Tom Kyte
July 08, 2010 - 4:21 pm UTC

no, i see them - you might not be able to see that text in the bug. Please open a service request, reference that bug and say you've hit it.

Big Patchset obsolete in 11GR2?

Sean, July 13, 2010 - 2:36 pm UTC

I have been googling everywhere about the new features on 11GR2 patchset manangement AND searched extensively on metalink.oracle.com but can NOT confirm this NEW feature(you can say new de-supported feature) rumor: 11G R2 only supports small PSU ( patchset update, by opatch) but not the big way : a big patchset like 1.5G for 10.2.0.5(by Universal Install). I.e, in metalink, I can see 11.2.0.2 but can't find a PATCHSET for that release, though I can find 100s of patchs. we don't want to install so muny small patches all the time, we only want to install a big patchset and stay on for 2 years or so without reboot the database... Please comment of this 11G R2 upgrade feature. Thank you
Tom Kyte
July 19, 2010 - 12:50 pm UTC

there is no 11.2.0.2 as of this date - it hasn't been released yet.


what "new de-supported" feature are you referring to?

NTH_VALUE FROM FIRST, LAST ANALYTIC FUNCTION

defender, September 28, 2010 - 7:29 am UTC

Hi, Mr. Tom,
How can I build nth_value() from first /*last*/ 11gR2 analytical function, in 10g.
Best Regards,

Tom Kyte
September 28, 2010 - 9:17 am UTC

trick question, I would not use first/last, I would use row-number and max

ops$tkyte%ORA11GR2> select deptno,
  2         ename,
  3         sal,
  4         nth_value(sal,2) over (partition by deptno order by sal range between unbounded preceding and unbounded following) second
  5    from scott.emp
  6   order by deptno, sal
  7  /

    DEPTNO ENAME             SAL     SECOND
---------- ---------- ---------- ----------
        10 MILLER           1300       2450
        10 CLARK            2450       2450
        10 KING             5000       2450
        20 SMITH             800       1100
        20 ADAMS            1100       1100
        20 JONES            2975       1100
        20 SCOTT            3000       1100
        20 FORD             3000       1100
        30 JAMES             950       1250
        30 WARD             1250       1250
        30 MARTIN           1250       1250
        30 TURNER           1500       1250
        30 ALLEN            1600       1250
        30 BLAKE            2850       1250

14 rows selected.

ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> select deptno,
  2         ename,
  3         sal,
  4         max(temp) over (partition by deptno) second
  5    from (
  6  select deptno,
  7         ename,
  8         sal,
  9         decode( row_number() over (partition by deptno order by sal), 2, sal) temp
 10    from scott.emp
 11         )
 12   order by deptno, sal
 13  /

    DEPTNO ENAME             SAL     SECOND
---------- ---------- ---------- ----------
        10 MILLER           1300       2450
        10 CLARK            2450       2450
        10 KING             5000       2450
        20 SMITH             800       1100
        20 ADAMS            1100       1100
        20 JONES            2975       1100
        20 SCOTT            3000       1100
        20 FORD             3000       1100
        30 JAMES             950       1250
        30 WARD             1250       1250
        30 MARTIN           1250       1250
        30 TURNER           1500       1250
        30 ALLEN            1600       1250
        30 BLAKE            2850       1250

14 rows selected.

ops$tkyte%ORA11GR2> 


Oracle upgrade and edition-based redefinition

cmark, October 04, 2010 - 5:41 am UTC

With respect to Edition-based redefinition, is this feature more suitable to using for an application upgrade versus an Oracle patch or version upgrade? I am thinking that since public synonyms are likely used in almost any Oracle patch or version it would not work for those cases.
Tom Kyte
October 04, 2010 - 5:44 am UTC

what do public synonyms have to do with anything?


It is for application upgrades only - not database updates - online database updates would be handled via a rolling upgrade with data guard.

Column position with LONG datatype

Rajeshwaran Jeyabal, November 29, 2010 - 6:54 am UTC

Tom:

Quote from Oracle product documentation.

if a table has a column of type LONG, then Oracle Database always stores this column last in the row.

http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/tablecls.htm#i20438


rajesh@11GR2> create table t(
  2  x number,
  3  y long,
  4  z date);

Table created.

Elapsed: 00:00:01.95
rajesh@11GR2> ed;
Wrote file afiedt.buf

  1  select table_name,column_name,data_type,column_id
  2  from user_tab_columns
  3* where table_name ='T'
rajesh@11GR2> /

TABLE_NAME COLUMN_NAM DATA_TYPE             COLUMN_ID
---------- ---------- -------------------- ----------
T          X          NUMBER                        1
T          Y          LONG                          2
T          Z          DATE                          3

Elapsed: 00:00:00.01
rajesh@11GR2>
rajesh@11GR2> select * from t;

no rows selected

Elapsed: 00:00:00.04
rajesh@11GR2>
rajesh@11GR2> desc t;
 Name                                                                    Null?    Type
 ----------------------------------------------------------------------- -------- ------------------
 X                                                                                NUMBER
 Y                                                                                LONG
 Z                                                                                DATE

rajesh@11GR2>
rajesh@11GR2> select dbms_metadata.get_ddl('TABLE','T') from dual;

DBMS_METADATA.GET_DDL('TABLE','T')
--------------------------------------------------------------------

  CREATE TABLE "RAJESH"."T"
   (    "X" NUMBER,
        "Y" LONG,
        "Z" DATE
   ) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  TABLESPACE "USERS"


As per the statment from Documentation the column with LONG datatype should be in Third position and not at second position. Is that a bug with documentation, Tom ?
Tom Kyte
November 29, 2010 - 10:42 am UTC

they were talking "physically", if you dumped the block you would see it is "last" in the block.

logically - we can put it anywhere we like. Physically - it is "last"

Column position with LONG datatype

Rajeshwaran Jeyabal, November 30, 2010 - 2:34 am UTC

rajesh@11GR2> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

Elapsed: 00:00:00.15
rajesh@11GR2>
rajesh@11GR2> create table t(
  2     c1 char(2000),
  3     c2 long,
  4     c3 varchar2(4000),
  5     c4 date
  6  );

Table created.

Elapsed: 00:00:00.29
rajesh@11GR2>
rajesh@11GR2> insert into t values('*','*',lpad('*',4000,'*'),sysdate);

1 row created.

Elapsed: 00:00:00.26
rajesh@11GR2> commit;

Commit complete.

Elapsed: 00:00:00.00
rajesh@11GR2>
rajesh@11GR2> exec dbms_stats.gather_table_stats(user,'T');

PL/SQL procedure successfully completed.

Elapsed: 00:00:10.73
rajesh@11GR2> select blocks, empty_blocks
  2  from user_tables
  3  where table_name ='T'
  4  /

    BLOCKS EMPTY_BLOCKS
---------- ------------
         5            0

Elapsed: 00:00:00.04
rajesh@11GR2>
rajesh@11GR2> exec show_space(user,'T','TABLE');
l_total_blocks****************  8
l_total_bytes*****************  65536
l_unused_blocks***************  0
l_unused_bytes****************  0
l_last_used_extent_file_id****  4
l_last_used_extent_block_id***  528
l_last_used_block*************  8
l_unformatted_blocks**********  0
l_unformatted_bytes***********  0
l_fs1_blocks******************  0
l_fs1_bytes*******************  0
l_fs2_blocks******************  1
l_fs2_bytes*******************  8192
l_fs3_blocks******************  0
l_fs3_bytes*******************  0
l_fs4_blocks******************  4
l_fs4_bytes*******************  32768
l_full_blocks*****************  0
l_full_bytes******************  0

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.68
rajesh@11GR2> declare
  2    l_rowid rowid;
  3    l_rowid_type    NUMBER;
  4    l_object_number NUMBER;
  5    l_relative_fno  NUMBER;
  6    l_block_number  NUMBER;
  7    l_row_number    NUMBER;
  8  begin
  9    select rowid
 10    into l_rowid
 11    from t;
 12    dbms_rowid.rowid_info(l_rowid,l_rowid_type,l_object_number,l_relative_fno,l_block_number,l_row_number);
 13
 14    dbms_output.put_line (' l_rowid_type = '||l_rowid_type);
 15    dbms_output.put_line (' l_object_number = '||l_object_number);
 16    dbms_output.put_line (' l_relative_fno = '||l_relative_fno);
 17    dbms_output.put_line (' l_block_number = '||l_block_number);
 18    dbms_output.put_line (' l_row_number = '||l_row_number);
 19  end;
 20  /
 l_rowid_type = 1
 l_object_number = 76359
 l_relative_fno = 4
 l_block_number = 534
 l_row_number = 0

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.07
rajesh@11GR2>
rajesh@11GR2>


Tom:

Now totally 5 blocks ( 4 blocks in fs4 and 1 blocks in fs2) is actually used to save Table 'T' data. But how do i know in which block the column c1 is available? Do we have any methods available for this in dbms_rowid package?

http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16760/d_rowid.htm#i1003692
Tom Kyte
November 30, 2010 - 2:49 am UTC

you would have to dump the block as stated above, nothing documented on that - and if you ask me - a waste of time to pursue - it is nothing you need to do.


you can google around if you like to see how to dump a block, it is not something I do myself.

type of compression in oracle

Amir Riaz, November 30, 2010 - 8:04 am UTC

Hi Tom,

Oracle 11g r2 and Oracle exadata has 3 type of compression.

1. basic compression ( create table name compress as select * from emp)
used for data warehouses and a row based compression.
2. oracle advance compression
used for OLTP system and a row based compression
3. Oracle columnar compression
only available with oracle exadata and has two types query and archive.

Lets say, I am working in warehouse environments, then my choices can be #1 and #3. I use #3 in some tables and can i use #1 in others? I know, it looks odd and but i am testing the effect of performance loose by mistake and trying to convey the message to our clients that best choice is columnar compression.

confirm me that #2 is row based compression and what changes has been done in it to make it OLTP enabled.
Tom Kyte
November 30, 2010 - 11:58 am UTC

Actually, in a warehousing environment I would say 1, 2 and 3 are all possibilities.

Many data warehouses use tools like Informatica- infamous for its slow by slow loading techniques - which would only be able to use #2 for compression.

Or they trickle feed a continuous stream, again #2 would apply.


You can use 1, 2 and 3 simultaneously - even on the same table if you want - having really old partitions archive compressed, having old partitions query compressed, having relatively new partitions basic compressed and the newest - most current stuff 'OLTP' compress.


Columnar compressed will consume the most amount of CPU horsepower of the three during the direct path operation - it, like basic, only works with direct path operations. You'll get the very best compression - but lose all ability to ever effectively perform single row modifications again to that data (without uncompressing it).


OLTP advanced compression is very similar in nature to the basic compression as far as "technique" goes. Neither are "row compression", both 1 and 2 are block level compression (fill block up, look for redundancies, factor them out, make more room on block and fill it up again).


data warehouse

Amir Riaz, December 03, 2010 - 7:28 am UTC

Hi,

Our oracle Exadata v1 project went on line last week and

"it does not contain any bitmap index".

I have been saying this since i joined this project. We may not need indexes with Oracle Exadata but most people found it hard to believe. In fact, most top oracle taken my claim as a humiliation but i stuck with my theory and we have tested the warehouse with more the 80TB of uncompressed data (10 years data from 2000 to 2010 in telecommunication domain). Our ETL time is 6hour (8 hours window) and report response time is little above one minute. Although, we dont need that much data but we want to make sure that we get performance till to full capacity and my analysis is if we manage to compress that data 10 times with oracle columnar compression we may not need to remove that data from the system.

i will be leaving this project after compression activity and prideful that I did which top professionals we were not able to do.

Tom, I am planning to write some papers on

"Why we dont indexes with Oracle Exadata"

and want that oracle publish it if they find it right. that way i will get resignation of my work and may my career shine after that. Can you tell me what to do to write something on Oracle and how to get your work published as other people do.


Tom Kyte
December 07, 2010 - 9:18 am UTC

In the year 2010 - anyone can publish anytime they want (just start a blog and start writing).

You can submit it to your local user groups - they many times print journals for their members.

You can turn it into a presentation and submit it to conferences, they almost always take white papers and the presentations and 'publish' them as well.


informatic for DWH

Amir Riaz, December 03, 2010 - 10:16 am UTC

Also, I would like to add, if you are using ETL tools like Informatica power center,its very little chance that you will get any performance with oracle or any huge database. Reason is, the difference between ETL and ELT. ELT is the oracle invented data warehousing technique in which ELT tool can reside on database server. ELT loads extracted data directly into table and than perform transformation. while in ETL extracted data is being carried to another server(ETL server) and loaded into some sort of file, processed at ETL server in file and then loaded into database. Here, due to network traffic and row by row processing between database server and ETL server, you will not get good performance. That is why above Tom says, advance compression can help with Informatica but why should one use it, if Oracle warehouse Builder is available and its free.
Tom Kyte
December 07, 2010 - 9:23 am UTC

extract - then transform outside the database - then load = ETL

extract from source and bulk load into target, then transform using set based sql = ELT

this is key - if you are going to use exadata and you think you are going to do ETL - you will be disappointed.

You need to do ELT.

about EBR - can not activate editions without downtime

sperlea, January 19, 2011 - 3:15 pm UTC

Hi Tom
I wanted to use EBR hoping that changing a package from dozens could be done online without downtime and a new reconnect for the existing sessions.
You said:
"
Say you want to patch - fix a broken procedure (or a dozen, whatever)
you would in general

a) edition the schema (one time command)
b) create an edition
c) grant use on that edition to the schema
d) log into schema and alter session
e) issue as many create or replaces as you need "

Yes i wanted to fix a procedure from dozens... I do this but the only problem is that i can not activate the new edition online for the sessions which are already connected. "alter session..."is for the future session and not for the actual sessions. To do the change i need to do a downtime for many applications servsers. I have done this also previously to change a procedure. editions doesn't do the job for me. i am wright here? or maybe is possible to this online for the existing sessions?
thank you very much
best regards
adrian sperlea

Tom Kyte
January 24, 2011 - 5:52 am UTC

Edition Based Redefinition is a tool to reduce OR eliminate downtime.

If you want 100% uptime, you have to do what is known as a hot rollover - meaning for some period of time version 1 will be running AND version 2 will be running - simultaneously. You cannot (it is not reasonable to even expect) take an existing session and WITHOUT IT'S KNOWLEDGE - change the rules of the game, change the version of code that session is running.


Otherwise you are using EBR to minimize downtime to the smallest possible bit of time possible - that bit of time is the time it takes to restart your application servers.

In this latter case - you are removing all of the time it takes to perform (e) above - which could be many minutes, hours or even days in extreme cases.


Some tools, like APEX - http://apex.oracle.com/ - are 'edition aware' and can be used to "immediately make a new version available to all" as it will do the switching to an edition based on configuration information it reads before generating pages. But - beware - you have to think really long and really hard before doing this. Can you have your application run version 1 code for pages 1,2,3 - and then version 2 code for pages 5,6 in your application. Does it make sense? Would it work? Is it what you really want?

Alex, February 16, 2011 - 12:27 pm UTC

Did you know you can query a table that has the alert log info in it now? Pretty cool, I just stumbled upon this:

http://blog.tanelpoder.com/2009/03/21/oracle-11g-reading-alert-log-via-sql/

Recursive Subquery Factoring

Martin Schlafer, March 29, 2011 - 8:12 pm UTC

Tom,

I experienced the same date issues with recursive subquery factoring as James Su and I further isolated the trouble.

The first problem appears that Oracle cannot determine the datatype. I overcame this by casting in the anchor block.

The second problem appears in the recursive block when the left operand of the date addition operator is the recursive date column. The addition operator oddly behaves as subtraction, but only when the left operand is the recursive column. Other date expressions as the left operand work fine. I overcame this two ways. One is to perform date subtraction on a negative integer. The other was to "wrap" the recursive column in a scalar query of dual.

SELECT * FROM v$version;

WITH
  cal (iter,a_date,b_date,c_date,d_date,e_date) AS
  (
    SELECT
      1                     AS iter,
      CAST(sysdate AS DATE) AS a_date,
      CAST(sysdate AS DATE) AS b_date,
      CAST(sysdate AS DATE) AS c_date,
      CAST(sysdate AS DATE) AS d_date,
      CAST(sysdate AS DATE) AS e_date
    FROM dual
    UNION ALL
    SELECT
      iter   + 1  AS iter,
      a_date + 1  AS a_date,   --bug
      b_date - 1  AS b_date,
      c_date + -1 AS c_date,   --bug
      d_date - -1 AS d_date,
      (SELECT e_date FROM dual)
      + 1 AS e_date
    FROM cal
    WHERE iter < 5
  )
SELECT * FROM cal;


BANNER                                                                           
-------------------------------------------------------------------------------- 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production     
PL/SQL Release 11.2.0.1.0 - Production                                           
CORE 11.2.0.1.0 Production                                               
TNS for Linux: Version 11.2.0.1.0 - Production                                   
NLSRTL Version 11.2.0.1.0 - Production                                           

ITER   A_DATE      B_DATE      C_DATE      D_DATE      E_DATE     
------ ----------- ----------- ----------- ----------- -----------
1      29-MAR-11   29-MAR-11   29-MAR-11   29-MAR-11   29-MAR-11  
2      28-MAR-11   28-MAR-11   30-MAR-11   30-MAR-11   30-MAR-11  
3      27-MAR-11   27-MAR-11   31-MAR-11   31-MAR-11   31-MAR-11  
4      26-MAR-11   26-MAR-11   01-APR-11   01-APR-11   01-APR-11  
5      25-MAR-11   25-MAR-11   02-APR-11   02-APR-11   02-APR-11  





- Marty

11g new features on RAC

A reader, September 15, 2011 - 8:27 am UTC

Dear Tom,

I would like to seek an advise from you. I am a core DBA with around 4years of experience in the field and has been working fluently in 10g version. I am planning to go for a RAC training and I'm confused for which version should I go.
Therefore can you please make me undestand about the new features 11g has got in terms of RAC is concerned? Also, do you suggest 11g RAC will be hard to understand without working in database of 11g version? I am eagerly waiting for your response and thanks for having your time for this.
Tom Kyte
September 15, 2011 - 12:03 pm UTC

you'll find most of the new features here:

http://docs.oracle.com/docs/cd/E11882_01/server.112/e17128/toc.htm


You'll want to learn 11g as well as RAC at the same time - there is a lot added in 11g in general.

11g would be where I would start personally. Especially if you have 11g where you are going to be working..

Alexander, September 15, 2011 - 12:09 pm UTC

I agree with Tom. I feel like there's enough added/changed with 11g RAC that I dont even know it anyone. All the directories for files that are different, the whole "grid infrastructure" thing, SCAN listeners...

Editon based Redefinition

Lal Cyril, September 23, 2011 - 4:04 am UTC

Hi Tom,

I am trying out EBR feature for one of our products which uses a three schema approach for database deployment.
All tables, views are created in tables schema (TESTTBLS),
all procedures and synonyms of tables (in TESTTBLS) created in procedure schema(TESTPROCS) and
synonyms of procedures(in TESTPROCS) and synonyms of synonyms of tables(in TESTPROCS) created in user schema (TESTUSER)

The application server connects to TESTUSER which has the synonymns of procedures and tables and have the grants
to execute procedure and DMLs on tables.

Test Case
---------
I have the following table in TESTTBLS which has a BLOB column

conn TESTTBLS/TESTTBLS@XE
CREATE TABLE test_blob (
id NUMBER(15)
, image_name VARCHAR2(1000)
, image BLOB
, timestamp DATE
);

GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO TESTPROCS,TESTUSER;

CONN TESTPROCS/TESTPROCS@XE
CREATE SYNONYM test_blob FOR TESTTBLS.test_blob;

CONN TESTUSER/TESTUSER@XE
CREATE SYNONYM test_blob FOR TESTPROCS.test_blob;

The application server connecting TESTUSER is able to insert records to blob table.

Now for enabling EBR i did the following steps as per Oracle documentation.

conn TESTTBLS/TESTTBLS@XE
REVOKE INSERT,UPDATE,DELETE,SELECT ON test_blob FROM TESTPROCS,TESTUSER;
RENAME test_blob TO test_blob_1;
CREATE OR REPLACE EDITIONING VIEW test_blob AS SELECT * FROM test_blob_1;
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO TESTPROCS,TESTUSER;

now i am able to select and insert data (with empty_blob())into this editioning view using sql developer from TESTPROCS and TESTUSER
schema.

But the application server throws the following error.

Caught SQL Exception: (Write BLOB value - Put Method).
SQL:
SELECT image FROM test_blob WHERE id = 1 FOR UPDATE
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4C8TTILob.processError(T4C8TTILob.java:789)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8TTILob.write(T4C8TTILob.java:178)
at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2412)
at oracle.sql.BLOB.setBytes(BLOB.java:881)
at oracle.sql.BLOB.putBytes(BLOB.java:382)
at BLOBFileExample.writeBLOBPut(BLOBFileExample.java:274)
at BLOBFileExample.main(BLOBFileExample.java:617)
Caught SQL Exception. Exiting.
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4C8TTILob.processError(T4C8TTILob.java:789)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8TTILob.write(T4C8TTILob.java:178)
at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2412)
at oracle.sql.BLOB.setBytes(BLOB.java:881)
at oracle.sql.BLOB.putBytes(BLOB.java:382)
at BLOBFileExample.writeBLOBPut(BLOBFileExample.java:274)
at BLOBFileExample.main(BLOBFileExample.java:617)

the insert (with empty_blob()) and select worked on the editioning view from application server also,
but the writing of blob failed.

When i grant the privileges on the base table this error doesnot occur.
conn TESTTBLS/TESTTBLS@XE
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob_1 TO TESTPROCS,TESTUSER;

I tried the same with a normal view instead of editioning view and the error is not thrown.

Is it a bug? If not can you explain why the grant is required for the base table.
Is there any issue if i grant the privilege on the base table and then use editoning view.

I used the sample code from http://www.idevelopment.info for trying this(Oracle->DBA Tips->Load Binary Files to BLOB then Write Back Out to Disk - (Java))

Thanks in advance for your precious time.

Tom Kyte
September 23, 2011 - 9:39 am UTC

sql developer is written in java using jdbc - just like your code.

can you post the SMALLEST HUMANLY POSSIBLE bit of java code to reproduce (100% complete java code - something runable - but something teeny tiny - JUST enough code to demonstrate the issue - no error handling or anything, just as few lines of code as possible)

Edition based redefinition

lal cyril, September 27, 2011 - 4:03 am UTC

Tom,

Only the insert with empty_blob() worked with sql developer. I mentioned that just to show that the access to the procedure schema is correct.

Please find the simple java code to try the BLOB issue with EBR. This program loads an image to blob table.

Java Code
---------
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.sql.*;
import oracle.jdbc.*;

public class TestBlobWrite
{
//java TestBlobWrite jdbc:oracle:thin:@192.168.2.53:1521:panorama IRESEBRTBLS IRESEBRTBLS D:\Apr11.jpeg
public static void main(String args[]) {

Connection conn = null;
PreparedStatement stmt1 = null;
PreparedStatement stmt2 = null;
OutputStream os =null;
ResultSet rset = null;
try {
if(args.length != 4) {
System.out.println("\nCheck Arguments!! \n\nUsage:java TestBlobWrite <jdbc:oracle:thin:@IP:PORT:SID> <username> <password> <file-path>");
System.exit(1);
}
Class.forName ("oracle.jdbc.driver.OracleDriver").newInstance();
conn = DriverManager.getConnection(args[0], args[1], args[2]);
conn.setAutoCommit(false);
System.out.println("Got Connection ..");
File inputBinaryFile = new File(args[3]);
stmt1 = conn.prepareStatement("INSERT INTO test_blob (id, image_name, image, timestamp) VALUES(2, '" + inputBinaryFile.getName() + "', EMPTY_BLOB(), SYSDATE)");
stmt1.executeUpdate();
stmt2 = conn.prepareStatement("SELECT image FROM test_blob WHERE id = 2 FOR UPDATE");
rset = stmt2.executeQuery();
rset.next();
Blob image = (rset).getBlob("image");
os = image.setBinaryStream(1);
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bytesOut);
out.writeObject(inputBinaryFile);
out.flush();
out.close();
bytesOut.close();
byte[] bytes = bytesOut.toByteArray();
os.write(bytes);
os.flush();
conn.commit();
System.out.println("Insert Committed...");

os.close();
rset.close();
stmt1.close();
stmt2.close();
conn.close();
System.out.println("Disconnected...");

} catch(Exception e) {
e.printStackTrace();
if (conn != null) {
try {
conn.rollback();
System.out.println("Exception and Insert Rolled back...");
} catch(Exception ex){}
}
}

}
}

To compile
----------
set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;
javac TestBlobWrite.java

To run
-------
create two schemas EBRTBLS and EBRPROCS
conn sys/manager123@orcl as sysdba
create user EBRTBLS identified by EBRTBLS;
grant connect,resource to EBRTBLS;

create user EBRPROCS identified by EBRPROCS;
grant connect,resource to EBRPROCS;

CONN EBRTBLS/BRTBLS@ORCL
CREATE TABLE test_blob (
id NUMBER(15)
, image_name VARCHAR2(1000)
, image BLOB
, timestamp DATE
);

GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRPROCS;

CONN EBRPROCS/EBRPROCS@ORCL
CREATE SYNONYM test_blob FOR EBRTBLS.test_blob;

Run the java program (replace the connection details, schema details and the path of the file name D:\20110206_024.jpg)
--------------------
set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;

java TestBlobWrite jdbc:oracle:thin:@localhost:1521:ORCL EBRPROCS EBRPROCS D:\20110206_024.jpg

This works connecting to EBRPROCS schema which refers the synonym of blob table.

Now execute the following to create editions on blob table

CONN EBRTBLS/BRTBLS@ORCL
REVOKE INSERT,UPDATE,DELETE,SELECT ON test_blob FROM EBRPROCS;
RENAME test_blob TO test_blob_1;
CREATE OR REPLACE EDITIONING VIEW test_blob AS SELECT * FROM test_blob_1;
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRPROCS;

Run the same java program (replace the connection details, schema details and the path of the file name D:\20110206_024.jpg)
---------------------------
set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;

java TestBlobWrite jdbc:oracle:thin:@localhost:1521:ORCL EBRPROCS EBRPROCS D:\20110206_024.jpg

The following exeption is thrown
---------------------------------
Got Connection ..
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3
576)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:365
7)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWr
apper.java:1062)
at TestBlobWrite.main(TestBlobWrite.java:28)
Exception and Insert Rolled back...

If the grant on base table is given this works
CONN EBRTBLS/BRTBLS@ORCL
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob_1 TO EBRPROCS;
Run the same java program (replace the connection details, schema details and the path of the file name D:\20110206_024.jpg)
---------------------------
set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;

java TestBlobWrite jdbc:oracle:thin:@localhost:1521:ORCL EBRPROCS EBRPROCS D:\20110206_024.jpg

Tom Kyte
September 27, 2011 - 8:31 am UTC

I don't have the complete test case here - no table - and I'm pretty darn sure the code is 3 or 4 times larger than it needs be to reproduce the issue.

Entire example please.

From soup to nuts.

for example, it would look like this:

here is my create table ....

here is my very very very short java program that does JUST ENOUGH TO GET THE ERROR (eg: anything after like 28 of your code is most likely NOT RELEVANT)...

Here is me running it:

SQL> create table ....
SQL> alter user ... enable editions;
SQL> whatever else you need to do...
SQL> host java TestBlobWrite .....



you know, sort of like I do? Make a 100% complete, yet concise as all get out test case and demonstrate exactly how to run it from start to a complete finish.

Edition Based redefinition

Lal Cyril, September 27, 2011 - 10:35 pm UTC

Tom,
I have put the complete test case in very short code as far as possible.
First i pasted the java code and then mentioned how to compile and then under heading (To run) i have given the complete steps including schema creation, table creation.
Can you pls go through it once again. May be the order in which i put the data is confusing.
Only thing you need extra is a sample jpg file to load into the blob table.
Tom Kyte
September 28, 2011 - 5:37 am UTC

the java code is too long, you know it fails on whatever line 28 is. I don't see the table.

I want it short, I want is complete, I want it in a single posting. I do not want to have to page up and down and all around trying to assemble it.

Your code can be much much shorter.
And it must be complete.
And it must be in a single place.

Make it easy for me - I get lots of these and taking 10 or 15 minutes trying to assemble them each would eat my day up entirely.

Edition based redeinition and blob

lal cyril, September 29, 2011 - 6:50 am UTC

Tom,

Please find the steps to execute the test case.
--Login as sys user and create two schemas EBRTBLS and EBRAPP

sqlplus sys@XE as sysdba
create user EBRTBLS identified by EBRTBLS ENABLE EDITIONS;
grant connect,resource,CREATE VIEW to EBRTBLS;

create user EBRAPP identified by EBRAPP ENABLE EDITIONS;
grant connect,resource,create synonym to EBRAPP;


--Login to tables schema and create the blob table which will be used by java code
CONN EBRTBLS/EBRTBLS@XE
CREATE TABLE test_blob (
 id               NUMBER(15)
 , image_name       VARCHAR2(1000)
 , image            BLOB
 , timestamp        DATE
 );
 
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRAPP;

--Login to app schema and create the synonym on blob table. The java app connects to app schema and uses the synonym of blob table
CONN EBRAPP/EBRAPP@XE
CREATE SYNONYM test_blob FOR EBRTBLS.test_blob;


--The following Java Code is used for populating data to the blob table
--Save the following as TestBlobWrite.java file in D:\

import java.sql.*;
import java.io.*;
import java.util.*;
public class TestBlobWrite
{
//Usage:java TestBlobWrite <IP:PORT:SID> <username> <password> <version>
 public static void main(String args[]) throws Exception {
 Class.forName ("oracle.jdbc.driver.OracleDriver");
 Properties prop = new Properties();
 prop.put("user", args[1]);
 prop.put("password", args[2]);
 prop.put("oracle.jdbc.editionName", args[3]);
 Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+args[0], prop);
 PreparedStatement stmt1 = conn.prepareStatement("INSERT INTO test_blob (id, image_name, image, timestamp) VALUES(2, 'TEST_NAME', EMPTY_BLOB(), SYSDATE)");
 stmt1.executeUpdate();
 PreparedStatement stmt2 = conn.prepareStatement("SELECT image FROM test_blob WHERE  id = 2 FOR UPDATE");
 ResultSet rset = stmt2.executeQuery();
 rset.next();
 Blob image = (rset).getBlob("image");
 OutputStream os = image.setBinaryStream(1);
 byte[] bytes = "Test".getBytes();
 os.write(bytes);
 os.flush();
 System.out.println("Successfully updated....");
 }
}


--Steps to compile java (Change the path as required)
--from D:\
set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;
javac TestBlobWrite.java


--Steps to run the java program (replace the connection details, schema details)

set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;
--Usage:java TestBlobWrite <IP:PORT:SID> <username> <password> <version> (change ip and sid values based on your environment)
java TestBlobWrite d013:1521:XE EBRAPP EBRAPP ORA$BASE


--The above code works without issues connecting to EBRAPP schema which refers the synonym of blob table.

--Now execute the following to create editioning view on blob table
conn sys@XE as sysdba
create edition version1;
grant use on EDITION version1 to EBRTBLS,EBRAPP;

CONN EBRTBLS/EBRTBLS@XE
alter session set edition=version1;
REVOKE INSERT,UPDATE,DELETE,SELECT ON test_blob FROM EBRAPP;
RENAME test_blob TO test_blob_1;
CREATE OR REPLACE EDITIONING VIEW test_blob AS SELECT * FROM test_blob_1;
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRAPP;

CONN EBRAPP/EBRAPP@XE
alter session set edition=version1;
DROP SYNONYM test_blob;
CREATE OR REPLACE SYNONYM test_blob FOR EBRTBLS.test_blob;


--Run the same java program (replace the connection details, schema details and version details)

set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;
java TestBlobWrite d013:1521:XE EBRAPP EBRAPP VERSION1


The following exeption is thrown

Exception in thread "main" java.io.IOException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.OracleBlobOutputStream.flushBuffer(OracleBlobOutputStream.java:236)
at oracle.jdbc.driver.OracleBlobOutputStream.flush(OracleBlobOutputStream.java:169)
at TestBlobWrite.main(TestBlobWrite.java:23)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4C8TTILob.processError(T4C8TTILob.java:789)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8TTILob.write(T4C8TTILob.java:178)
at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2412)
at oracle.sql.BLOB.setBytes(BLOB.java:881)
at oracle.jdbc.driver.OracleBlobOutputStream.flushBuffer(OracleBlobOutputStream.java:228)
... 2 more

--If the grant on base table is given this works

CONN EBRTBLS/EBRTBLS@XE
GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob_1 TO EBRAPP;


--Run the same java program (replace the connection details, schema details)

set path=C:\Program Files\Java\jdk1.6.0\bin;
set classpath=D:\Applns\oracle11gXE\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar;
java TestBlobWrite d013:1521:XE EBRAPP EBRAPP VERSION1


Why is the grant required on base table in this case even if the java code uses only editioning view on the table and the grants on the editioning view exists? Is this a bug?



Tom Kyte
October 12, 2011 - 7:22 am UTC

update: 12-oct-2011

we have filed bug 13084683 regarding this, it is incorrect behavior - your temporary workaround (direct grant) until this gets fixed can be used


--------------------------------------------------------------------------




You wrote that you could do this from sqldeveloper, but not from your java application.

I believe you are wrong - if you would do in sqldeveloper what you did in your application - you would have seen this.

Here is your small reproducible test case, without java at all.


ops$tkyte%ORA11GR2> create user EBRTBLS identified by EBRTBLS ENABLE EDITIONS;

User created.

ops$tkyte%ORA11GR2> grant connect,resource,CREATE VIEW to EBRTBLS;

Grant succeeded.

ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> create user EBRAPP identified by EBRAPP ENABLE EDITIONS;

User created.

ops$tkyte%ORA11GR2> grant connect,resource,create synonym to EBRAPP;

Grant succeeded.

ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> CONN EBRTBLS/EBRTBLS
Connected.
ebrtbls%ORA11GR2> 
ebrtbls%ORA11GR2> CREATE TABLE test_blob ( image            BLOB);

Table created.

ebrtbls%ORA11GR2> GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRAPP;

Grant succeeded.

ebrtbls%ORA11GR2> 
ebrtbls%ORA11GR2> CONN EBRAPP/EBRAPP
Connected.
ebrapp%ORA11GR2> CREATE SYNONYM test_blob FOR EBRTBLS.test_blob;

Synonym created.

ebrapp%ORA11GR2> 
ebrapp%ORA11GR2> declare
  2          l_image blob;
  3  begin
  4          insert into test_blob( image ) values (empty_blob())
  5          returning image into l_image;
  6  
  7          dbms_lob.writeappend( l_image, 2, hextoraw( '0a0d' ) );
  8          commit;
  9  end;
 10  /

PL/SQL procedure successfully completed.

ebrapp%ORA11GR2> 
ebrapp%ORA11GR2> connect /
Connected.
ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> create edition version1;

Edition created.

ops$tkyte%ORA11GR2> grant use on EDITION version1 to EBRTBLS,EBRAPP;

Grant succeeded.

ops$tkyte%ORA11GR2> 
ops$tkyte%ORA11GR2> CONN EBRTBLS/EBRTBLS
Connected.
ebrtbls%ORA11GR2> alter session set edition=version1;

Session altered.

ebrtbls%ORA11GR2> REVOKE INSERT,UPDATE,DELETE,SELECT ON test_blob FROM EBRAPP;

Revoke succeeded.

ebrtbls%ORA11GR2> RENAME test_blob TO test_blob_1;

Table renamed.

ebrtbls%ORA11GR2> CREATE OR REPLACE EDITIONING VIEW test_blob AS SELECT * FROM test_blob_1;

View created.

ebrtbls%ORA11GR2> GRANT INSERT,UPDATE,DELETE,SELECT ON test_blob TO EBRAPP;

Grant succeeded.

ebrtbls%ORA11GR2> 
ebrtbls%ORA11GR2> 
ebrtbls%ORA11GR2> CONN EBRAPP/EBRAPP
Connected.
ebrapp%ORA11GR2> alter session set edition=version1;

Session altered.

ebrapp%ORA11GR2> DROP SYNONYM test_blob;

Synonym dropped.

ebrapp%ORA11GR2> CREATE OR REPLACE SYNONYM test_blob FOR EBRTBLS.test_blob;

Synonym created.

ebrapp%ORA11GR2> 
ebrapp%ORA11GR2> declare
  2          l_image blob;
  3  begin
  4          insert into test_blob( image ) values (empty_blob())
  5          returning image into l_image;
  6  
  7          dbms_lob.writeappend( l_image, 2, hextoraw( '0a0d' ) );
  8          commit;
  9  end;
 10  /
declare
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_LOB", line 1139
ORA-06512: at line 7



Now we can investigate whether this is a bug or not.

Given that Oracle OpenWorld is next week - it'll be a while before I can give this any activity. I'll be talking with the guy that knows EBR better than anyone and try to see what is up.

Use your workaround for right now and we'll follow up later.

Edition based redefinition

Lal Cyril, October 03, 2011 - 4:34 am UTC

Tom,
Thanks for finding the issue in your own way. Sorry for the confusion. I didn't try the full java code using sql developer. What i wanted to say, is that the insert statement(using empty_blob()) worked using SQL developer(just to explain that the grant to the table is correct).


Tom Kyte
October 03, 2011 - 10:02 am UTC

I didn't
try the full java code using sql developer.


and that changed everything - because you clearly said "it happens in java, it DOES NOT happen in sql developer". That sends support people down the wrong path, looking for a red herring. You would need to make sure in the future that when you say something like that, something that "sounds relevant", that you actually have tested it out all of the way.

That is why I wanted a SMALL AS HUMANLY POSSIBLE bit of code - that compared apples to apples, not apples to flying toaster ovens. When you finally gave me the complete example that was small - I saw immediately "these are not the same" and made them the same - which allowed me to immediately see "java not needed".

that let me cut it from the test case altogether! Now the example it even smaller and requires just.... sqlplus. Nothing to obscure what is going on. A support analyst would be able to see immediately "we have a problem" and will not have to weed through hundreds of lines of irrelevant code (nor have to try to figure out what tables to create etc.)


The fine art of making a test case - learn it. If you can do just that, you'll grow and order of magnitude or more as a developer immediately

11g changes to OFA

Kev, October 06, 2011 - 3:16 am UTC

Dear Tom,

I am currently studying for the 1Z0-050 exam (New Features for Administrators 11g) and have come upon what seems to me to be two very contradictory statements on page 3 of the official Oracle study material by Sam Alapati. I am hoping you can clarify them.

The first statement is:

"Oracle recommends creating the flash recovery area and the datafiles under ORACLE_BASE".

The second statement is:

"Oracle recommends that you keep the flash recovery area and the datafiles on separate disks".

The second statement makes sense to me for obvious reasons and is naturally my strategy for avoiding the loss of not only datafiles but also the FRA that will help me to recover if I need to.

Is it possible that the first statement has been unfortunately worded and something else was meant? After all, having them both under ORACLE_BASE means having them both on the same (logical) partition or disk.

Many thanks as always.

Kev
Tom Kyte
October 06, 2011 - 9:14 am UTC

statements on page 3 of the official Oracle study material by Sam Alapati. I


curious - why not get in touch with Sam Alapati?

But his statements are not contradictory necessarily. Mount points could be under oracle_base technically. Or links can be used (although I would not advise that).

11g R2 dataguard feature

Suraj Sharma, December 21, 2011 - 12:00 pm UTC

I've always been your fan and follower since begining of my career as ORacle DBA.

I have one simple question:

We have 11G R2 4 node RAC database and there is a 2 node clustered (RAC) standby as well for 11gR2, I have simple quesrtion: "As per RAC standard, Always DB services will be up (in mount state) on one DR node only and DB services will be down on all remaining nodes on DR side." is this statement true?
Tom Kyte
December 21, 2011 - 2:58 pm UTC

Not necessarily - you can have all of the instances on the RAC standby up and processing queries


http://www.oracle.com/technetwork/database/features/availability/maa-wp-11gr1-activedataguard-1-128199.pdf

license required for edition based redefinition?

A reader, April 03, 2012 - 4:44 pm UTC

Hello,

If we have enterprise edition for Oracle RAC, does edition based redefinition feature comes as part of that? I heard someone in my group that edition based redefinition requires an additional license.

Thanks,

Tom Kyte
April 04, 2012 - 12:03 pm UTC

Edition based redefinition comes with every edition of oracle - SE, EE, everything has it.

You can always review:

http://docs.oracle.com/cd/E11882_01/license.112/e10594/editions.htm#CJACGHEB

if something requires a license - it'll be in there, if not - you won't see it mentioned.

Regarding USER_OBJECTS_AE

Abdul Rahim, January 13, 2015 - 5:14 am UTC

Hi Tom,

I have just started implementing EBR features in 12c. I have couple of doubts. First Question
1. I created version1 it has objects created, then i created version 2 and created some cross editioning trigger etct. My current version is version1 & i removed the version2. But when i query this thing from user_objects_ae i could see the entry of the cross editioning trigger with object type as 'NON-EXISTENT'. Is there any mechanism available in oracle to remove those types of objects.

2. My Second Question: Base version is ora$base, a new version version1 is created and all the objects are deployed. Now i want to permanently migrate to this version. Many of the article says just execute the command
ALTER DATABASE DEFAULT EDITION=VERSION1;
I have executed this command. But it is not changing to the VERSION1 EDITION. Do we need to bounce back the database.

3. Third Question: I have ora$base, version1,Version2,version3. My latest version is version3. It has the latest changes. I dont want the previous version (version1 & version2). But when i triy to drop the same, i got the error. Error report -
SQL Error: ORA-38810: Implementation restriction: cannot drop edition that has a parent and a child