Hi!
I am having some trouble. I have two stored procedures:
CREATE PROCEDURE dbo.TestTran1
as
declare @.erri int
begin tran
insert into prosjekt values('this is a test', NULL, 1)
select @.erri = @.@.error
if @.erri <> 0
goto errHandler
exec TestTran2
select @.erri = @.@.error
if @.erri <> 0
begin
goto errHandler2
end
commit tran
return 0
errHandler:
if @.@.trancount > 0
rollback tran
Raiserror('Det oppstod en feil i TestTran1',16,1)
GO
Here is procedure number 2:
CREATE PROCEDURE dbo.TestTran2 AS
begin tran
print 'in proc 2'
insert into prosjekt values('Dette er et testprosjekt Dette er et
testprosjekt Dette er et testprosjekt ', null, 2)
if @.@.error <> 0
begin
goto errH
end
commit tran
return 0
errH:
rollback tran
print 'rolling back'
raiserror('Det oppstod en feil i TestTran2', 16, 1)
GO
The first procedure inserts values to a testtable with success. Then it
calls the second procedure that will generate an error because it tries
to insert too much text in a varchar(50) column. What I am trying to
achieve here is to be able to use both procedures by it self and also be
able to call one from the other if nessesairy.
If I run the first procedure (that calls the other), I get the error:
"Server: Msg 266, Level 16, State 2, Procedure TestTran2, Line 26
Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK
TRANSACTION statement is missing. Previous count = 1, current count =
0."
If I run the second procedure or the first one without calling the
second, everything works fine. The same goes if I make the second
procedure not fail when called from the first.
I have so far learned that an inner commit will not actually commit
anything, rather just decrement the @.@.trancount by one. The outer commit
will make the actuall commit. A rollback on the other hand will allways
make a rollback and set @.@.trancount = 0.
1. What am I doing wrong. Can I not use begin tran in two different
procedures calling each other?
2. Is there any need for using the begin tran expression? or will sql
server still handle everything like a transaction what ever one does?
Hope I made my self clear on the matter. Thanks!
Henning :-)
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hi Henning.
What I've been doing, don't know if it's the best method or not, is
in each proc, test if it has been called within a transaction and if
not, use transactions. Also, to ensure your transaction isn't
automatically aborted upon a SQL error, use SET XACT_ABORT OFF
Example:
create procedure myProc
as
set xact_abort off
declare @.InTran tinyint
set @.InTran = @.@.trancount
if @.InTran = 0
begin
begin tran
end
-- do some stuff
if @.@.error <> 0
begin
if @.InTran = 0
begin
rollback tran
end
end
else
begin
if @.InTran = 0
begin
commit tran
end
end
Hope this helps. I look forward to anyone else's feedback.
Bryce
Showing posts with label transactions. Show all posts
Showing posts with label transactions. Show all posts
Sunday, March 11, 2012
Tuesday, February 14, 2012
calculating load
SEVRER WORKLOAD PARAMETERS:
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back en
d?
ANS: Yes"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back en
d?
ANS: Yes"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
Labels:
based,
calculating,
database,
expected,
following,
givenq1,
load,
microsoft,
mysql,
oracle,
parameters,
parameterscan,
server,
sevrer,
sql,
suggest,
transactions,
workload
calculating load
SEVRER WORKLOAD PARAMETERS:
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back end?
ANS: Yes"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back end?
ANS: Yes"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
calculating load
SEVRER WORKLOAD PARAMETERS:
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back end?
ANS: Yes
"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
can someone suggest me something based on the following parameters given
Q1 How many transactions are expected during the peak hour of activity? How
many transactions are expected each business day?
ANS: 300 concurrent users (max) will connect to application server and based
on the activity application server will call stored procedure stored in the
database server (one at a time). Most of the stored procedure (approx 500)
has single SELECT/UPDATE statement but, around 100 procedures has multiple
SELECT/UPDATE statement inside them (max 8 statement), frequency of calling
these procedures are less compared to the other 500.
Q2 How many database connections are required? From Appln to DB
ANS: How can we check that, will SQL profiler be able to give me this info?
Q3 How much storage should be reserved for the database (data and indexes)?
15 GB of database size is expected.
Q4 Can your application support 2 appln servers talking to one db at back end?
ANS: Yes
"NewTOPROJECT" <NewTOPROJECT@.discussions.microsoft.com> wrote in message
news:3DF1EF15-D256-4961-881E-68427A184A0B@.microsoft.com...
> SEVRER WORKLOAD PARAMETERS:
> can someone suggest me something based on the following parameters given
>
I suggest you test, there's not nearly enough information to accruately size
the hardware. By the way, no matter how detailed your questionare is, you
will still need to test.
That workload does not appear to be too extreme. 15GB is on the large size
for an OLTP application, and a big wildcard is how expensive your SELECT
statements are. With 15GB of data there is ample opportunity to create very
expensive queries. On the other hand, if the data is largly historical and
you don't do historical reporting during peak load times, your workload may
be quite light.
So throw the profiler on it and watch the Reads and the CPU. The most
expensive 10% of queries may use 90% of your resources, so identify and
optimize these.
David
Labels:
based,
calculating,
database,
expected,
following,
givenq1,
load,
microsoft,
mysql,
oracle,
parameters,
parameterscan,
server,
sevrer,
sql,
suggest,
transactions,
workload
Subscribe to:
Posts (Atom)