Click here to Skip to main content
15,899,475 members
Home / Discussions / Database
   

Database

 
GeneralRe: Grouping by time period Pin
Colin Angus Mackay12-Mar-05 6:49
Colin Angus Mackay12-Mar-05 6:49 
Generaltables list in access Pin
Silly Boy11-Mar-05 0:58
Silly Boy11-Mar-05 0:58 
GeneralRe: tables list in access Pin
numbrel11-Mar-05 3:59
numbrel11-Mar-05 3:59 
GeneralRe: tables list in access Pin
Suman Singh29-Mar-05 12:51
professionalSuman Singh29-Mar-05 12:51 
GeneralProgram loaded before Sql service Pin
Anonymous10-Mar-05 23:23
Anonymous10-Mar-05 23:23 
GeneralRe: Program loaded before Sql service Pin
Yulianto.11-Mar-05 16:07
Yulianto.11-Mar-05 16:07 
GeneralRe: Program loaded before Sql service Pin
Anonymous12-Mar-05 15:11
Anonymous12-Mar-05 15:11 
GeneralApplication Level Transaction Vs Stored Proc Transaction Pin
devvvy10-Mar-05 14:48
devvvy10-Mar-05 14:48 
Hi, I'm choosing between transaction on stored proc level and transaction on application level. You see:
<br />
DECLARE	@ValidationCode INTEGER<br />
BEGIN TRAN<br />
SET @ValidationCode = 0<br />
EXEC sp_CreateSupplier 1, 'M', 1, 'Golden Lucky and Associates', 'Golden Lucky and Associates', NULL, NULL, 'A', 3, 8, @ValidationCode OUTPUT<br />
PRINT 'Validation code: ' + CAST (@ValidationCode AS VARCHAR(10))<br />
<br />
... do other stuff...<br />
<br />
COMMIT TRAN<br />
<br />
CREATE PROCEDURE sp_CreateSupplier(<br />
	@supplier_no INTEGER,<br />
	@type VARCHAR(8),<br />
	@group_no INTEGER = NULL,<br />
	@short_name VARCHAR(50) = NULL,<br />
	@full_name VARCHAR(100) = NULL,<br />
	@address VARCHAR(100) = NULL,<br />
	@country_code VARCHAR(10) = NULL,<br />
	@status VARCHAR(8) = NULL,<br />
	@createBy INTEGER,<br />
	@ownerGroup INTEGER,<br />
	@ValidationCode INTEGER OUTPUT<br />
)<br />
AS<br />
BEGIN<br />
<br />
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE<br />
BEGIN TRANSACTION<br />
<br />
	-- STEP 1: Validation<br />
	SET @ValidationCode = 0<br />
	IF EXISTS(SELECT * FROM fe_supplier WHERE supplier_no=@supplier_no)<br />
		BEGIN<br />
		SET @ValidationCode = -10<br />
		ROLLBACK TRANSACTION<br />
		RETURN<br />
		END<br />
         ...<br />
COMMIT TRAN<br />
END<br />


The above snippet will result in:
Server: Msg 266, Level 16, State 2, Procedure sp_CreateSupplier, Line 26<br />
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0.


Now, what I'm really doing in my code is I called the stored proc from a method in application level - And this method is executed in context of a transaction (Which wraps around the stored proc with its own transaction):

Public Function Create(ByVal sup As vendormanagement.to.Supplier, ByVal tran As IDbTransaction) As vendormanagement.to.Supplier<br />
<br />
  Dim sql As String = "sp_CreateSupplier"<br />
  Dim cmd As IDbCommand<br />
  Dim rdr As IDataReader<br />
  Dim param As IDataParameter<br />
  Dim factory As IDbProviderFactory<br />
  Dim validationCode As Int32 = 0<br />
<br />
  Try<br />
    If _conn.State <> ConnectionState.Open Then<br />
       _conn.Open()<br />
    End If<br />
<br />
    factory = apputil.GlobalVariables.ProviderFactory<br />
    cmd = factory.CreateCommand(sql, Conn)<br />
    cmd.CommandType = CommandType.StoredProcedure<br />
    cmd.Transaction = tran<br />
<br />
    ...<br />
    rdr = cmd.ExecuteReader()<br />
    ...<br />
   Catch<br />
    ...<br />
   Finally<br />
      ...<br />
   End Try<br />
End Function


What I wish to do is to MAINTAIN transaction in stored proc level - which suggest that I must remove application level transaction. BUT I can't do that because:
<br />
vconn = vFactory.CreateConnection(...)<br />
tran = vconn.BeginTransaction(...serializable...)<br />
SupplierBean.Create(..., tran)<br />
AnotherBean.Update(..., tran)<br />
tran.Commit()<br />

So, my question is, how can I reconcile the two: Application Vs Stored proc transaction. The ONLY way to just recitify the problem seems to be removing stored proc level transaction.... Am I right?

Thanks in advance!

Norman Fung
Questionwhat does this error means Error converting data type varchar to int. Pin
feeha10-Mar-05 11:27
feeha10-Mar-05 11:27 
AnswerRe: what does this error means Error converting data type varchar to int. Pin
Edbert P10-Mar-05 15:50
Edbert P10-Mar-05 15:50 
Generalplz help me in the following code Pin
feeha10-Mar-05 11:13
feeha10-Mar-05 11:13 
GeneralRe: plz help me in the following code Pin
Colin Angus Mackay10-Mar-05 11:35
Colin Angus Mackay10-Mar-05 11:35 
GeneralRe: plz help me in the following code Pin
turbochimp14-Mar-05 17:58
turbochimp14-Mar-05 17:58 
Questionhow to save databse along with its data Pin
eshban28410-Mar-05 8:25
eshban28410-Mar-05 8:25 
AnswerRe: how to save databse along with its data Pin
Colin Angus Mackay10-Mar-05 10:06
Colin Angus Mackay10-Mar-05 10:06 
Generalupdating an SQL table in C# Pin
clemenslinders10-Mar-05 5:59
clemenslinders10-Mar-05 5:59 
GeneralADO events Pin
ledallam10-Mar-05 4:06
ledallam10-Mar-05 4:06 
GeneralRe: ADO events Pin
numbrel11-Mar-05 3:55
numbrel11-Mar-05 3:55 
GeneralRe: ADO events Pin
coderChina16-Mar-11 21:35
coderChina16-Mar-11 21:35 
GeneralInspecting / Analyzing transaction log file contents Pin
Hillel9-Mar-05 21:43
Hillel9-Mar-05 21:43 
GeneralRe: Inspecting / Analyzing transaction log file contents Pin
Mike Dimmick10-Mar-05 1:49
Mike Dimmick10-Mar-05 1:49 
GeneralBDE causes DB Open/Close to lose windows Handles Pin
Pankaj Kahal9-Mar-05 16:39
Pankaj Kahal9-Mar-05 16:39 
GeneralRe: BDE causes DB Open/Close to lose windows Handles Pin
Rob Graham10-Mar-05 7:02
Rob Graham10-Mar-05 7:02 
Generalwhats the proper defination of view Pin
feeha9-Mar-05 9:28
feeha9-Mar-05 9:28 
GeneralRe: whats the proper defination of view Pin
ToddHileHoffer9-Mar-05 10:25
ToddHileHoffer9-Mar-05 10:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.