Wednesday, 10 October 2012

what is the difference between declarative and imperative programming

In other words, Non-Procedural (declarative) and Procedural (imperitive):


Declarative programming is where you say what you want without having to say how to do it. For example, SQL is more declarative than procedural, because the queries don't specify steps to produce the result. Eg: SQL, XSLT, HTML etc
 With procedural programming, you have to specify exact steps to get the result. Eg; C, C++, Java, .net and many other.

With imperative programming, you tell the compiler what you want to happen, step by step.
For example, let's start with this collection, and choose the odd numbers:
List<int> collection = new List<int> { 1, 2, 3, 4, 5 };
With imperative programming, we'd step through this, and decide what we want:
List<int> results = new List<int>();
foreach(var num in collection)
{
    if (num % 2 != 0)
          results.Add(num);
}
Here, we're saying:
  1. Create a result collection
  2. Step through each number in the collection
  3. Check the number, if it's odd, add it to the results
With declarative programming, on the other hand, you write code that describes what you want, but not necessarily how to get it (declare your desired results, but not the step-by-step):
var results = collection.Where( num => num % 2 != 0);
Here, we're saying "Give us everything where it's odd", not "Step through the collection. Check this item, if it's odd, add it to a result collection." 


Differences between SQL and PL-SQL

SQL is a query language that allows you to issue a single query or execute a single insert/update/delete.
PL-SQL is Oracle's "Programming Langugage" SQL, which allows you to write a full program (loops, variables, etc.) to accomplish multiple selects/inserts/updates/deletes.

Regards
Rajan Bansal

Saturday, 6 October 2012

What is DELIMITER //


Hi,
It changes the statement delimiter from ; to //. This is so you can write ; in your trigger definition without the MySQL client misinterpreting that as meaning you're done with it.
Note that when changing back, it's DELIMITER ;, not DELIMITER; as I've seen people try to do.
source: stackoverflow.com