« Processing Multiple Row Check Boxes - Part I | Main | Processing Multiple Row Check Boxes - Part II »

August 31, 2005

Welcome to the DHTML, PL/SQL, and Javascript Coding Category

Welcome! This category will be used to demonstrate the blending of DHTML, PL/SQL, and Javascript for some pretty slick web applications. Here at WOU we use PL/SQL Developer, and, currently, an Oracle 9i database. It is a great platform for web development, but there are very few resources that show you how to create applications incorporating all of these technologies into one package.

And I do mean "package". All of our applications consist of one or more packages stored on our Oracle database. When combined with an Apache web server, the database has the ability to serve up web pages from these packages! If you don't think that is really cool, well, I can't help you.

I am going to assume you know the basics of writing an Oracle package using PL/SQL, that you are familiar with basic web coding in HTML and DHMTL, and that you at least know what Javascript is. If you have questions about the basics in any of these areas, give me a post, and I'll try and help you out.

The most trying aspect of this coding environment is moving back and forth between them in your package. For example, let's say we have a table "mike.test_web" (mike is the schema, or owner, test_web is the name of the table). test_web has two columns, msg, a varchar2(40), with some text in it (like "Hello, world."), and num, a number column, which is a primary key, like 1.

So, if I want to display the message in a browser window, here is what my package would look like:

Create or replace package mike.test_msg is

procedure display_msg is

vtext varchar2(40);

begin

select msg into vtext
from mike.test_web
where num = 1;

htp.print('
H2 Yes indeed, this really works!/H2>br>
table>tr>td>'||vtext||'/td>/tr>/table>
'); end display_msg;

end test_msg;

I had to leave off all the "<"s so the blog server did not interpret the HTML code, but you get the idea. Don't forget your header file for the package, and compile. Then you can call your package from a browser window.
(NOTE: Your database and web browser must be configured to accomplish this task. It needs DAD's and such which are beyond the scope of this entry.)

Here it is:

You can see the web server stuff, then the package name and procedure name in the URL. Pretty cool!

Note the htp.print(' opening "tag" and '); closing "tag". This is how you move between PL/SQL code and the web code. It is pretty easy here, but it quickly gets complicated! What can you make of this line: td>'||vtext||'/td> ?? What is going on here?
If you can see that you are calling a PL/SQL variable from within your HTML, you've got it!

You should be thinking of all the possibilities this opens up for you. You can add in any HTML or DHTML (and soon PHP!) or Javascript to make applications that are dynamic and very nice looking....

Posted by rossm at August 31, 2005 10:36 AM

Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?