Oracle Application Express (APEX) and ASP.NET

I am digging around of the benefit using Oracle Application Express (APEX) compare to ASP.NET in building my website for current job needs. Because I am getting the direction from superior to study and start using APEX instead of ASP.NET for my web development.

At first, when I look into Oracle website about APEX, I can imagine how easy my work will be. I mean the website will be easy to create, offer easy connectivity to Oracle database but still, I will need to connect my website to MSSQL server to store data input by user.

Anyway,let look at what other people has say about Oracle Application Express (APEX) versus ASP.NET (Visual Studio).

APEX is a framework that uses the database and PL/SQL to produce web pages. If you can figure out what the output to the browser will need to be you can create it in APEX. If you find any part of the framework inhibiting you can write PL/SQL procedures and expose them to the web server directly but still take advantage of the security, logging, session state, etc that the APEX system manages for you.

You should know PL/SQL, SQL, HTML, JavaScript and CSS. Sure the interface looks like a big data entry application but the data you enter will mostly be code snippets in each of these languages.

It scales as well as the database does. It typically uses Apache as a web server but is only used to serve static files and pass requests back to the database, where the web pages are created by the PL/SQL code in the APEX schema. You can use AJAX to minimize the size of the traffic traveling up and down the pipe. You can set caching for specific items, lists, page regions, pages, etc. 

Since most things are pretty simple to do with the framework, naturally there will be some things that are a little more complicated to do within the framework. The color coding example given above might be something you do with CSS or maybe you would need to turn to print statements to produce the output you need. The thing is to learn the how the framework makes life easier and then when you hit a limit you can easily resort to more direct methods.

Coming from VB.Net you will miss the step by step debugging and the drag and drop. You will never miss the fact that some part of the page lifecycle will do a bind and reset the values you bound to an object in another part of the page.

This fella have a huge migration project. What has he say about APEX?

I am involved in a huge project to migrate a 5000 module Oracle Forms application to Apex. This is an extreme use of Apex, but it’s working just fine. It is a complete myth that Apex is suitable only for small internal apps built by DBAs, interns or end users: it is certainly suitable for those too (and more suitable than most other tools), but it can also be used to build extremely sophisticated applications. 

To build a sophisticated application (rather than a default out-of-the box Apex one) you will need someone on the team with Javascript skills, and someone with CSS skills. But most developers will just need PL/SQL initially. 

Is it scalable? Yes: probably more scalable than most other solutions! Apex adds very little overhead to the database server, and only the most minimal of application servers is required. “Facebook size”? I don’t know for sure but I don’t see why not, assuming you have an Oracle database on a machine large and powerful enough to handle “Facebook size” data and transaction volumes. Like any Oracle project, scalability is impeded mostly by bad database designs and poorly written SQL, not by the tool.

The good side of APEX has been discussed too.

The Good

  • Incredibly easy to generate a respectable web app with basic CRUD data entry, simple reporting and populate it with data. If you’re the IT guy who’s been tasked with consolidating a company’s mess of Excel/Access dbs into a central DB/web environment then you should take a look at APEX, it very well suited for this task. If you expect the scope to grow to something of even moderate complexity then I would move straight to a more flexible framework.
  • If you are a DBA/PLSQL guru but have no experience with traditional web development you’ll be well prepped to expose existing business logic in a web app without stuffing around with HTML/CSS/JavaScript if you dont want to.
  • APEX support forum has a ton of info and is well staffed by APEX devs.

Take a look into the bad site of APEX compare to ASP.NET.

The Bad

  • My experience with Apex began to go downhill when apps moved beyond CRUD data entry and required more dynamic and event driven behaviours.
  • The web based GUI is not cool. Debugging is painful.
  • When you (inevitably) need to do anything outside the limited scope of the framework, you’ll have to get your hands dirty with PL/SQL. Writing business logic against the database is fine, but generating HTML from PL/SQL procedures felt uncomfortably archaic in 2007.
  • Given the large number of sneaky places you can hide page and redirection logic, the program flow is both difficult to visualise and not naturally conducive to modular, separable and reusable code. OOP developers will be not be impressed. It’s possible to have well structured maintainable applications with APEX but its harder than it should be. This is worlds away from MVC.
  • Unacceptable number of framework bugs in the versions I used. I’d hope this has improved with recent versions, but the paradigm of integrating the IDE into the APEX platform itself caused me some of the darkest, soul destroying debugging sessions of my life. As an example, I was trying to reproduce an intermittent bug that would cause a user to lose their session data. Using the session information popup I saw that occasionally the session data would change when it shouldnt have. I spent 2 days trying to find the error in my code with no luck. Near delirious, I noticed by pure chance that I could reproduce errorous session data in the debug window but the application itself wouldnt go into an error state. My heart sunk when I realised what might be happening. Oracle later confirmed that I’d found a bug in APEX that caused the session information window to intermittently show me data from a prior session. I’d wasted 2 days debugging a session related bug with a buggy session debug window. That was the last Apex app I built.
  • PL/SQL is not and will never be the Next Big Thing in web development. After working with APEX for a while I realised it wasnt going to make me a better web developer. Mastering APEX is really about PL/SQL. Thats fine if you plan to focus your career on Oracle technology, just be aware that APEX is so tangential to the direction of mainstream web technologies that the portable set of skills you can take from APEX to other web frameworks is minimal.

ASP.net how to execute query to Oracle using Button click

I would like to share a simple code which currently I am doing. This is a very basic application you may design for your website and require a database connection to Oracle databases.
First, lets go to the design of it. This is truely very useful for beginner like me especially you do not know where to start with. I am using Microsoft Visual Studio 2012 for Web to design my application website.

Second, talk about the Oracle connection string. I have quite sometime searching for correct oracle connection string that works (on my machine at least). You may copied it over, hopefully it will works on you too. Please change where necessary in the string follow your server configuration and setting.

“Data Source=(DESCRIPTION=” _
+ “(ADDRESS_LIST=” _
+ “(LOAD_BALANCE=YES)” _
+ “(FAILOVER=YES)” _
+ “(ADDRESS=(PROTOCOL=tcp)(HOST=YOUR_HOST_NAME)(PORT=YOUR_PORT))” _
+ “(ADDRESS=(PROTOCOL=tcp)(HOST=YOUR_HOST_NAME)(PORT=YOUR_PORT))” _
+ “)” _
+ “(CONNECT_DATA=” _
+ “(SERVICE_NAME=YOUR_SERVICE_NAME)” _
+ “)” _
+ “);” _

+ “User ID=YOUR_USER_ID;Password=YOUR_PASSWORD;” 

Now, when you double click on Button from the project, it will bring you to the new coding page. This file is normally ended with *.vb filename. Here will be the location to paste the Oracle connection string as pasted above. Below is how the code will be looks alike:

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ‘Your Oracle connection Setting
        Dim strConnString As String = “Data Source=(DESCRIPTION=” _
                                    + “(ADDRESS_LIST=” _
                                    + “(LOAD_BALANCE=YES)” _
                                    + “(FAILOVER=YES)” _
                                    + “(ADDRESS=(PROTOCOL=tcp)(HOST=YOUR_HOST_NAME)(PORT=YOUR_PORT))” _
                                    + “(ADDRESS=(PROTOCOL=tcp)(HOST=YOUR_HOST_NAME)(PORT=YOUR_PORT))” _
                                    + “)” _
                                    + “(CONNECT_DATA=” _
                                    + “(SERVICE_NAME=YOUR_SERVICE_NAME)” _
                                    + “)” _
                                    + “);” _
                                    + “User ID=YOUR_USER_ID;Password=YOUR_PASSWORD;” 
        ‘Your sql statement goes here
        Dim strQuery As String = “SELECT cus_name from  tbl_cus where cus_ID = ‘” + TextBox1.Text + “‘”
        Dim con As New OracleConnection(strConnString)
        Dim cmd As New OracleCommand()
        cmd.CommandType = CommandType.Text
        cmd.CommandText = strQuery
        cmd.Connection = con
        Try
            con.Open()
            Dim sdr As OracleDataReader = cmd.ExecuteReader()
            While sdr.Read()
                ‘Here will be your output result
                Label1.Text = “Item”
            End While
        Catch ex As Exception
            Throw ex
        Finally
            con.Close()
            con.Dispose()
        End Try

    End Sub

Above code working just fine when I debug the project and click the button. This may help you to explore more on query to Oracle database for your project.