Let us know something about PL/SQL.
Consider an example related to accounting, in which tax on salary is to be calculated. There exists a table named employee (in which the account details are stored, say, emp_id,name and salary). Now, on using conventional programming approach, the programmer will need to make a cursor (for which, JDBC-ODBC bridge,DSN etc), through which records of employee table would be extracted, necessary calculation would be performed on extracted data and the generated result i.e. tax would be inserted back in some table say Tax. And all this will be done by programmer.
Procedural Language/Structured Query Language or PL/SQL is that part of RDBMS at which we do not pay much attention while studying. However, when it comes to develop project, it is the most important part and cannot be ignored. Using PL/SQL while designing database reduces the programmer's effort exponentially. Question arises, how? And the simple answer is, 'A major portion of programming dealing with DB is finished in the database designing phase.'
Let us consider a scenario, through which we can understand the importance of using PL/SQL.
Consider an example related to accounting, in which tax on salary is to be calculated. There exists a table named employee (in which the account details are stored, say, emp_id,name and salary). Now, on using conventional programming approach, the programmer will need to make a cursor (for which, JDBC-ODBC bridge,DSN etc), through which records of employee table would be extracted, necessary calculation would be performed on extracted data and the generated result i.e. tax would be inserted back in some table say Tax. And all this will be done by programmer.
Now let us have a look at approach in which PL/SQL is involved.While designing DB, few procedures would be made(say, calculateTax and populateTax), in which necessary calculations would be done and later, simply procedures would be called. Here the point to be observed is, making procedures and implementing necessary calculations in them, calling them, all these activities are being performed at DBMS and the programmer is far away from this.
Here's the code for above example.(according to MySQL)
Now let us look at few program units of PL/SQL
- Procedures
- Functions
- Triggers
- Function returns a value while procedure do not.
- Function can be used in SQL statements while procedures cannot.
This was a brief introduction about PL/SQL.
Please correct me if I got something wrong.
No comments:
Post a Comment