ODAC Assigning DBNull.Value to paramater

Here we go, null is not an instance of any type, it is an invalid reference.Whereas, System.DbNull.Value, is a valid reference to an instance of System.DbNull
that represents nonexistent (e.g. NULL) values in the database.

(System.DbNull is a singleton and System.DbNull.Value gives you a reference to the single instance of that class)

The keyword null represents an invalid reference. The class System.DbNull represents a nonexistent value in a database field.

// Assigning Null value to Procedure Parameter

OracleParameter pram_IN_1 = new OracleParameter("pPACKAGE_NAME", OracleDbType.Varchar2);
pram_IN_1.Direction = ParameterDirection.Input;
pram_IN_1.Value = strPackageName != null ? strPackageName : (object)DBNull.Value;
cmd.Parameters.Add(pram_IN_1);

//

TRUNCATE, DELETE and DROP

Data Definition Language (DDL) statements are used to define the database structure or schema.

Data Manipulation Language (DML) statements are used for managing data within schema objects.

DELETE

It is a DML statement; it is used to remove the data from the table.

It also generates REDO information and deleted data can be ROLLBACK

It provides the facility of conditional-based deletion, a WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed.

This operation will cause all DELETE triggers on the table to fire.

SQL> SELECT COUNT(*) FROM EMP;

COUNT(*)
----------
14

SQL> DELETE FROM EMP WHERE JOB = 'CLERK';

4 rows deleted.

SQL> COMMIT;

Commit complete.

SQL> SELECT COUNT(*) FROM EMP;

COUNT(*)
----------
10

After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it.

TRUNCATE

It is a DDL statement; it is used to removes all rows from a table permanently and cannot be rolled back.

TRUNCATE drops the storage held by the table. It is the faster command because it directly drops the storage (dropped storage can be use by this table again or some other table).

SQL> TRUNCATE TABLE EMP;

Table truncated.

SQL> SELECT COUNT(*) FROM EMP;

COUNT(*)
----------
0

In case of TRUNCATE,

  • Delete the contents only not the structure.
  • No Trigger get fired,
  • No WHERE clause used
  • No undo space used.

DROP

This is the DDL statement; it is used to removes a table from the database.

It removes the entire rows and information along with structure. It also removes all information about the table from data dictionary

All the tables’ rows, indexes and privileges will also be removed.

SQL> DROP TABLE EMP;

Table dropped.

SQL> SELECT * FROM EMP;

SELECT * FROM EMP
*
ERROR at line 1:
ORA-00942: table or view does not exist

In case of DROP

  • No Trigger get fired.

Note: We can not recover the table before Oracle 10g. But Oracle 10g provides the command to recover it by using the command (FLASHBACK), From Oracle 10g a table can be “undropped”. Example:

SQL> FLASHBACK TABLE EMP TO BEFORE DROP;

Flashback complete.

Discussion

When you type DELETE all the data get copied into the Rollback TABLESPACE first and then delete operation get performed. That’s why when you type ROLLBACK after deleting a table; you can get back the data (The system gets it for you from the Rollback TABLESPACE). All this process takes time but when you type TRUNCATE, it removes data directly without copying it into the Rollback TABLESPACE. TRUNCATE is faster. Once you TRUNCATE you can’t get back the data.

DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command.

DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.

Reference: http://www.orafaq.com/faq/difference_between_truncate_delete_and_drop_commands


COMMIT, ROLLBACK and SAVEPOINT

TRANSACTION

A transaction is a set of SQL statements which Oracle treats as a Single Unit i.e. all the statements should execute successfully or none of the statements should execute.

Transaction Control Language (TCL)

Transaction Control Language (TCL) statements manage changes made by Data Manipulation Language (DML) statements.It allows statements to be grouped together into logical transactions

To control transactions Oracle does not made permanent any DML statements unless you commit it. If you don’t commit the transaction and power goes off or system crashes then the transaction is roll backed.

TCL Statements available in Oracle are

COMMIT : Make changes done in transaction permanent.

ROLLBACK: Rollbacks the state of database to the last commit point.

SAVEPOINT: Use to specify a point in transaction to which later you can rollback.

COMMIT

To make the changes done in a transaction permanent issues the COMMIT statement.

The syntax of COMMIT Statement is
COMMIT [WORK] [COMMENT ‘Your Comments’];

WORK: is optional.
COMMENT: is also optional; specify this if you want to identify this transaction in data dictionary DBA_2PC_PENDING.

Example:

INSERT INTO EMP (EMPNO, ENAME, SAL) VALUES (101,’ABID’, 2300);
COMMIT;

ROLLBACK

To rollback the changes done in a transaction give rollback statement. Rollback restore the state of the database to the last commit point.

Example:

DELETE FROM EMP;
ROLLBACK; --undo the changes

SAVEPOINT

Specify a point in a transaction to which later you can roll back.

Example:

INSERT INTO EMP (EMPNO,ENAME,SAL) VALUES (109,’SAMI’,3000);
SAVEPOINT A;
INSERT INTO DEPT VALUES (10,’SALES’,’HYD’);
SAVEPOINT B;
INSERT INTO SALGRADE VALUES (‘III’,9000,12000);

Now if you give

ROLLBACK TO A;

Then row from SALGRADE table and DEPT will be roll backed. Now you can COMMIT the row inserted into EMP table or ROLLBACK the transaction.

If you give

ROLLBACK TO B;

Then row inserted into SALGRADE table will be roll backed. Now you can COMMIT the row inserted into DEPT table and EMP table or ROLLBACK to SAVEPOINT A or completely roll backed the transaction.

If you give

ROLLBACK;

Then the whole transactions are roll backed.

If you give

COMMIT;

Then the whole transaction is committed and all SAVEPOINT are removed.

Reference: http://www.oracle-dba-online.com/sql/commit_rollback_savepoint.htm


Oracle Timestamp to Date Conversion

Some simple ways for conversion of Oracle Timestamp to Date.

/* PL-SQL */


SQL> SELECT TO_CHAR (SYSTIMESTAMP, 'YYYY-MON-DD HH24:MI:SS') AS TS FROM DUAL ;

TS
----------------------------
2012-JAN-24 19:06:18

SQL> SELECT TO_DATE (TO_CHAR (SYSTIMESTAMP, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS' ) AS DT FROM DUAL ;

DT
----------------
24-JAN-12


SQL> SELECT SYSDATE DT FROM DUAL ;
 
DT
---------
24-JAN-12
 
SQL> SELECT SYSTIMESTAMP TS FROM DUAL;
 
TS
-------------------------------------------------------
24-JAN-12 07.08.02.283311000 PM +05:00
 
SQL> SELECT CAST(SYSTIMESTAMP AS DATE) DT FROM DUAL;
 
DT
--------------
24-JAN-12
 
SQL> SELECT TRUNC(SYSTIMESTAMP) DT FROM DUAL;
 
DT
--------------
24-JAN-12


C#.Net Common Variable Types

The chart below details most of the common variable types, as well as their size and possible values.

C# Type .Net Framework (System) type Signed? Bytes Occupied Possible Values
sbyte System.Sbyte Yes 1 -128 to 127
short System.Int16 Yes 2 -32768 to 32767
int System.Int32 Yes 4 -2147483648 to 2147483647
long System.Int64 Yes 8 -9223372036854775808 to 9223372036854775807
byte System.Byte No 1 0 to 255
ushort System.Uint16 No 2 0 to 65535
uint System.UInt32 No 4 0 to 4294967295
ulong System.Uint64 No 8 0 to 18446744073709551615
float System.Single Yes 4 Approximately ±1.5 x 10-45 to ±3.4 x 1038 with 7 significant figures
double System.Double Yes 8 Approximately ±5.0 x 10-324 to ±1.7 x 10308 with 15 or 16 significant figures
decimal System.Decimal Yes 12 Approximately ±1.0 x 10-28 to ±7.9 x 1028 with 28 or 29 significant figures
char System.Char N/A 2 Any Unicode character (16 bit)
bool System.Boolean N/A 1 / 2 true or false

Ultimate Love Letter by Programmer

Sweetheart ,

I’ve seen you yesterday while surfing on the local train platform and realized that you are the only site I was browsing for. For a long time I’ve been lonely; this has been the bug in my life and you can be a real debugger for me now.

My life is an uncompiled program without you, which never produces an executable code and hence is useless.

You are not only beautiful by face but all your ActiveX controls are attractive as well.

Your smile is so delightful; it encourages me and gives me power equal to thousands of mainframes processing power.

When you looked at me last evening, I felt like all my program modules are running smoothly and giving expected results. /*which I never experienced before.*/

With this letter, I just want to convey to you that if we are linked together, I’ll provide you all objects & libraries necessary for a human being to live an error free life.

I anticipate that nobody has already logged in to your database so that my connect script will fail.

And its all but certain that if

this happened to me, my system will crash beyond recovery.

Kindly interpret this letter properly and grant me all privileges of your inbox. Error free…

Regards,

Software Programmer

Today This company
Tomorrow That Company
But always want Ur Company!

(Signature the best part of letter)

Source: I got this letter through email from my friend


Making F1 Google Search for Visual Studio

Start Visual Studio 2008 OR Visual Studio 2010

  1. From Menu bar select “Tools->Macros->New Macro Project
  2. Name the project “MyGoogleSearch
  3. Rename the default Module1 to “GoogleSearch” (right click on the module name in the left hand pan, select “Rename”)
  4. Copy following code and paste into the module body

Sub doGoogleSearch()

    Dim url As String
    Dim search As TextSelection = DTE.ActiveDocument.Selection()

    If search.Text <> "" Then
        url = "www.google.com/search?q=" + search.Text
    Else
        url = "www.google.com/"
    End If

    ' Run Command: "firefox.exe -new-tab http://www.google.com"

    Dim cmd As System.Diagnostics.Process = New System.Diagnostics.Process()

    cmd.StartInfo.Arguments += " -new-tab " + url

    cmd.StartInfo.FileName = "firefox"

    cmd.Start()

End Sub
  1. Build and save your “GoogleSearch” module.
  2. From menu bar  “Tools->Options->Environment->Keyboard
  3. In the “Show commands containing:” input textbox, type “Google” (to search your newly created macro).
  4. Go to the “Press shortcut keys” box, and press F1 and then Assign button
  5. Press OK.

Select text in your Visual Studio Environment that you want to google and press F1, now google searches for whatever you highlighted.
Your search result will be appeared by open New Tab in Firefox (no matter if firefox is already running ).

enjoy your development and google search interactive format.  Save your time of text copy/paste or typing the terms you want to google.


National Anthem of Pakistan (Qaumī Tarāna)

National Anthem of Pakistan
(Qaumī Tarāna Urdu)

پاک سرزمین شاد باد
كشور حسين شاد باد
تو نشان عزم علیشان
ارض پاکستان!
مرکز یقین شاد باد

پاک سرزمین کا نظام
قوت اخوت عوام
قوم ، ملک ، سلطنت
! پائندہ تابندہ باد
شاد باد منزل مراد

پرچم ستارہ و ہلال
رہبر ترقی و کمال
ترجمان ماضی شان حال
! جان استقبال
سایۂ خدائے ذوالجلال

 

National Anthem of Pakistan

National Anthem of Pakistan

Listen National Anthem of Pakistan

 

National Anthem of Pakistan
(Urdu Transliteration)

Pak sarzamin shad bad
Kishware haseen shad bad
Tunishane azmealishan arze Pakistan
Markazeyaqin shadbad.

Pak sarzamin ka nizam quwate akhuwati awam
Qaum, mulk, Sultanat
Painda ta binda bad shad, bad man zele murad.

Parchame sitarao hilat
Rahbare tarraqio ka mal
Tarjumane mazishane hal jane istaqbal
Sayyai, khudae zul jalal.

National Anthem of Pakistan
(English)

Blessed be the sacred Land
Happy be the bounteous realm
Symbol of high resolve
Land of Pakistan
Blessed be thou citadel of faith

The order of this sacred land
Is the might of the brotherhood of the People
May the nation, the country, and the state
Shine in glory everlasting
Blessed be the goal of our ambition

This Flag of the Crescent and Star
Leads the way to progress and perfection

Interpreter of our past, glory of our present
Inspiration of our future
Symbol of Almighty’s protection


IF EXISTS in Oracle(PL/SQL)

Here is a simple implementation to perform ‘IF EXISTS’ check

PL/SQL:


DECLARE 

vCount NUMBER;

BEGIN

      SELECT COUNT(*)
        INTO vCount
        FROM TABLE_NAME
       WHERE COLUMN_NAME = 'YOUR_VALUE';

      IF vCount > 0 THEN
       /*  Exists */
       DBMS_OUTPUT.PUT_LINE('Exists');
       
      ELSE
      /*  Not exists */
       DBMS_OUTPUT.PUT_LINE('Does not exists');
       
      END IF;

END;




ICC Cricket World Cup 2011



Group A:

Pakistan, Australia, New Zealand, Sri Lanka, Canada, Kenya, Zimbabwe


Group B:

India, England, South Africa, West Indies, Bangladesh, Netherlands, Ireland

  • Every team will play 2 warm-up matches before the start of WC.
  • Pakistan‘s two warm-up matches are against Bangladesh and England on February 15 and February 18 respectively.
  • Pakistan‘s all matches are in Sri Lanka and day/night. All  will start at 2.00pm PST and 9.00am GMT
  • Top four teams from each group will qualify for Quarter-Final, which would be first knock-out stage of World
    Cup.

 

Match

Date

Teams

Venue

1

19 Feb

India vs Bangladesh

Dhaka

2

20 Feb

New Zealand vs Kenya

Chennai

3

20 Feb

Sri Lanka vs Canada

Hambantota

4

21 Feb

Australia vs Zimbabwe

Ahmedabad

5

22 Feb

England vs Netherlands

Nagpur

6

23 Feb

Pakistan vs Kenya

Hambantota

7

24 Feb

South Africa vs West
Indies

New Delhi

8

25 Feb

Australia vs New Zealand

Nagpur

9

25 Feb

Bangladesh vs Ireland

Dhaka

10

26 Feb

Sri Lanka vs Pakistan

Colombo

11

27 Feb

India vs England

Kolkata

12

28 Feb

West Indies vs Netherlands

New Delhi

13

28 Feb

Zimbabwe vs Canada

Nagpur

14

1 Mar

Sri Lanka vs Kenya

Colombo

15

2 Mar

England vs Ireland

Bangalore

16

3 Mar

South Africa vs Netherlands

Mohali

17

3 Mar

Pakistan vs Canada

Colombo

18

4 Mar

New Zealand vs Zimbabwe

Ahmedabad

19

4 Mar

Bangladesh vs West
Indies

Dhaka

20

5 Mar

Sri Lanka vs Australia

Colombo

21

6 Mar

India vs Ireland

Bangalore

22

6 Mar

England vs South Africa

Chennai

23

7 Mar

Kenya vs Canada

New Delhi

24

8 Mar

Pakistan vs New Zealand

Pallekelle

25

9 Mar

India vs Netherlands

New Delhi

26

10 Mar

Sri Lanka vs Zimbabwe

Pallekelle

27

11 Mar

West Indies vs Ireland

Mohali

28

11 Mar

Bangladesh vs England

Chittagong

29

12 Mar

India vs South Africa

Nagpur

30

13 Mar

New Zealand vs Canada

Mumbai

31

13 Mar

Australia vs Kenya

Bangalore

32

14 Mar

Pakistan vs Zimbabwe

Pallekelle

33

14 Mar

Bangladesh vs Netherlands

Chittagong

34

15 Mar

South Africa vs Ireland

Kolkata

35

16 Mar

Australia vs Canada

Bangalore

36

17 Mar

England vs West
Indies

Chennai

37

18 Mar

Sri Lanka vs New Zealand

Mumbai

38

18 Mar

Ireland vs Netherlands

Kolkata

39

19 Mar

Australia vs Pakistan

Colombo

40

19 Mar

Bangladesh vs South Africa

Dhaka

41

20 Mar

Zimbabwe vs Kenya

Kolkata

42

20 Mar

India vs West
Indies

Chennai

43

23 Mar

1st QF: A1 v B4

Dhaka

44

24 Mar

2nd QF: A2 v B3

Colombo

45

25 Mar

3rd QF: A3 v B2

Dhaka

46

26 Mar

4th QF: A4 v B1

Ahmedabad

47

29 Mar

First Semifinal will be played between winners of both
Quarter Finals played in Dhaka

Colombo

48

30 Mar

Second Semifinal will be played between winners of
Quarter Finals played in Ahmedabad and Colombo

Mohali

49

02 Apr

FINAL

Mumbai