Home > Oracle Tips > Oracle Database Administrator > SQL generation vs. Oracle stored procedures
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

SQL generation vs. Oracle stored procedures


ITKnowledge Exchange
02.24.2005
Rating: -4.29- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


SQL generation vs. Oracle stored procedures An ITKnowledge Exchange member had a question about which option to choose: SQL generation or stored procedures. Fellow Oracle techies jumped in on the conversation and helped Steve. Here is a portion of the conversation. Read the rest of the thread.

"stevewaltz" asked:
We are attempting to adopt programming standards that would mandate the use of stored procedures in our Oracle 8i and 9i databases for data access. Application developers prefer to take advantage of the SQL generation capabilities of IBM's WebSphere and Compuware's Uniface. DBAs feel the security, performance, maintainability, visibility and sharability of procedures stored in the databases outweigh the ease of development with generated SQL. Any related experiences and advice would be appreciated.

"GEESTER" responded:
This is a classic developmental question, and any contribution is always just a small view of the ongoing debate; external factors often play a larger part. As a general rule, it is true that the closer you are to the database, the easier it is to enforce business rules. It is easier to have a constraint go unviolated if it is defined at the table level rather than at the application level. Stored procedures also afford you centralized security. There are lost of resources you can look up that describe this approach. I think it really boils down to answering a few questions:

  1. Do you have the DBA resources do carry out this work now, and will those resources be there once the project goes live? My guess is you'll have a production DBA but not a development one, whilst you'll always need the J2EE developer. You also be tied to Oracle -- not a bad choice, but tied nonetheless.

  2. Do your tools provide adequate and well-optimized code? If WebSphere generates good SQL and doesn't parse 100 times per page, you can use it, but I've found that lots of tuning time is necessary to remove issues that stem from having 100 SQL for 100 lines of display.

  3. Are your developers as good at writing SQL as your DBAs are? Some are; some aren't. Experienced RDBSM developers are often better than DBAs, but again this goes back to the resource ratio you have and how many developers versus DBAs you have. It's pointless putting loads of logic in the DB if you have to teach PLSQL to 20 J2EE staff.
The nicest approach I've come across is an instance in which all the SQL stored in XML files. That way both developers and DBAs can read them easily and spot issues quickly. I would then leave the stored procedure aspect to areas where large amounts of data are worked on and network traffic would be harmful. The RDBMS resources can then be used for constraints, indexes, tuning and monitoring SQL, efficient dataloads and that is usually enough to keep them busy. The important thing is that your database is designed well enough so that regardless of the datasource, data remains clean and as close to the business rules as possible.

"FERENCMANTFELD" responded:
I concur 100% with the previous reply.

To add, PL/SQL is much more powerful than anything WebSphere or CA tools can churn out.

Yes, adopt a standard, but don't get fanatical about it; there are times to make valid exceptions to the rule.

Questions to ask:

  1. Does WebSphere have the ability to use the database-specific functionality? Oracle has Analytic functions, implementation of TRANSLATE or subquery factoring using WITH clause, Ref Cursors, custom types, DBMS_% packages. The short answer is: in IBM's dreams!

  2. What will you do when you need some specific functionality to do something special in Oracle? An insurance company client of mine wanted a function that accepted an adviser's ID, and the function was to return the last appointment for the current month, with date and type, and the first appointment for the next month. This would have involved very complex SQL, but with PL/SQL, the function I wrote executed in 10 milliseconds, and it took me 10 minutes to write and test the function. My other option was a SQL-centric approach, which may have been rather expensive and involved many joins and possible performance concerns; I would have also had to worry about the skills of the production support staff to maintain the complex SQL once I was offsite.

  3. Can WebSphere generate the SQL required for hierarchical queries? For instance, consider CONNECT BY PRIOR, START WITH, ORDER SIBLINGS BY, NOCYCLE (10g). I'd offer the same answer.

  4. Can WebSphere/CA generate Oracle hints when hints are to be used? Perhaps, but probably not.
When you want a generic SQL generator (like Siebel, PeopleSoft and SAP do), you are dumbing down the database to the lowest common denominator, which means you are really using the database as a glorified dumb storage bin. The database is there to do powerful and meaningful processing, USE ITs!



Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

Oracle stored procedures
Stored procedure to autotransfer data between Oracle servers
Insufficient privileges error when creating stored procedure
ORA-01422 error when procedure returns more than one row
Calling procedure inside another procedure in anonymous block
Can I make a second connection to Oracle without losing the first?
How to create an index using a procedure in Oracle
Oracle updates Microsoft developer tools
Procedure compiles but does not execute
Tool in Oracle 10g to keep track of execution of queries
ORA-04082: NEW or OLD references not allowed in table level triggers

Oracle PL/SQL
Oracle's free SQL Developer adds database migration tool
Confused about Oracle certification exams
ORA-01422 error when procedure returns more than one row
Calling procedure inside another procedure in anonymous block
How to import comma-delimited text file to Oracle table
Oracle updates Microsoft developer tools
PLS-00103 errors
PL/SQL do's and don't's: Five questions with Steven Feuerstein
Definition of force view
ORA-04082: NEW or OLD references not allowed in table level triggers

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
stored procedure  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts