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!
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)