Wed 31 Dec 2008

Sample Code Oracle stored procedure - In this simple implementation, call commit at the end of work done, and Rollback if any exception occur.

 

PROCEDURE SAVE_TWO_THINGS(
IN_THING_ONE IN VARCHAR2,
IN_THING_TWO IN VARCHAR2)
IS

BEGIN

INSERT INTO TABLEONE
(ACTIVE, THING_DESC)
VALUES
('Y', IN_THING_ONE);


INSERT INTO TABLETWO
(ACTIVE, THING_DESC)
VALUES
('N', IN_THING_TWO);

COMMIT;

EXCEPTION WHEN OTHERS THEN 
ROLLBACK;
END;

Comments here
Wed 31 Dec 2008

Today I need to implement transaction in .NET. Front end language was VB.NET and database was Oracle.

This transaction is being implemented using Oracle Data Access Provider - ODP.NET.

Simple implementation is that create and open a connection, begin transaction using that connection, create command using that connection, call stored procedures or statments using command(s), if every thing gone fine and success then call commit of that transaction else rollback, and in last close and dispose connection and transaction.

Be sure not to use commit, rollback or statement that causes transaction invalidate inside the procedure that is being called within .NET transaction, otherwise that .NET transaction scope will no longer valid as within that connection commit or rollback have been called.

Sample code that make my work done is :-

=============

Private Sub Save()
Dim conn As New OracleConnection("ConnString")
Dim trans As OracleTransaction
Dim success as Boolean = False

Try
conn.Open()
 trans = conn.BeginTransaction
success =  saveThingOne(conn)
If success Then
success = saveThingTwo(conn)
End If

If success  Then
 trans.Commit()
else
trans.Rollback()
End If

Catch ex As Exception
 trans.Rollback()
Finally
trans.Dispose()
conn.Close()
conn.Dispose()
End Try
End Sub



Private Sub saveThingOne(ByVal conn As OracleConnection) As Boolean
Dim success as Boolean = False
Using comm As New OracleCommand("Save_Thing_One_Stored_Procedure", conn)
   comm.CommandType = CommandType.StoredProcedure
   comm.Parameters.Add("IN_ID", OracleType.Number).Value = intID
   comm.Parameters.Add("IN_THING_ONE", OracleType.VarChar, 60).Value = strThingONe
   comm.Parameters.Add("OUT_RESULT", OracleType.Number).Direction = ParameterDirection.Output
   comm.ExecuteNonQuery()
‘Here if that procedure successfully perform action then will return 0 in case of success and 1 in case of failure
success = Iif(comm.Parameters(“OUT_RESULT”).Value.ToString().equals(“0”), True, False)
Return success
End Using
End Sub



Private Sub saveThingTwo(ByVal conn As OracleConnection)
Dim success as Boolean = False
Using comm As New OracleCommand("Save_Thing_Two_Stored_Procedure", conn)
   comm.CommandType = CommandType.StoredProcedure
   comm.Parameters.Add("IN_ID", OracleType.Number).Value = intID
   comm.Parameters.Add("IN_THING_TWO", OracleType.VarChar, 60).Value = strThingTwo
   comm.Parameters.Add("OUT_RESULT", OracleType.Number).Direction = ParameterDirection.Output
   comm.ExecuteNonQuery()
‘Here if that procedure successfully perform action then will return 0 in case of success and 1 in case of failure
success = Iif(comm.Parameters(“OUT_RESULT”).Value.ToString().equals(“0”), True, False)
Return success

End Using
End Sub

 

 

Comments here
Tue 30 Dec 2008
Categories : Knowledge / Amazing
Comments here
Sun 28 Dec 2008

Cool rebranding due to financial crisis... 3m, apple, cisco, citigroup, dell, ferrari, ford, goodyear, jones, lg, nike, nokia, xerox, yahoo....

 

rebrand 3m.jpg

rebrand apple.jpg

rebrand buy.jpg

rebrand cisco.jpg

rebrand citi.jpg

rebrand dell.jpg

rebrand ferrari.jpg

rebrand ford.jpg

rebrand goodyear.jpg

rebrand jones.jpg

rebrand lg.jpg

rebrand nike.jpg

rebrand nokia.jpg

rebrand ssler.jpg

rebrand xerox.jpg

rebrand yahoo.jpg

Categories : Pics / Images Shot
Comments here
Fri 26 Dec 2008

aik tu jis nay chaman say phool cheen kar hamay dia
aik hum jo is ko gulshan bana na sakay

aik tu jo gardish-e-zamanay say takra gaya
aik hum nidamat say sar utha bhi na sakay

aik tu jo shama jalata tha hawa k rukh par
aik hum jo shama ko bujhnay say bacha bhi na sakay

 

Categories : Thoughts / Lessons
Comments here
Fri 26 Dec 2008

Hum laye hain kashti ko toofaan say nikal kay... is mulk ko rakhna tum sambhal kay....

The great leader of Pakistan, Quaid-e-Azam, Muhammad Ali Jinnah - On this birth day...

 jinnah1.jpg

I(Doc Kazi of flickr) got this rare photgraph from Mahmood on Victoria Road. He could not identify the others although the man in the center resembles the Nawab of Jungadh. The British General resembles Gen Musa. Mr Jinnah seems in a relaxed mood ostensibly with his favorite 'Craven A' cigarettes, which finally got him

 quaid-british.jpg

In 1916, an even younger Mr Jinnah(in front center, mustachioed) presiding over a joint meeting of Indian National Congress and All India Muslim League.

 quaid-meeting.jpg

 

Mayor of Karachi Hakim M Ahsan hosts a reception for the Governor General of Pakistan on Aug 25, 1947.

 quaid-mayor.jpg

Quaid visiting PAF base Risalpur, 1947.

 MA_Jinnah_at_Risalpur_1.jpg

 

MA_Jinnah_at_Risalpur_2.jpg

 

MA_Jinnah_at_Risalpur_3.jpg

Quaid with Moutbaten

 quaid-mountbaten233331634_8911330.jpg

Quaid with Liaquat Ali Khan

 quaid-liaquat21634_4060182.jpg

 

Nawabzada Nasurallah escorts Mr. Jinnah

 quaid-welcome2.jpg

 

quaid-welcome.jpg

 

The Founder with Field Marshal Auchinleck

 quaid-auchinleck.jpg

The Founder addresses the Muslim League Session, Allahabad 1942

quaid-muslim-league.jpg

Smiling Jinnah in Bombay

quaid-smiling.jpg  

 

Categories : Pics / Images Shot
Comments here
Thu 25 Dec 2008
This is good for those who are interested in linux
 
GNU + Cygnus + Windows = Cygwin
 
Cygwin is a Linux-like environment for Windows
 
 
 
Comments here