In this post I will put 5 other new 12c features in the spotlight (in addition to the features of a previous post), that really makes the 12c an improvement against the previous versions of the Oracle database.
To get this result I listed up all the major new features and wanted to know my top 5 features that would make my life easier(as a developer), excluding the features from the previous post (I certainly would have added the sequence modification(feature 1)), when doing development on an Oracle database.
- Top end query -> I really like this feature and I’m still wondering why it took Oracle so long before creating it. It is something I could have used a lot in the past, but instead I had to create far too complicated, not as nice readable queries to achieve this. How does it work? Well it’s very easy and it’s readable and can be used in a wide variety of cases. Some examples:
Only get the first 3 rows:
select * from X order by id
fetch first 3 rows only;
Skip the first 3 rows and get the next 3 rows:
select * from X order by id
offset 3 rows fetch next 3 rows only;
Get the first 50% of records
select * from X order by id
fetch first 50 percent rows only;
Get the first 3 rows together with the records equal to these department id’s
select * from emp order by deptno
fetch first 3 rows with ties;
If you want the capture the last rows, you can obviously change ‘first’ with ‘last’…
- In the 12c database the use of 32767 characters for a VARCHAR2 in SQL is now available instead of the maximum of 4000(this is also the case for RAW and nvarchar2).
We all have been waiting a long time for this one and before we had to use the clob datatype.
But beware this is not an out of the box feature, you will have to execute the lines below before this is enabled :
alter system set max_string_size=EXTENDED scope=both;
More info can be found on: http://docs.oracle.com/cd/E16655_01/server.121/e17615/refrn10321.htm
- The invisible column is a feature of which I was wondering where I could use it for.
Well it could be handy when you are adding a column to your table, but you don’t want any existing code to be impacted by it.
Another case where it could be useful, is when using audit columns. Columns as the creation_dt, update_dt, user_creation and user_update will only be of any added value when you would like to audit a certain column.
Packages with inserts, updates, references to this table will not be impacted by the creation of this column.
On the other hand there is also a risk that you forget that this column is in there, because you have to explicitly call for it (a describe or select * will not show this column). You can create invisible columns like this:
If you want to make the column visible again, use this:
In summary it could be handy, but don’t forget this column or it will pollute your table.
- The with clause inline plsql feature is also something that I think is very welcome.
It will make it possible to create a procedure or function inside your select statement instead of having to create this in a package or function. Oracle also says that this will optimize the performance against having to call a schema procedure/function(I still have to test this).
A little example:
FUNCTION fnc$_add_one(p_num IN NUMBER) IS
- Most of the time I use the ANSI way of writing for a left outer join, but the oracle way of writing left outer joins is still often used by many of the oracle developers.
But there was one thing that you could do in ANSI, that you couldn’t in the oracle way. You couldn’t write multiple tables on the left of an outer join, untill12c…
In 11g and before when coding something like this:
where a.id = b.id
and a.id = c.id(+)
and b.id = c.id2(+);
This resulted in -> ORA-01417: a table may be outer joined to at most one other table
In 12c this will work, also the ANSI solution obviously still works both on 12c and on 11g
JOIN b ON (a.id = b.id)
LEFT OUTER JOIN c ON (a.id = c.id AND b.id = c.id2);
Together with the previous post this makes 10 reasons why you should start to use the Oracle 12c database :-)
This battle for all the Oracle Partners in Belgium and the Netherlands is organized by Oracle (Yves Van Looy(BE) and Charles Billar(NL)). All employees of these Oracle Partner companies can compete to be the Oracle smartest of their company for that year. Just like last year, the contest was also aiming to provide an in-depth architectural knowledge about seven different technology tracks.
Like previous editions of AYTS, iAdvise joined this year’s AYTS contest.
This year, 17 people represented iAdvise, and tried to win the prestigious price: a business travel to the Oracle HQ in San Francisco and Las Vegas.
Six out of seven tracks were covered by the iAdvise team: Security, Data Integration, BI & Applications, HW & Software combination, Service Integration and Database & options.
This year, iAdvise also improved the oraevents site which is used for this contest. Many new features and functionalities were added to improve the user experience of this tool. The usability and new functionalities were clearly appreciated by all the contenders, all credits goes to the iAdvise apex team who really made this a very nice tool to work with!
Of course we also had a top 3 for iAdvise: Tuur made it as ‘nummero uno’ for the security track, second place went to David for the BI track and on the third place Kristof who also followed the security tracks. Congratulations to all three!
So we had some high scores on different tracks, which ones again proves that iAdvise is very proficient in several technologies.
But even more important was that Tuur got a gigantic high score of 39/40, something that nobody ever achieved before in the AYTS history and it will likely take some time before someone will achieve an equal or higher score.
He is without question the very convincing winner of this edition, and will enjoy his trip to the States! Congratulations Tuur!
Next year will be without question very exciting, since there are a whole lot of new technologies coming up our way and of course iAdvise will be one of the participating companies!
I already managed to remove the Dbms Output pane a couple of times from my SQL Developer, probably by doing a keyboard combination by accident.
I am not sure how I did this and I can’t really reproduce this but sometimes I was bugged with this problem.
Problem is that I can’t get this pane back by following the ‘normal’ procedure (going to Menu-> View->Dbms-Output).
Previously I did not found a proper solution for this and I just had to reinstall the sqldeveloper all over again.
Untill now, I found a really easy way to get this pane back.
First of all exit all your sqldevelopers sessions.
Go to the directory where the sqldeveloper is installed (the numbering of the directories could be different from one version to another, but it will look similar to this)
there remove the windowinglayout.xml file
This file contains your ‘custom’ sqldeveloper layout. By removing this the sqldeveloper layout will be reset to the original settings.
Then restart your SqlDeveloper
in sqldeveloper go to Menu -> View -> Dbms_Output
And tadaaa there it is again :)
What should you do if you have an anydata column in a queue table and you don’t have any tool to read from it(sqldeveloper doesn’t support it natively)?
I have written some code to extract all the information from such a column and print it, whatever the content would be.
You can find out more Continue reading
Something I really often use is this select:
SELECT distinct type,line,name,text
WHERE lower(Text) LIKE(‘%’||lower(:search_source)||’%’)
SELECT distinct ‘column’ type,null line,table_name||’.’|| COLUMN_NAME name,null
WHERE lower(COLUMN_NAME) LIKE(‘%’||lower(:search_source)||’%’)
SELECT DISTINCT ‘table’ type,null line,object_name name,null
WHERE object_type IN (‘TABLE’,’VIEW’)
AND lower(object_name) LIKE(‘%’||lower(:search_source)||’%’)
ORDER BY type,name,line
This select will show you most of the database objects in a schema(columns, table,view,code), where this ‘search_source’ string is used.
You can add this into you sqldeveloper as well, as a user defined report.
To accomplish this you will have to do the following steps:
1) Open sqldeveloper
2) go to Reports tab(If you don’t see this tab go to the Menu choose view->Reports
3) right-click ‘User Defined Reports’ -> add Report -> give name and put the sql code as above into SQL input screen(you can leave the rest as default)
You can use this Search in sqldeveloper now.
When you try to convert an xml file, which has a tag that contains for example one or more pdf files, into an XMLTYPE object, you will get the following error:
ORA-19011: CHARACTER string BUFFER too small
This error will be thrown because the content of a tag of an XMLTYPE is limited to 4000 bytes(this problem should be solved in 11g).
I have developed a solution/workaround for this.
For a project with Oracle Portal, I had to do some lookups in packages and procedures on the database to get some information about the project. Since I wasn’t working full-time for this project I had no access to the DB, except via the portal itself.
Several times I had the problem that the client wanted a quick answer for his question, but therefor I needed to dig into the code that was developed in the past. The problem was that the size for editing/viewing a package or procedure was limited to 30K and since there where several packages bigger than 30K, I couldn’t give them a quick answer.
If you only want to read the packages(not edit), there is a very easy portal solution for this problem:
I was developing a dequeue function for an XML file and I wanted to check if a certain returned value from the xml file was correct.
To retrieve the value of a tag I used this=>
v_text := v_record.extract(‘/record/Fruit/text()’,’xmlns=”http://www.example.org”‘).getStringVal();
Ones I captured this record I wanted to check if the content of this tag was equal to, for example, some fruit, let’s say ‘Lemon’.
In most of the cases I received the correct result, but there were some xml files which didn’t gave me the correct result. Nevertheless I was pretty sure that the value in my xml file was ‘Lemon’.
So what happened? I did some checks and then I found out that the syntax of this specific xml file was something like this:
When extracting the content out of the Fruit tag he also took the spaces, tabs and lines with it, and that was the reason why he thought that this wasn’t a ‘Lemon’
Conclusion, always use trim for the spaces and put some replace clauses for lines and tabs round the value. So you should use something like this:
v_text := replace(replace(replace(trim(v_record.extract(‘/record/Fruit/text()’,’xmlns=”http://www.example.org”‘).getStringVal()),chr(10),”),chr(13),”),chr(9),”);