Home arrow Site Administration arrow Page 9 - Database Essentials

So That's Where All My Money Went... - Administration

Are you new to the wonderful world of databases? Confused by thesudden flood of technical jargon? Don't know the difference between a"trigger" and a "stored procedure", a "join" and a "subquery"? Look nofurther - the solution is right here!

  1. Database Essentials
  2. The Customer Is King
  3. Relationships
  4. Invasion Of The Foreign Keys
  5. Looking Up The Index
  6. Joined At The Hip
  7. Room With A View
  8. Pulling The Trigger
  9. So That's Where All My Money Went...
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 7
February 26, 2001

print this article


Database servers like Oracle also come with the ability to create "stored procedures" at the database layer - essentially, blocks of program code that can be executed at will, similar to the user-defined functions you can write in Perl or PHP.

The advantage of creating such stored program blocks at the database level is very simple, and very powerful - all applications which interact with the database can use these stored procedures, thereby reducing the time and effort required for application development. For example, if your application uses both Perl and PHP to communicate with a database, you would need to write procedures to accomplish the same tasks in both languages. By writing the procedure once and moving it to the common point of intersection - the database - application code becomes easier to write and maintain, and your time is used more effectively.

For example, here's a simple procedure, again from Oracle's PL/SQL language, which would reduce a specified customer's balance by 10%:

sql> CREATE PROCEDURE reducebalance (ID IN int, Balance IN int) AS BEGIN UPDATE balance SET AccountBalance=(Balance-Balance/10) WHERE CustomerID=ID END;

This procedure would accept a CustomerID and AccountBalance as parameters, and use this information to update a database entry in the table. As you can see, this is similar to a Perl or PHP function, which accepts values as parameters and performs actions based on those parameters (incidentally, you can also have the stored procedure return a value to you, based on the results of code execution - just like a regular function)

And that's about it. I hope you found this information useful, and that it served as a good starting point for your journey into the world of databases. If you're interested in learning more, you should also take a look at the "Speaking SQL" tutorials at http://www.devshed.com/c/a/MySQL/Speaking-SQL-part-1/ , and at the very interesting article on database normalization at http://www.devshed.com/c/a/MySQL/An-Introduction-to-Database-Normalization/ . If you want to get right into building data-driven Web applications, take a look at PHP at http://www.php.net/, or check out the PHP 101 series of tutorials at http://www.devshed.com/c/b/PHP/ . See you soon!

>>> More Site Administration Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: