Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Wednesday, September 08, 2010

SQL: Start day and End day of week

I just got an interesting question: how do you know for a date, in which week (Monday - Sunday) it falls.

I created a little test script to get 31 days of data:
(date_c is the same as date_d, but in a more readable output. c stands for char, d for date)


select to_char(sysdate + level, 'Day DD-MON-YYYY HH24:MI') as date_c,
(sysdate + level) as date_d
from dual
connect by level <= 31

Next I used the NEXT_DAY function to get the first Monday after that date, and the same for the Sunday. As it will give you the results of the next week I had to subtract 7 days so I was sure it would fall under the week the date was in.
e.g. if you have a date Wednesday 8 of September, that person wanted to have Monday 6th-Sunday 12th. If I just did NEXT_DAY of 8-SEP I would get 13-SEP, that is why I first had to subtract 7 to go to a previous week and get the next Monday.
For the end date it's similar, but there you only have to subtract 1 day, as only the Sunday might be a problem, as the next Sunday is the next week.

So the final query became:

with t1 as (
select to_char(sysdate + level, 'Day DD-MON-YYYY HH24:MI') as date_c,
(sysdate + level) as date_d
from dual
connect by level <= 31 )
select date_c,
next_day(trunc(date_d)-7,'Monday') as start_day_of_week,
next_day(trunc(date_d)-1,'Sunday') as end_day_of_week
from t1

A more readable screenshot:


Update (after comments of Kees and Alex): the following solution looks even more elegant and is NLS independent:
with t1 as (
select to_char(sysdate + level, 'Day DD-MON-YYYY HH24:MI') as date_c,
(sysdate + level) as date_d
from dual
connect by level <= 31 )
select date_c,
trunc(date_d,'iw') as start_day_of_week,
trunc(date_d+7,'iw')-1 as end_day_of_week
from t1

Wednesday, August 25, 2010

Follow-up on comparing two Oracle schemas

Over 4 years ago I wrote a blog post about software that helps you to compare two Oracle schemas. That post is accessed a lot and I still get questions about it, so I decided to write a follow up on that post as things change over time.

Comparing two Oracle schemas is still something I have to do regularly, e.g. if I want to compare a development, test and production instance after a deployment of an application.

Alongside Oracle Application Express (APEX), I use Oracle SQL Developer daily. They have a built-in Database Diff tool which works, but I tend to use other tools as well, as it’s hard with SQL Developer to see exactly what has changed. We built our own tool in APEX that compares schemas based on dbms_metadata, which we use when we have access only through the APEX interface. But when I can run things from my own system, I like to use Schema Compare for Oracle.

The people of Red Gate wrote a nice post on how to use their software, with screenshots and steps you can follow, so I won't repeat that. Instead I’m going to compare it against the Diff Tool built into SQL Developer.

Simplicity

The older I get, the more I can appreciate user-friendly software. That is something I try to do in the software I write myself, follow the KISS principle = keep it simple stupid.

For me software has to look good, ’be easy to use and do what it’s intended to do in an efficient way. If I want to compare two schemas I just want to follow a couple of steps:
1. Select my source and target database
2. Select the schema(s) I want to compare
3. Optional - select what exactly it should compare (tables, packages etc.)
4. Get an overview of the results
5. Produce synchronization scripts

Schema Compare for Oracle (SCfO)

Here’s how it works in Schema Compare for Oracle.

When you open Schema Compare you have to create or open a project.


It asks you for the source and target database you want to connect to and which schema you want to compare. An advantage in SCfO is that you can compare multiple schemas at once.
Another thing I found interesting was the option to compare against a Snapshot. You basically take a “picture” of your schema at a certain moment in time and compare against that. Very handy when you can’t access both schemas from the same location. Or if you develop applications and want to generate upgrade scripts, I see the use of snapshots too.

But let’s get further with the normal schema compare.

In SCfO you don’t select the objects first, you just hit the Compare Now button and SCfO starts to compare the whole schema directly. At first I thought, I don’t really want you to do that as you are doing a lot of work for nothing, but the more I used the tool, the more I appreciated it. To start a comparison is very easy and quick...

One thing I found handy as well is the Options tab, which allows you to define if the tool needs to ignore white spaces, storage clauses etc.


When we are happy with the options, we click the Compare Now button and we get a screen with the progress.


Once it’s finished you have a complete overview of the differences in both schemas.


I like this screen a lot as it has many more functionalities than you would first imagine. The filter (find box) is very handy to find some specific objects quickly. You can also sort by different things and just from the way it looks it is so easy to understand what is different in which schema and database! But the nicest thing is when you click on a row where there are differences. It shows you both versions and highlights the differences. No need for an extra tool or text editor to get that information out. It’s just there.


If you want to create an upgrade script or make both schemas equal you just have to use the Synchronization Wizard...

The wizard asks you what it has to do and generates a script for you or automatically synchronizes both schemas based on the objects you selected.


I think Schema Compare for Oracle does it really well. So let’s compare it to the comparison tools that come with Oracle SQL Developer.

Oracle SQL Developer

In SQL Developer you go to Tools - Database Diff.

The first time it will tell you it’s using Oracle Change Management, a payable option of the Oracle database, and you have to acknowledge you have a proper license to use that.


Next, it will pop up with a screen that allows you to select a source and destination connection and immediately asks you what objects you want to compare.


Clicking on Next shows you a screen where you can select the individual objects.
You can view all objects at once, or change the select-list to only see tables, sequences and select the objects that way. This might be a good thing to do if you have many objects!


Once you click Finish it will compare the objects and present you the result in a Diff Report.


You can click on the green SQL button and it will generate the script for you based on the differences you selected.

So it’s rather straightforward to compare two Oracle schemas in SQL Developer, but there are some things I would prefer a bit different.

This is my wish list:
1. Not be forced to have the Change Management license for your Oracle database. The price depends your Oracle Database license, but it can be high if you just want to compare two schemas through SQL Developer.
2. Be able to compare multiple schemas at the same time.
3. Get a cleaner Diff Report, which allows me to add filters to it and allows me to see what exactly is different between the two versions. At the moment I just see a count there, when I click on the row. I get the script to generate that version, but I couldn’t find a way to see exactly the source and target and compare them side-by-side.

Point 3 is my biggest issue and that is why I searched for something else that made my life easier and finally came across Schema Compare for Oracle. Although Red Gate created a Windows only version of Schema Compare for Oracle, so as a Mac user I need to run it through a VM, I find it worthwhile to do it. The interface of SCfO is very clean, it’s easy to use and it gives me most features I’m searching for. There is even a SQL Developer plugin for SCfO (search for Schema Compare for Oracle in the SQL Developer Plugin repository).

So is Schema Compare perfect and is it better in every aspect than the Diff Tool in SQL Developer? Almost, but not completely. SQL Developer supports the comparison of Materialized Views (and their logs) and Database links, which SCfO doesn’t do in the release I tested (1.3).The version of SQL Developer I used was 2.1. I’m not sure the Diff Tool in SQL Developer 3 (which will be released in a few weeks/months) will be different...

Happy comparison!

Thursday, February 19, 2009

European APEX Training Days - April

After our highly successful Utrecht and London Oracle APEX Training Days (not to mention our original Brussels Training), Apex Evangelists have just opened registration for our 4th Oracle Application Express 3-Day training course. This time it will be held in the nice Midland Hotel in Manchester, UK, from the 20th-22nd of April.

So, what are these training days? Well, we host a lot of on-site training for clients, however we also hold ‘open training’ days, where anyone can sign up, come along and get training by people who know the product inside-out. We believe that our training provides the highest quality training for superb value for money.

The current agenda (subject to change) covers a variety of topics, but it doesn’t just stop there. We don’t believe in just a 9-5 training schedule and one of our core beliefs with these training events is to provide an open format where you can also raise any other (APEX related!) problems/questions you might have, particularly during some of our ‘out of hours’ relaxed sessions.

If you have been on one of our previous training events then you’ll notice the agenda has changed and even if the topic description might look the same the contents may have been modified, so if you’ve been to a previous event there is still value in attending this one (we’re proud to say that on every course so far we have always had someone who attended a previous event!).

Following the previous training, we expect interest to be high (and places are strictly limited, so please don’t delay to register).

You can find more information on exact location, pricing and signing up at http://www.apex-evangelists.com/training

Monday, September 15, 2008

Preview Oracle APEX 4.0 - Websheets

Oracle Application Express 4.0 will include a lot of nice new features. You can read about these in the statement of direction.

A few months ago I put some screen shots of the Websheets functionality on my blog.

Now I'm happy to show you a video so you can see it working live! As like my previous post this presentation got recorded during Marc Sewtz's APEX presentation. Again I edited it and put some music to it. The music is carefully chosen of course, but if you don't like it, put the volume to mute. The preview takes just over 4 minutes. Here we go...



A better quality video can be downloaded in m4v format or swf format.

Preview Oracle APEX 3.2 - Forms Migration

APEX 3.2 won't include much changes in the development tool itself, but there will be a killer feature added: the Forms Migration tool.

A lot of people are looking into other directions to replace their Oracle Forms/Reports or Designer environment. Till a few months ago Oracle themselves pushed you towards JDeveloper. A lot of people I spoke to were not that java minded and even started to look after other solutions (non-Oracle). With a Forms to Apex migration possibility I think a real solution is waiting for you.

The main reasons I believe such a tool has a big change to succeed:

  • You want to keep your Oracle investments. APEX is living in the Oracle database so 100% ok.
  • You want to reuse your Oracle knowledge. Forms developers know SQL and PL/SQL very good, which is exactly the knowledge you need for APEX.
  • You want your migration be so streamlined as possible. Hopefully the Forms2APEX migration tool provides you with that. I don't believe a tool doing the migration for 100% automatically exists, but you should be able to reuse a lot and get a head start.
  • You want your Forms environment in a Web 2.0 way, which APEX is providing you.
As you could read on David Peake's blog, the limited Early adapter is not going to happen, instead a normal Early adapter is foreseen. I'm not sure how the final screens will look like, but here's alread a preview of the Forms to APEX migration tool! I recorded this video from Marc Sewtz presentation for the German APEX Community. I edited it and added some music. When putting the video on Youtube the quality dropped, better quality video can be downloaded in m4v format or swf format. You might want to turn the volume down or up ;-) Hope you like it!



You can see to the full presentation of Marc here (in German).

Thursday, May 15, 2008

European APEX Training Days in the Netherlands

It's starting to become a tradition... After our successful Oracle Application Express training days in Brussels (September 2007) and London (March 2008) it's time to announce our third European APEX Training Days. This time it will be held in Utrecht, the Netherlands.

The environment will be a bit different. We didn't go for the Plaza hotel, instead we went for a green "theme". The setting and architecture of the Mitland hotel make you feel as if you’re in the middle of the countryside! Nevertheless, it's only 5 minutes from the city of Utrecht.

Below you find the agenda. Depending feedback we might change some topics, but these are the topics we believe will bring you to the "next" level APEX developer.


You find more information about the training days at the website of Apex Evangelists.

Hope to see you there.

Tuesday, May 13, 2008

Sometimes you love you chose Oracle

The last days it's really hot in Belgium. Working when it's hot is not good for our brains and the computers as they get overheated.

Some people are distracted as they think about the pool all the time, some others get grumphy and some others make mistakes...

In the last couple of days I had to use the flashback feature of the Oracle database more than the last 6 months together. When you get a mail like: "I had to change something, but accidentally deleted the whole text. Can you please put it back?"

At that time you're so glad you use an Oracle database! Can you do something like this in MySQL or MS SQL Server?

SELECT *
FROM my_table AS OF TIMESTAMP TO_TIMESTAMP('2008-05-12 08:00:00', 'YYYY-MM-DD HH24:MI:SS');

Another command I had to use for myself, when I dropped a table in development, but forget to look at the logic of an existing trigger of that dropped table:
FLASHBACK TABLE my_table TO BEFORE DROP;

I guess everybody already knew about flashback in Oracle (if not, Tim Hall wrote a nice compact page about flashback), but then I wonder sometimes why people ask me if APEX also runs with other databases... Oracle has to many nice features buildin, so some want to use another database I guess ;-)

I'm happy the sun is shining and I'm using an Oracle database during these days.

Friday, March 28, 2008

Dynamic Breadcrumb in APEX

I got a question during the training how to create a dynamic breadbrumb. If you don't know what a breadcrumb is, it looks like this:

Breadcrumbs are nice to have a hierarchical navigation view or a visual flow how you came to that page. In Oracle Application Express breadcrumbs are rather static. You specify for which page the breadcrumb counts and if it has a parent. It's not "out-of-the-box" to make it more dynamic, so I made a quick example to show how you can create a dynamic breadcrumb.

In my example you've three different pages. The request was if you go to page 3, it should know from which page you came, so you can click the breadcrumb to go back to the page you came from. In my case Page 1 or Page 2.

You can use different breadcrumbs which you show based on a condition, but that's not really dynamic. So let's try to make it more dynamic!

Create 3 pages and call them: Master 1, Master 2 and Child


On the Master Pages add a Submit button to the Child Page. Also add a breadcrumb on all pages like you normally would do.

Do you see you have a problem? For the Child breadcrumb you need to specify a master, but you've two masters! So how to get around this?

Create two Application Items: AI_PARENT_PAGE, AI_PARENT_PAGE_NAME
(in the screenshot I've one more, but in this example you don't need it)


On the Master Pages, in the Branch for the Submit button, specify that it need to go to Page 3 and give the Application Items the value of the master page you're on. On the screenshot in my case Page 1 (Master 1).

Page 2 would be the same expect from the last line where you would have 2, Master 2.

In the breadbrumb you would reference the Application Items instead of the fixed page number and page name. Change the original breadcrumb for Master 1 to:


The result will be a dynamic breadcrumb!
You can download the example application which shows the feature here.

I thought it might be useful for others too, hope it helps some of you.

Thursday, March 27, 2008

Creating Help in APEX

It's not a new feature of APEX 3.1, but I didn't use/see it that much before. With the new icons in APEX 3.1 the Help region draw my attention.

Did you already see the region type called "Help Text"?


If you don't like to write documentation, this feature is something you should look at. Of course we all start with writing our test cases and documentation about how the system will work before we actually develop, so not sure who will use this ;-)

Seriously, some of us do put some help text with the items, so if you click on the label of the item you get some help. Wouldn't it be nice in that case if you could also see the help of all items at once?

That's exactly what this new feature is doing! The Help Text Region gets filled with all Help Text of the items on that page.

An example will make it more clear...

1) Create a new Blank Page with as template "PopUp". On that page create a new region of type "Help Text". (see the above screenshot to select the region)
Give it an alias of HELP_PAGE (in Page Attributes)


2) On another page, create two new items: for ex. two text-items: name and address and add some text in the Help section. Also add some text for the Help in the Page Attributes
3) Last step to do: add a url to the Help page on every page
Go to page 0 (create Page 0 when you don't have it) and add a region (display before footer) with a link to f?p=&APP_ID.:HELP_PAGE:&SESSION.:&APP_PAGE_ID.
Also put a condition on the Help Region as we don't want to see the help on the help page itself.
("Current Page is NOT in Expression 1")


4) Run your page and click on the Help link
You should see the help of both items!

Nice, isn't it?


An export (APEX 3.1) of an application which shows this feature in action, can be downloaded here.

Monday, March 03, 2008

Oracle APEX 3.1 Training for Europe

In two weeks time our European APEX Training Days will take place in London (UK).

As blogged before, on Friday APEX 3.1 went live under a big applause! If you would like to get one of the first trainings covering APEX 3.1 New Features, you can't miss our training ;-)

We still have some places left, but be quick as time flies! The training is from March, 18th till 20th in the heart of London. An awesome place! And a message to people not coming from the UK; the exchange rate has dropped... so you pay "less" compared to a few months ago!

Of course, if you're from the UK you don't have that exchange rate advantage, but we also provide group discounts.

Hope to see you soon at our event or maybe I'll speak you in the States at Collaborate or Kaleidoscope.

Thanks,
Dimitri

Tuesday, February 05, 2008

Where are all these APEX blogs?

I'm happy to announce my new project: www.apexblogs.info


The goal of the new site is to find all APEX related blog posts at one place. But that's not all, you can also rate the articles and if you don't have a blog yourself, but want to share your findings, idea's etc. the site will allow you to do that. You can write your own blog posts.

Next to releasing this site for the APEX community, I also wanted to show a more advanced site created in Oracle Application Express. It reads RSS-feeds and provide one, it uses jquery, javascript, css, materialized views and provides an easy to search functionality (based on interMedia).

You can also add your feedback or start discussions and view statistics of the APEX blogger community.

It's a first beta release, so I'm open to all your comments, feedback and ways to make it even better.

Hope you enjoy the site!

Sunday, February 03, 2008

Checkbox in APEX

You want to create a checkbox in Oracle Application Express and get it's value in javascript?

An example of a checkbox:
In my application I want to do an interactive search whenever the checkbox is checked.

So, how do you know if the checkbox is checked? Let's try with an example.

  1. Create a new "Check Box" item and give it a name, for ex. P26_CHECKBOX.
  2. In the List Of Values, put STATIC2: ;Y (this checkbox doesn't have a label, but will return the Y value whenever the checkbox is checked)
  3. If you look at the Session State (in the developer toolbar) of the item after a submit of the page, you see the checkbox item has a value of Y when it's checked...
  4. If you want to get the value of an item in javascript within APEX, you normally do $x('ITEM_NAME').value
  5. So let's try $x('P26_CHECKBOX').value -> it returns: undefined
  6. If you know a bit of javascript/html, you maybe think you need to use $x('P26_CHECKBOX').checked -> it returns: undefined
  7. The above doesn't work, because APEX is putting a number after the item. In my example: $x('P26_CHECKBOX_0')
  8. If you try with $x('P26_CHECKBOX_0').value, it return Y or with $x('P26_CHECKBOX_0').checked, it returns true... and that's what we'd like to have
  9. See it in action here
If you've more checkboxes (because the lov is returning more values) you can use following function to see what's checked:

Thursday, December 13, 2007

ADVERT: Agenda European APEX Training Days

A few days ago we released our agenda to the people coming to the AE European Oracle Application Express Training Days.

This training will be held in London in March 18th-20th 2008. It's not a beginners training, more an advanced one, although "advanced" is difficult to measure.

There are still a few places left, so if you have been looking for some Advanced APEX training by some of the most passionate APEX people around then sign up quickly as places are limited. 

Saturday, December 01, 2007

Installation of BI Publisher on OEL5 and BIP Desktop on Windows Vista

-- Update: This post remained in my drafts folder (for one month now), I guess I wanted to include something else, but I don't know what anymore, so I decided to post it as is...

As I blogged a few days ago, I created a VM with my Oracle soft. Now I'm extending my demo system with BI Publisher. So far, so good, wasn't it I also need Oracle BI Publisher Desktop, and that runs on Windows. I could have gone for another VM for only that, which would be the most secure thing as it would be a "fixed" working environment (without the windows updates etc.).

Nevertheless, I didn't do that, as my systems RAM is going bananas! Windows Vista is already eating 1GB of my RAM, the other 1GB I use for my VMware. So no room left for another VM with Windows.

As I'm giving a presentation at OOW and UKOUG about the integration of APEX and BI Publisher and creating some advanced pdf's, next thing for me to do ... install BIP!

When I'm talking about Oracle Business Intelligence Publisher (BIP), I'm talking about a server part, in my case BI Publisher 10.1.3.3.1 for Linux and a client part, BI Publisher Desktop 10.1.3.3.1 for Windows.

Installation of BI Publisher 10.1.3.3.1 in OEL5 (Oracle Enterprise Linux 5)

Installing BIP in Windows is a matter of minutes, click on the installation file and that's basically it. I hoped it would be as easy in Linux, but ...

After downloading BIP for Linux, I read the manual. There're not that many pre-requisites, so I started with "./runInstaller".

What followed was a nice java error thrown by the OUI (Oracle Universal Installer).
When you think you've all needed libraries installed, there's for an odd reason always one more! In my case I had to install the libXp-1.0.0-8.i386.rpm package to get the installation of BIP running.

So these are the steps I followed to install BIP (server) in OEL5
  1. Start a Terminal
  2. Install the required library: rpm -Uvh libXp-1.0.0-8.i386.rpm (you find the rpm on CD2 of OEL5)
  3. Download BI Publisher
  4. Extract the file: cpio -idmv < (the downloaded file)
  5. Do a Basic Installation of BIP: ./runInstaller
  6. Go for the defaults, which means you get a proper oc4j for your BI Publisher
  7. To configure your APEX with BI Publisher you may want to read my previous blog post.
    Be sure you did all pre and post installations for your DB and BIP.

Installation of BI Publisher Desktop 10.1.3.3.1 in Windows Vista

Installing software to demo on your daily OS, isn't maybe the smartest thing to do, but I already explained why I'm still doing it. Let's hope my settings will still be good at OOW ;-)

  1. Download and install Java Runtime Environment (JRE) 6 Update 3
  2. Download and install Oracle BI Publisher Desktop
  3. You may want to read this before installing BIP Desktop on Vista.
    I went for all default settings.
  4. In MS Word you'll see the BIP Add-in (see screenshot)

Thursday, November 08, 2007

Quest Toad on Oracle 11g not supported

Are you already on Oracle Database 11g? If you're not, it's really cool ;-)

Nevertheless, this post is to warn all developers out there using Quest TOAD for Oracle.
The current release of TOAD is 9.1, this version is not supported with Oracle 11g (client). But even more important, the version that comes out half of November, TOAD 9.5 (see screenshot below which is a beta), isn't working with the Oracle 11g client neither!

I logged a support ticket at Quest. The support over there is really quick and helpful. In less than a day I got a message back that they were going to try it themselves, it went even to the technical people (development team) and after a few mails of back and for I got this final message: "Unfortunately, it was confirmed by our team's technical lead that Toad version 9.5 only support Oracle server 11g and not Oracle client 11g. My only suggestion for you is to install another client on your machine that is 10gR2 version or lower."

It's hard to believe that you need to install an Oracle Server just to get your development environment (TOAD) running ;-) Nevertheless, a workaround is to install Oracle 10g client, which I don't want to do as I'm connecting to 11g databases.
Or go for SQL Developer, a free alternative of Oracle.

A screenshot of the error "OCI version 11.1.0.1.0 is not supported"


I'm using both SQL Developer and TOAD as I think both have strengths and points to improve.
This post isn't to favor for SQL Developer, it's just to warn you... on my Windows Vista pc I'm obliged to go for SQL Developer as TOAD is not working with my Oracle 11g client.

Wednesday, November 07, 2007

What should you say to students when teaching Oracle?

A few weeks ago I teached a group of students some parts of the Oracle Database.

When talking about new features and the things of Oracle I think are really good, I started to talk about Oracle Application Express. On the fly I did a demo of APEX and talked about Rapid Application Development. The students were really attentive and sometimes I heard an "ohhh" ;-)

The demo was the start of a very interesting discussion. The students have a course called "Rapid Application Development", it's not APEX, it's .NET. When I heard that, I thought "fine", how do they call APEX then: "High Speed Application Development", "Rapid Application Development times 10", "Application Development at Warp Speed", ... ?

But that wasn't the most interesting part yet! Apparently the students had to do a project: their development a part in Java and a part in .NET on an underlying Oracle database.
The students thought it a good idea to create packages and put the logic inside the database. They showed their teachers and they gave this feedback: "The database is for your data, the logic you put inside your application (middleware/java/.net)"... I'm not sure about you, but I disagree with that statement!

I prefer to have as much logic/validations/business rules etc as close to my data, in other words, if I can do it in the database, I will do it. For me it doesn't make sense to only use the database as a data store. What changes the most? I would think the front-end! Do I always need to recreate all the logic again? If today I use Java, at the same time I use APEX, C# and Flex on the same data, I need to write my logic four times? And will the implementation be exactly the same? I come from the DBA side and in general DBA's prefer to know what you're doing. If the same package/procedure/function in the database is called by all development environments we know exactly what's happening. It can be tuned appropriately, statistics can be kept, auditing etc. I even didn't talk about data consistency...

One of the arguments was "performance": if you always need to go back to your database server, too many round trips... Ha! What about the performance of putting everything in recordsets and treating these recordsets? Maybe I can do the same in one SQL statement by using analytical functions? Why not using materialized views? Who does best to handle the data in the most performant way?
Of course I also use some client side things to check if a field is filled in, so I avoid a server roundtrip, but it's not true for data/logic etc.

There're so many great features in the Oracle database that people using the Oracle database as just a data store are not knowing and not using. It's a pity.

Nevertheless, we had a lovely discussion about this topic, but afterwards I thought I was maybe too hard for the teachers. It's a fact there're two groups of people out there. In my experience a lot of JAVA developers are doing it the "put logic in your middleware/app" approach, where as people coming from the database prefer to have their logic as close to their data.

My question... What should you do when you get such a question (logic inside the database or not)?

Tuesday, October 30, 2007

My demo system: VMware 6 + OEL5 + Oracle DB 11g

It took me longer to install my demo system as I thought. So be warned when doing this yourself.


My current laptop is a Dell Latitude D820 with 2GB of RAM running a dual boot: Windows XP and Vista. Before I used Windows XP as my demo system, but with the service packs and other installation of software which can interfere with my Oracle config it was too risky to keep it as non-fail demo system. I also wanted to use Windows Vista, but on that, the Oracle database is not supported. Update: according to this it's supported on Windows Vista Business, Enterprise, and Ultimate editions.

So I thought to start using VMware images as demo system. I already tried it in the past (the Oracle VM's) but found it too slow, so I was sceptic about it. But I must admit, it's running fine at the moment.

The time I started with my VM's, Oracle DB 11g for Windows wasn't even out, so I choose for Oracle Enterprice Linux 5 (OEL5). Oracle is putting a lot of effort in linux and using it as their "main" development platform, so most of the soft should come out first for this operating system.

I first used VMware Server (free) to install OEL5, which did work. But when playing with linux and trying to get my network working, I just had one problem after another.
I couldn't understand why it failed, so I tried to use VMware Workstation (not free), which I was sure was supported for Windows Vista. After 5 minutes everything worked.

Tip: When using Windows Vista use VMware Workstation 6 or higher!

The steps I did to get my demo system up and running.


Create a new VMware machine
  1. Select "New Virtual Machine" from VMware to create the hardware specification
  2. Go for a Custom virtual machine configuration - Linux - Linux kernel 2.6.x
  3. I used 1GB Ram, 20GB diskspace, a cd-rom and bridged ethernet
  4. Go with the defaults of the wizard


Install Oracle Enterprise Linux 5

  1. Download Oracle Enterprice Linux from OTN
  2. Unzip the file, you should get 5 iso images
  3. Mount the first cd in your VMware console (Edit virtual machine settings - connection - use iso image)
  4. Start the Virtual Machine
  5. If everything is fine, it will boot the OEL5 cd and will start the wizard for the installation
  6. I used most of the default settings during the installation
  7. Use a static IP address
  8. Select some more packages as default (Customize software packages to be installed) for ex.: Legacy Software Development, Graphical Internet, Development Tools, System Tools
  9. During the installation you'll need to change the cd's (right click on the cd in VMware, Edit and select the other cd)
  10. Reboot the system and finalize the installation


Configure your linux

  1. I had to change the monitor to be able to get a higher resolution
  2. You can also opt to install the VMware Tools which give you some more features
    (I had some problems with these tools as they changed my network settings)
  3. If you prefer to change your shell (for ex. bash instead of ksh), you can do that by using: "chsh". You need to logout and login again so the settings are applied.


Install Oracle Database 11g

  1. Read the installation guide (!). Even the most experienced people sometimes forget to read the installation manual. Something can change in time, the system requirements change, ...
  2. Especially in linux you need to review your kernel parameters and required packages.
    Some of the packages that weren't installed as default, for ex.: libaio-devel-0.3.105-2, unixODBC-devel-2.2.11-1. You find most of the required packages on CD2 and CD3.
    You can use the "rpm -Uvh" command to get them installed.
  3. Create users and groups:
    # groupadd -g 501 oinstall
    # groupadd -g 502 dba
    # useradd -g oinstall -G dba -s /bin/ksh oracle
    # passwd oracle
  4. Append the following to the /etc/sysctl.conf file as the root user and run /sbin/sysctl –p (this command makes the settings immediately applied):
    kernel.sem = 250 32000 100 128
    kernel.shmmax = 536870912
    net.ipv4.ip_local_port_range = 1024 65000
    net.core.rmem_default = 4194304
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 262144
  5. The Oracle Universal Installer will verify the requirements, if they are not met you'll get a warning. Before going further, you should review the failed items and resolve the issues.
    Do retry and if all steps are passed successfully, you can start the installation.
  6. I did a normal Enterprise Edition install with the preconfigured database.
  7. You may also check your environment variables (for ex. in /home/oracle/.bash_profile) for the oracle user ($ORACLE_HOME, $PATH, $ORACLE_SID etc.) Make also sure you include the Oracle bin directory in your PATH (export PATH=$PATH:$ORACLE_HOME/bin) so you can run commands from everywhere.

Configure Oracle Application Express (APEX)

  1. To configure APEX you can follow the instruction in the Postinstallation tasks
  2. Before, I always used Apache as my webserver for APEX, but now I thought to go for the embedded PL/SQL gateway
  3. As most of you know, with 11g APEX is preinstalled ;-) The installation is made so easy!
  4. Open a terminal and go to $ORACLE_HOME/apex
  5. Connect with SQL*Plus as sysdba and run @apxconf
  6. It will ask you for the port of the Oracle XML DB HTTP server. I'm not sure 8080 (default) is a great port to use as it's sometimes in conflict with other products... so I used 7779.
  7. The final step is to ALTER USER ANONYMOUS ACCOUNT UNLOCK;
  8. Go to your fixed ip or hostname in a browser: http://192.168.2.150:7779/apex/
  9. The first time can take some time, but you should see APEX coming up

Tip: Read the manuals!


Some screenshots of my system


If you want to read how to install something like above but in Rac, Frederik (Frikkie) Visser wrote a very good article.

That was basically what I did to create my demo system. During this process, I sometimes "cursed" my machine. John Scott was very supportive, but also teased me more than once with "get a Mac"! We'll see ;-)


Friday, October 05, 2007

Oracle APEX Forum - Week 39

*** After a long time, I finally said to myself to start this Oracle Application Express Forum Wrap-up again ***

My goal is to put some links to the forum that took my attention in the last week. Sometimes these posts made me laugh, sometimes they made me cry and some of them I found really interesting.

The most interesting topics:

Announcements:
  • none
If you saw something in the forums I should have included, you're free to put a comment.

Wednesday, September 26, 2007

Update: I love PLSQL and ... (.net)

I got some messages about the title of my previous blog post and the picture you get when clicking on Steven Feuerstein's photo on the iloveplsqland.net site.

The title of my previous blog post was a bit to "shock" some people and see what it would do to the stats of my site. ;-) Nothing spectacular of course... but I got a lot of mails or comments about this title. You know now why I did it... it's not Steven's opinion he likes PLSQL and .NET, of course NOT ;-)

To avoid problems or comments in the future I changed the title to a normal one you could expect.

The website got in the meanwhile some small updates. Nothing spectacular, just some improvements Bryn asked.
For ex.: "Can we get an estimate of the amount of PL/SQL they have (both no. of compilation units and no. of source code lines)."
Implementation: On the site you'll see two new fields: Estimated PL/SQL code volume: Lines [ ] Programs [ ]


And finally about the picture... that's Steven (when he was a bit younger)!

Wednesday, September 19, 2007

Announcement: 2nd European Apex Training Days (EATD)


Following the success of our recent European Application Express training days in Brussels, we have set the date and location for our next APEX Evangelists European Training Days Event.

The event will be a 3-day advanced Application Express course (agenda coming soon) and like our previous event will rely heavily on lots of live demos and real world examples and scenarios.

We will need to limit numbers, since once the audience size grows beyond a certain point it becomes more time-consuming to respond to questions and we cannot be as ‘interactive’ as we like to be (which from the feedback from the previous even was one of the things that people felt set us apart from other training events they’d attended).

So, if you’re looking for some advanced Application express training, from people who *really* use it day-in day-out and can help to answer those real-world questions you have, then sign up!

Note that, whilst we are only doing a few of these ‘open’ trainings a year, we are of course able to perform on-site training specifically for your company. So feel free to contact us via the APEX Evangelists site.

You can register directly for the London 2008 training by using this link.