Non vendor specific paging query

As we know all database vendors deal pagination of result accordingly their product specification

Example:

  • MS-SQL 2000, 2005, 2008 use top, row_number() keywords
  • MySQL & Postgres use limit , offset keywords
  • Oracle uses rownum
  • etc…
Question: Can we create a common paging query run on all vendors available in the market?
Answer is yes.
Explanation:

Example:

If we have table T1 fields id , t1, t2 ,t3 , t4, t5

 

Without Filter Clause


SELECT  * FROM

( SELECT
(SELECT  COUNT(id)  FROM test  WHERE id <= A.id)   AS index1, t1, t2, t3, t4, t5
FROM  T1  AS  A)  AS  result

WHERE result.index1 >= 1  AND  result.index1<=5

 

With Filter Clause


SELECT * FROM

( SELECT
(SELECT  COUNT(id)  FROM test  WHERE id <= A.id)   AS index1, t1, t2, t3, t4, t5
FROM T1  AS  A  WHERE A.t1 = false AND A.t2 > 200

)  AS  result

WHERE  result.index1 >= 1  AND  result.index1<=5


C# Int16, Int32, and Int64 Types

You want to see what the Int16Int32, and Int64 types in the C# language are equivalent to. Typically, C# programmers prefer the C-style numeric types, which are easier to read. In this example program, we demonstrate that the Int16, Int32, and Int64 types are equivalent to more commonly used types.

Int16 -> short
Int32 -> int  
Int64 -> long

Example

This simple program simply declares Int16, Int32, and Int64 variable instances, and then prints the Type object corresponding to them in the runtime. Then, it does the same exact thing for the short, int, and long types. The program’s output shows that Int16 is equal to short, Int32 is equal to int, and Int64 is equal to long in the runtime.

Program that uses Int16, Int32, Int64 types [C#]

using System;

class Program
{
    static void Main()
    {
	{
	    Int16 a = 1;
	    Int32 b = 1;
	    Int64 c = 1;

	    Console.WriteLine(a.GetType());
	    Console.WriteLine(b.GetType());
	    Console.WriteLine(c.GetType());
	}
	{
	    short a = 1;
	    int b = 1;
	    long c = 1;

	    Console.WriteLine(a.GetType());
	    Console.WriteLine(b.GetType());
	    Console.WriteLine(c.GetType());
	}
    }
}

Output

System.Int16
System.Int32
System.Int64
System.Int16
System.Int32
System.Int64

Which should I use?

So should you prefer Int16 to short, Int32 to int, or Int64 to long? Not usually; conventions in most C# programs prefer the short, int, and long types. However, in some programs where the number of bytes in the types is most important, you might prefer Int16, Int32, or Int64. In methods where you use int variables, it is a poor choice to use Int32 variables instead, as int is very standard.