Re: Java vs PLSQL

From: John Russell <johnrussell10_at_home.com>
Date: Sat, 16 Jun 2001 22:48:38 GMT
Message-ID: <k1nnito1t3bf3h5l3s6tst1hdv4p7le6bt_at_4ax.com>


[Quoted] On Sat, 16 Jun 2001 20:54:15 +0200, Joachim Pense <joachim.pense_at_t-online.de> wrote:

>Alexander Chupin wrote:
>
>> Somebody told me that since Oracle 9i has been
>> introduced there is a recommendation from Oracle
>> do not use PLSQL for HTML pages generation anymore. Instead it we should
>> use Java or JSP. I want to hear opinion of people, which
>> have experience or made some performance test.
>
>In my opinion, writing any code that does string processing (e.g. web
>page generation or dynamic SQL) in PL/SQL is painful. I tried that
>once or twice and quickly went back to Perl.
>
>Joachim

I believe there is better/faster Java and JSP in 9i. Of course there is also better/faster PL/SQL. :-)

Regarding Perl vs, PL/SQL... In my experience, PL/SQL programs follow the same general structure for database processing as Perl programs do for text processing. So I find it very easy to switch between the two and reuse techniques. In Perl, it's

open file
read entire contents into array
for each line { search/replace; conditionally print line to screen or output file }

With PL/SQL, it's

open cursor (I usually use implicit cursors with FOR loops) for each result row { concatenate literals, columns, and function results ; print line to web page }

I don't do a great deal of text processing in PL/SQL, but for web pages I haven't found a big need for this. Usually concatenation and basic search/replace with no regexps are all that I require, and PL/SQL does those fine. PL/SQL is gaining Internet-oriented packages for things like encoding URLs and CGI-style name-value pairs.

With PL/SQL server pages (new in 8.1.6), you don't have to HTP.PRINT each line or bother with || and doubled-up quotes. You can code the file like a regular HTML page and toss in declarations, function return values, and control structures wherever needed enclosed in <% %>. This gets compiled to a stored procedure that does all the HTP.PRINT calls behind the scenes. A regular stored procedure can call a PSP (e.g. to include a common banner or sidebar on every page) and vice versa (e.g. to have a nice-looking page that includes a big database-generated block in the middle).

PL/SQL-generated web pages buffer all the output until the stored procedure is finished, then send everything to the browser. This is the only performance gotcha I've encountered. If you have some static content followed by the output of a long-running query, or construct a page using the output of several queries, the browser doesn't display a partial page while waiting for a query to finish.

John

--
Got an Oracle database question?
Try the search engine for the database docs at:
http://tahiti.oracle.com/
Received on Sun Jun 17 2001 - 00:48:38 CEST

Original text of this message