Wednesday, 9 December 2015

What is difference between Temp Table and Hash Table in SQL?

        The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

        Temporary tables are a useful tool in SQL Server provided to allow for short term use of data. There are two types of temporary table in SQL Server,

  • Local temporary table
  • Global temporary table

        Local temporary tables are only available to the current connection to the database for the current user and are dropped when the connection is closed. Global temporary tables are available to any connection once created, and are dropped when the last connection using it is closed.

        Both types of temporary tables are created in the system database tempdb.

What are Cursors?

What are Cursors?

          A cursor is a temporary work area created in the system memory when a SQL statement is executed. A cursor contains information on a select statement and the rows of data accessed by it.
          This temporary work area is used to store the data retrieved from the database, and manipulate this data. A cursor can hold more than one row, but can process only one row at a time. The set of rows the cursor holds is called the active set.

There are two types of cursors in PL/SQL:

  •      Implicit cursors:

          These are created by default when DML statements like, INSERT, UPDATE, and DELETE statements are executed. They are also created when a SELECT statement that returns just one row is executed. 

  •     Explicit cursors:

          They must be created when you are executing a SELECT statement that returns more than one row. Even though the cursor stores multiple records, only one record can be processed at a time, which is called as current row. When you fetch a row the current row position moves to next row.

            Both implicit and explicit cursors have the same functionality, but they differ in the way they are accessed.

What is the difference between convert.ToInt32 and int32.Parse ?

string convertToInt = "78";
string nullString = null;
string maxValue = "93333332222222224444442222222222";
string formatException = "99.99";

int ParseResult;

Int32.Parsh(String Str)
Convert.ToInt32(String Str)
Int32.Parse(str) method converts the string representation of a number to integer 32 bit.
Exe.
// It will perfectly convert interger
parseResult= int.Parse(convertToInt);

Convert.ToInt32(str) method converts the string representation of a number to integer 32 bit.
Exe.
//It will perfectly convert integer
parseResult= Convert.ToInt32(convertToInt);

when str is a null reference it will throw ArgumentNullException.
Exe.
// It will raise Argument Null Exception
parseResult= int.Parse(nullString);

when str is a null reference it will return 0 rather than throw ArgumentNullException.
Exe.
//It will ouput as 0 if Null string is there
parseResult= Convert.ToInt32(nullString);

if str is other than integer value it will throw FormatException.
Exe.
//It will raise Format Exception
parseResult= int.Parse(formatException);

if str is other than integer value it will throw FormatException.
Exe.
//It will raise Format Exception
parseResult= Convert.ToInt32(formatException);

when str represents a number less than MinValue or greater than MaxValue it will throw OverflowException.
Exe.
//It willl raise Over Flow Exception
parseResult= int.Parse(maxValue);

when str represents a number less than MinValue or greater than MaxValue it will throw OverflowException.
Exe.
//It will raise Over Flow Exception
parseResult= Convert.ToInt32(maxValue);


What is the DOM in Javascript/jquery ?

          The DOM is basically an API you use to interface the document with, and is available in many languages as a library ( JS is one of those languages ). The browser converts all the HTML in your web page to a tree based on the nesting. Pop open Firebug and look at the HTML structure. That is the tree I'm talking about.

If you want to change any HTML you can interact with the DOM API in order to do so.

<html>
 <head><script src="Tempfile.js"></script></head>
 <body>blah</body>
</html>
In Tempfile.js I can reference the body using:

onload = function() {
    document.getElementsByTagName('body')[0].style.display='none';
}
The getElementsByTagName is a method of the document object. I am manipulating the body element, which is a DOM element. If I wanted to traverse and find say, a span I can do this:

onload = function() {
 var els = document.getElementsByTagName('*');
 for ( var i = els.length; i--; ) {
    if ( els[i].nodeType == 1 && els[i].nodeName.toLowerCase() == 'span' ) {
       alert( els[i] )
    }
 }
}
I am traversing the nodeList given back by getElementsByTagName in the snippet above, and looking for a span based on the nodeName property.

what is lambda expression in linq c#?

          The term of ‘Lambda expression’ has derived its name from ‘lambda’ calculus which in turn is a mathematical notation applied for defining functions.
          Lambda expressions as a LINQ equation’s executable part translate logic in a way at run time so it can pass on to the data source conveniently.
         However, lambda expressions are not just limited to find application in LINQ only.

These expressions are expressed by the following syntax:

         (input parameters) => expression or statement block

         Below is an example of lambda expression

          y => y * y

         The above expression specifies a parameter named y and that value of y is squared. However, it is not possible to execute a lambda expression in this form. Example of a lambda expression in C# is shown below.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LambdaExa
{
  class Program
  {
     delegate int del(int i);
     static void Main(string[] args)
     {
        del myDelegate = y => y * y;
        int j = myDelegate(5);
        Console.WriteLine(j);
        Console.ReadLine();
     }
  }
}