Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Tuesday, March 27, 2012

Configuration Manager ?

Each time you start a SSIS project you have Solutions Configuration showing "Development". In the drop down box you can select "Configuration Manager..."

Can someone tell me the use of this, and is it related to the package configurations somehow. I've tried to create new Solution Configurations like "Test" and "Production" with the purpose of binding different configuration files and deplymentfolders to each Solution Configuration but still it seems like this isn't the way i should be used...

This is something inherent to Visual Studio rather than BIDS or SSIS. It doesn't have any relevance to package configurations that we know and love (!!!).

I don't know how this VS feature is supposed to be used so I say whether it would be useful for SSIS or not. I'd like to know though!!!

-Jamie

|||

The only thing i could see any use of this was to create 3 enviroments - Development, Test and Production.

I each of those i'll set the outputpath to bin\Development, bin\Test, bin\Production

So when i build the package i can choose the enviroment to build it to so that i can keep those files sepperate....

|||

Is there a way to reference the current value within a variable ?

This would be helpfull for having the servername depend on the selected configuration.

Thanks in advance,

Geert

|||

What you are asking and what cpgl described seems totally unnecessary if you only use the built in Configuration support for SSIS. Things like file paths are server names should be changed through configurations, not coded into the package during "build".

I would expect each environment to have the required configiration resources in place, so there should be nothing to change in the package to prepare it for an environment. If you do change the package between environments it just defeats the purpose of having a test environment as what you tested is not what you will then promote to production. It may be a minor change, but being strict, no changes should be allowed.

The only exception I can see is when environments are combined on machines, and for that I'd recomend passing in a parameter through the execution host, e.g. DTEXEC /SET

Configuration Files

Hi,

I’m having some issues associated with the configuration files that I can’t understand:

- Having a project with several packages using the same connections in each one (some packages use all connection and others I just have some of them), why can’t I use only one configuration file for all project. Assuming that I would have to configure all packages at least I would like to use always the same file. On the other way I would need 100’s of configuration files (one per package) to configure always the same connection, just because not all the packages use exactly the same connections.

- Having a configuration file on a machine, the package saves the full path, even if the configuration file lays in the same path them the project. When I change my project to another machine that doesn’t use the same file structure forces me to open every package and change the configuration file location.

Having 100’s of packages and a team of developers, even using the source safe, this makes the task just a little difficult

Thanks,
Vítor Ferreira

Sorry for the different fonts
|||

Vítor Ferreira wrote:

Hi,

I’m having some issues associated with the configuration files that I can’t understand:

- Having a project with several packages using the same connections in each one (some packages use all connection and others I just have some of them), why can’t I use only one configuration file for all project. Assuming that I would have to configure all packages at least I would like to use always the same file. On the other way I would need 100’s of configuration files (one per package) to configure always the same connection, just because not all the packages use exactly the same connections.

It is perfectly possible to do this (i.e. share a .dtsconfig file around multiple packages). I'd like to understand why you think it cannot be done.

Admittedly you do have the problem that if a config file references a property that doesn't exist in the package in which it is being used then you will get an error. I have asked for this behaviour to change in the future and I believe it will be.

In the meantime, I aways recommend that you should rationalise your configuration files - splitting them up so that you don't encounter the problem I just spoke of. On the project I have just completed we used a seperate config file for every single Connection Manager and this worked fantasically well because we could easily share config files between seperate packages - I would always take this approach in the future. In fact, I recommend it in my suggested best practices: http://blogs.conchango.com/jamiethomson/archive/2006/01/05/2554.aspx (number 14).

Vítor Ferreira wrote:

- Having a configuration file on a machine, the package saves the full path, even if the configuration file lays in the same path them the project. When I change my project to another machine that doesn’t use the same file structure forces me to open every package and change the configuration file location.

This is why you should use something else I always recommend - Indirect Configurations: http://blogs.conchango.com/jamiethomson/archive/2005/11/02/2342.aspx

Hope that helps!

-Jamie

|||

Jamie,
It works just like you said, that's why i mentioned that i had packages not always using the same connection, because if they all have the same connections or variables used in the configuration file, I have no error. I already have thought on the approach you have mentioned, one configuration file for connection, and it’s probably the best solution.

Thanks,

Vítor Ferreira

|||

Vítor Ferreira wrote:

Jamie,
It works just like you said, that's why i mentioned that i had packages not always using the same connection, because if they all have the same connections or variables used in the configuration file, I have no error. I already have thought on the approach you have mentioned, one configuration file for connection, and it’s probably the best solution.

Thanks,

Vítor Ferreira

Absolutely!!

Its definately the way forward in this scenario. Also, if you use indirect configs its even easier to edit your package configurations because its simply a matter of selecting an environment variable from a list. It works really well!

-Jamie

|||

I would suggest that the indirect configuration feature be augmented to support configuring the root path of configurations from an environment variable. Then just configure the remaining path portion or filename from the designer.

This would allow a single environment variable for a set of packages and each package would just have the configuration file name that is maintained.

Fred

|||

Jamie,
Correct me if I am wrong, but to use environment variables to configure the configuration files path, I will need to use one environment variable for each configuration file, even if they lay all in the same directory!?

Thanks,
Vítor
|||

Vítor Ferreira wrote:

Jamie,
Correct me if I am wrong, but to use environment variables to configure the configuration files path, I will need to use one environment variable for each configuration file, even if they lay all in the same directory!?

Thanks,
Vítor

Vitor,

Correct. That's the approach we used on my last project and we were really happy with it.

-Jamie

|||I'm trying to setup my indirect configuration path using environment variables. I have an environment variable that contains the location of the configuration file. Once I do that I don't have the option to export any variables to this file anymore. Do I have to configure everything using a direct path, then once I'm finished, set it to the environment variable? This seems awckward...|||

Pirooz Javan wrote:

I'm trying to setup my indirect configuration path using environment variables. I have an environment variable that contains the location of the configuration file. Once I do that I don't have the option to export any variables to this file anymore. Do I have to configure everything using a direct path, then once I'm finished, set it to the environment variable? This seems awckward...

Pirooz,

Yes, this is the correct way. I can see how it could be improved like you suggest tho. Why not request it at Microsoft Connect?

-Jamie

sqlsql

Configuration Files

Hi,

I’m having

some issues associated with the configuration files that I can’t understand:

-

Having

a project with several packages using the same connections in each one (some

packages use all connection and others I just have some of them), why can’t I use

only one configuration file for all project. Assuming that I would have to

configure all packages at least I would like to use always the same file. On

the other way I would need 100’s of configuration files (one per package) to

configure always the same connection, just because not all the packages use

exactly the same connections.

-

Having

a configuration file on a machine, the package saves the full path, even if the

configuration file lays in the same path them the project. When I change my

project to another machine that doesn’t use the same file structure forces me

to open every package and change the configuration file location.

Having 100’s of packages and a team of

developers, even using the source safe, this makes the task just a little difficult

Thanks,
Vítor Ferreira

Sorry for the different fonts|||

Vítor Ferreira wrote:

Hi,

I’m having some issues associated with the configuration files that I can’t understand:

- Having a project with several packages using the same connections in each one (some packages use all connection and others I just have some of them), why can’t I use only one configuration file for all project. Assuming that I would have to configure all packages at least I would like to use always the same file. On the other way I would need 100’s of configuration files (one per package) to configure always the same connection, just because not all the packages use exactly the same connections.

It is perfectly possible to do this (i.e. share a .dtsconfig file around multiple packages). I'd like to understand why you think it cannot be done.

Admittedly you do have the problem that if a config file references a property that doesn't exist in the package in which it is being used then you will get an error. I have asked for this behaviour to change in the future and I believe it will be.

In the meantime, I aways recommend that you should rationalise your configuration files - splitting them up so that you don't encounter the problem I just spoke of. On the project I have just completed we used a seperate config file for every single Connection Manager and this worked fantasically well because we could easily share config files between seperate packages - I would always take this approach in the future. In fact, I recommend it in my suggested best practices: http://blogs.conchango.com/jamiethomson/archive/2006/01/05/2554.aspx (number 14).

Vítor Ferreira wrote:

- Having a configuration file on a machine, the package saves the full path, even if the configuration file lays in the same path them the project. When I change my project to another machine that doesn’t use the same file structure forces me to open every package and change the configuration file location.

This is why you should use something else I always recommend - Indirect Configurations: http://blogs.conchango.com/jamiethomson/archive/2005/11/02/2342.aspx

Hope that helps!

-Jamie

|||

Jamie,

It works just like you said, that's why i mentioned that i had packages not

always using the same connection, because if they all have the same connections

or variables used in the configuration file, I have no error. I already have

thought on the approach you have mentioned, one configuration file for

connection, and it’s probably the best solution.

Thanks,

Vítor

Ferreira

|||

Vítor Ferreira wrote:

Jamie,
It works just like you said, that's why i mentioned that i had packages not always using the same connection, because if they all have the same connections or variables used in the configuration file, I have no error. I already have thought on the approach you have mentioned, one configuration file for connection, and it’s probably the best solution.

Thanks,

Vítor Ferreira

Absolutely!!

Its definately the way forward in this scenario. Also, if you use indirect configs its even easier to edit your package configurations because its simply a matter of selecting an environment variable from a list. It works really well!

-Jamie

|||

I would suggest that the indirect configuration feature be augmented to support configuring the root path of configurations from an environment variable. Then just configure the remaining path portion or filename from the designer.

This would allow a single environment variable for a set of packages and each package would just have the configuration file name that is maintained.

Fred

|||

Jamie,

Correct me if I am wrong, but to use environment variables to configure the

configuration files path, I will need to use one environment variable for each

configuration file, even if they lay all in the same directory!?

Thanks,
Vítor|||

Vítor Ferreira wrote:

Jamie,
Correct me if I am wrong, but to use environment variables to configure the configuration files path, I will need to use one environment variable for each configuration file, even if they lay all in the same directory!?

Thanks,
Vítor

Vitor,

Correct. That's the approach we used on my last project and we were really happy with it.

-Jamie

|||I'm trying to setup my indirect configuration path using environment variables. I have an environment variable that contains the location of the configuration file. Once I do that I don't have the option to export any variables to this file anymore. Do I have to configure everything using a direct path, then once I'm finished, set it to the environment variable? This seems awckward...|||

Pirooz Javan wrote:

I'm trying to setup my indirect configuration path using environment variables. I have an environment variable that contains the location of the configuration file. Once I do that I don't have the option to export any variables to this file anymore. Do I have to configure everything using a direct path, then once I'm finished, set it to the environment variable? This seems awckward...

Pirooz,

Yes, this is the correct way. I can see how it could be improved like you suggest tho. Why not request it at Microsoft Connect?

-Jamie

Configuration file for reporting server project

Hi!
Is it somehow possible to create a configuration file for a reporting server
project. Something similar like the web.config or app.config file in .NET
applications?
What I wanna do is to store the link of a picture file. I don't want to
hard-code that in every report.
Are there any other options than storing this link in a config file?
Cheers, RogerOn Jul 17, 8:37 am, "Roger Frei" <s...@.hotmail.com> wrote:
> Hi!
> Is it somehow possible to create a configuration file for a reporting server
> project. Something similar like the web.config or app.config file in .NET
> applications?
> What I wanna do is to store the link of a picture file. I don't want to
> hard-code that in every report.
> Are there any other options than storing this link in a config file?
> Cheers, Roger
What you could try doing is include a link to a picture file in a
report and then check the XML structure of the underlying RDL file in
a text editor (Notepad, Wordpad, etc). Then change the path in the RDL
file via a custom application that creates the RDL file on the fly.
This might be a bit tedious but it may be the only option.
Regards,
Enrique Martinez
Sr. Software Consultant|||On Jul 17, 2:37 pm, "Roger Frei" <s...@.hotmail.com> wrote:
> Hi!
> Is it somehow possible to create a configuration file for a reporting server
> project. Something similar like the web.config or app.config file in .NET
> applications?
> What I wanna do is to store the link of a picture file. I don't want to
> hard-code that in every report.
> Are there any other options than storing this link in a config file?
> Cheers, Roger
Roger,
Add the picture file to your report project - deploy and hide - no ?

Sunday, March 25, 2012

Configuration Error in roleManager in security VSS

We have a project that is in a server with windows 2000 (SQL Server 2005 and .Net 2005) And the other developer has a windows XP machine ( .Net 2005) , We are using the VSSC for the project , when the other developer run the application , the following error is show :

Server Error in '/XXX' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load type 'XXXSecurity.RoleSql'.

Source Error:

Line 27: <roleManager enabled="true" defaultProvider="SqlRoleManager" cacheRolesInCookie="true" cookieTimeout="30" cookieRequireSSL="false" createPersistentCookie="true"> Line 28: <providers> Line 29: <add name="SqlRoleManager" type="XXXSecurity.RoleSql" connectionStringName="MySqlConnection" applicationName="XXX"/> Line 30: </providers> Line 31: </roleManager>


Source File: C:\Documents and Settings\YYYY\My Documents\Visual Studio 2005\Projects\XXX\RRRR\KKKKK\web.config Line: 29

Where XXX is the name of application.

SomeOne Know How Help Me Please?

This error has nothing to do with SourceSafe. Moving to SQL groups, perhaps they can help...

Alin

|||

The error seems to come from the VS XML parser. I don't see anything related to SQL Server.

Thanks
Laurentiu

Config files get lost...

I created a project with multiple packages. I created a global

config file that all packages reference. I also created a config file

for each package that contains the package specific settings. I

checked it all into TFS. I went to a different machine and checked it

all out. Upon loading a package into the IDE I got the following 3

warnings.

Warning loading MT_LSE_PROD_StageLoad.dtsx: The

configuration file "MT_LSE_PROD_StageLoad.dtsConfig" cannot be found.

Check the directory and file name.

e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Warning

loading MT_LSE_PROD_StageLoad.dtsx: The configuration file

"Environment.dtsConfig" cannot be found. Check the directory and file

name. e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Warning

loading MT_LSE_PROD_StageLoad.dtsx: Failed to load at least one of the

configuration entries for the package. Check configurations entries and

previous warnings to see descriptions of which configuration failed.

e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Any

ideas? And yes, the files *ARE* there! I tried building the project

and it builds. I also tried doing a deployment build and that too

built. I am so confused!!!

StarPilot wrote:

I created a project with multiple packages. I created a global config file that all packages reference. I also created a config file for each package that contains the package specific settings. I checked it all into TFS. I went to a different machine and checked it all out. Upon loading a package into the IDE I got the following 3 warnings.

Warning loading MT_LSE_PROD_StageLoad.dtsx: The configuration file "MT_LSE_PROD_StageLoad.dtsConfig" cannot be found. Check the directory and file name. e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Warning loading MT_LSE_PROD_StageLoad.dtsx: The configuration file "Environment.dtsConfig" cannot be found. Check the directory and file name. e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Warning loading MT_LSE_PROD_StageLoad.dtsx: Failed to load at least one of the configuration entries for the package. Check configurations entries and previous warnings to see descriptions of which configuration failed. e:\contentloader\sprint1a\MT_LSE_PROD_StageLoad.dtsx

Any ideas? And yes, the files *ARE* there! I tried building the project and it builds. I also tried doing a deployment build and that too built. I am so confused!!!

Could it be a permissions issue? I assume the account running the packages has access to e:\contentloader\sprint1a\

-Jamie

|||Not a permission issue. I've granted every account access to the file system (one of the "joys" of being in a dev environment). Also, I see this behavior in VS.NET not SQL. I do a get latest or check out of the project on a brand new dev machine and it is VS.NET giving me the warnings. I compile (ignoring the warnings) and it works just fine. I turn deployment on and build and the deployment directory has the packages and config files. So, they are there and being used - it's VS.NET that's winpering over it...

Sunday, March 11, 2012

Conditional Report Parameters

I have a report with required parameters of company and project. I then have 3 parameters that I want to be conditional - start date, end date and cycle.

By conditional I mean if cycle is chosen then start & end date are not required. If start and end date are chosen then cycle is not required.

I have made all 3 parameters 'Allow Null Values" however cycle's available values are set from a query once a project is chosen. When the field refreshes I lose my null checkbox for cycle, so it ends up always being required.

Am I going about this the wrong way? I'm using 2005.

I'm not sure that conditional report parameters exist, but could you accomplish this using optional parameters?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=621340&SiteID=1

|||

Hmm, not really. I don't want all 3 to be optional, either cycle or start/end date need to be required.

I'll keep banging my head against the wall... Thanks though.

Saturday, February 25, 2012

Conditional Data Inserting

Hello,

My project import data from à text file to a database. I'm able to import the whole file but i want to import only if data are younger than the one i have in database.

How can i do ? Where can i see a tutorial about it ?

thanks a lotDo both the source rows and the database rows have a date that can be compared. If so then you could use either a lookup or a mergejoin to get the two dates into the same data flow (by lookup or join on some key that indicates the rows are matched) and then use a conditional split to send the rows you want to update to a OLEDB command transform with the appropriate update statement (or if you do indeed want to insert the data not update then just send it to an OLEDB destination).

Thanks,
Matt|||There's a tutorial here that compares merge join and lookup components. Its not exactly the same as your situation but it may help!!

-Jamie|||Thanks it is very useful !

But i'm still blocked because in some case i need to insert, and in other case i need to update...|||Ash has a great post on upserts here:
http://sqljunkies.com/WebLog/ashvinis/archive/2005/06/15/15829.aspx
Give that a shot.
Thanks,

Friday, February 17, 2012

Concurrency problems

Hi all,
Suppose that client A and client B read a record and B begins editing that.
Meanwhile A attempts to delete the record. Our project's rules says that the
record must not be deleted while it is being edited by other user. Whereas
our clients are disconnected, client B cannot lock the record. How can I
solve this problem?
Any help would be greatly appreciated.
LeilaI'm not sure what you mean by 'our clients are disconnected' but you
could throw the Primary Key value of the row being edited into a table.
A "this row is locked" table of sorts. Then any other user reading
that row you require your application to check your Lock table for the
Primary key value, if it is found then you return a message saying "you
can't delete this record, it's being edited by another user." Or
something like that, we've done that for our OLTP system in the past.|||One way to solve this is to never delete a row. Add a column called
'Visible' that will act as a boolean for the UI to display or not display
the row. When a user 'deletes' a row, the row should really just be marked
as not visible. Then you can implement some logic (via a trigger) such that
if a row is updated when it's marked 'not visible', it will be marked
'visible' again.
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Leila" <Leilas@.hotpop.com> wrote in message
news:eU2lWsE5EHA.1596@.tk2msftngp13.phx.gbl...
> Hi all,
> Suppose that client A and client B read a record and B begins editing
that.
> Meanwhile A attempts to delete the record. Our project's rules says that
the
> record must not be deleted while it is being edited by other user. Whereas
> our clients are disconnected, client B cannot lock the record. How can I
> solve this problem?
> Any help would be greatly appreciated.
> Leila
>|||Adam Machanic wrote:
> One way to solve this is to never delete a row. Add a column called
> 'Visible' that will act as a boolean for the UI to display or not
display
> the row. When a user 'deletes' a row, the row should really just be
marked
> as not visible. Then you can implement some logic (via a trigger)
such that
> if a row is updated when it's marked 'not visible', it will be marked
> 'visible' again.
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:eU2lWsE5EHA.1596@.tk2msftngp13.phx.gbl...
> > Hi all,
> > Suppose that client A and client B read a record and B begins
editing
> that.
> > Meanwhile A attempts to delete the record. Our project's rules says
that
> the
> > record must not be deleted while it is being edited by other user.
Whereas
> > our clients are disconnected, client B cannot lock the record. How
can I
> > solve this problem?
> > Any help would be greatly appreciated.
> > Leila
> >
> >
Adam,
I have one question about this method, and I'm not questioning the
validity of this solution so please don't take my question the wrong
way. My question is about spliting the table by using the Visible bit
and querying on the table later. Wouldn't you have to always use that
bit on your Selects and therefore not having the most effecient "index"
of sorts to use when you are retrieving data? I'm very interested in
hearing your opinion on this one, we've had developers in the past rely
on an "Active" bit for rows in certain tables we use. For instance, an
operation location around the country, making it accesible to the
application via the active bit. I don't particularly like doing this
and have advised not doing it. Thanks for your time.
Mark|||Thanks Adam,
But how the visibility helps me? Should client B(who is editing the record)
mark the record as invisible? What if client B crashes while editing and the
record remains invisible in table?
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:#t8hQQF5EHA.1976@.TK2MSFTNGP09.phx.gbl...
> One way to solve this is to never delete a row. Add a column called
> 'Visible' that will act as a boolean for the UI to display or not display
> the row. When a user 'deletes' a row, the row should really just be
marked
> as not visible. Then you can implement some logic (via a trigger) such
that
> if a row is updated when it's marked 'not visible', it will be marked
> 'visible' again.
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:eU2lWsE5EHA.1596@.tk2msftngp13.phx.gbl...
> > Hi all,
> > Suppose that client A and client B read a record and B begins editing
> that.
> > Meanwhile A attempts to delete the record. Our project's rules says that
> the
> > record must not be deleted while it is being edited by other user.
Whereas
> > our clients are disconnected, client B cannot lock the record. How can I
> > solve this problem?
> > Any help would be greatly appreciated.
> > Leila
> >
> >
>|||Thanks,
Actually I thought about that but I don't know what to do if the client
crashes? Because the PK remains in that table and no longer will be
deleted..
<myelton1@.Lincare.com> wrote in message
news:1103300244.952647.179750@.z14g2000cwz.googlegroups.com...
> I'm not sure what you mean by 'our clients are disconnected' but you
> could throw the Primary Key value of the row being edited into a table.
> A "this row is locked" table of sorts. Then any other user reading
> that row you require your application to check your Lock table for the
> Primary key value, if it is found then you return a message saying "you
> can't delete this record, it's being edited by another user." Or
> something like that, we've done that for our OLTP system in the past.
>|||<myelton1@.Lincare.com> wrote in message
news:1103302784.609659.76270@.z14g2000cwz.googlegroups.com...
> way. My question is about spliting the table by using the Visible bit
> and querying on the table later. Wouldn't you have to always use that
> bit on your Selects and therefore not having the most effecient "index"
> of sorts to use when you are retrieving data? I'm very interested in
> hearing your opinion on this one, we've had developers in the past rely
> on an "Active" bit for rows in certain tables we use. For instance, an
> operation location around the country, making it accesible to the
> application via the active bit. I don't particularly like doing this
> and have advised not doing it. Thanks for your time.
Yes, you would always have to use that column in your selects. Note, it
doesn't necessarily have to be a BIT. A lot of developers prefer CHAR(1)
NOT NULL CHECK (Visible IN 'Y', 'N'). Whether it will cause problems? It
depends on how many deleted columns there are, how selective the rest of the
columns in the queries are, etc. I probably wouldn't even bother adding it
to any indexes (except maybe covering indexes), as SQL Server can seek using
the keys from the queries and then filter the rows where Visible = 'N' quite
easily. Again, though, it depends. As always, test heavily :)
Another option is to store PKs from deleted rows in another table and
then you can query like:
SELECT *
FROM YourTable
WHERE NOT EXISTS
(SELECT *
FROM YourTableDeletedRows T1
WHERE T1.PK = YourTable.PK)
I don't know how that will perform, but it may solve the issue if you're
getting index scans due to the 'boolean' column.
--
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||"Leila" <Leilas@.hotpop.com> wrote in message
news:ukmR7uF5EHA.3120@.TK2MSFTNGP12.phx.gbl...
> Thanks Adam,
> But how the visibility helps me? Should client B(who is editing the
record)
> mark the record as invisible? What if client B crashes while editing and
the
> record remains invisible in table?
ClientA is looking at the record.
ClientB is editing the record.
ClientA hits the "delete" button on the UI. This flips the "Visible"
column on the row.
ClientB submits the edits...
And now the "Visible" column gets flipped back.
You will probably also want to investigate how to periodically delete
all of the rows marked "not visible" so that your table isn't full of too
much unused legacy data.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||Leila wrote:
> Thanks Adam,
> But how the visibility helps me? Should client B(who is editing the record)
> mark the record as invisible? What if client B crashes while editing and the
> record remains invisible in table?
The real problem here is that you didn't provide much real detail so
people have to make guesses.
However, you can implement date/time stamps to track when rows are
"checked out" and create an interface to override checked out rows if
there is a crash.
But, you said your clients are "disconnected". If that is indeed the
case, and both clients can have the same data locally, how do you expect
ANY kind of concurrency checking to take place? Your design doesn't
really allow for it. One solution that does come to mind is that you
create a system to manage changes/deletes each time a client reconnects
to the source data.
But, back to your lack of problem description. When you say that A
cannot delete while B is editing, is that ONLY during the exact time
that B is editing? Honestly, why does it matter? If you're going to let
A delete the data anyway, you're not gaining much by adding in this
check. In fact, you should create a system so that if A does in fact
delete a row while B is editing it, and B then saves the data, they are
notified that the data was deleted by another client and then allow be
to with discard their data (and thus totally deleting the data) or
optionally read the data back to the database. Imperfect solution but it
sounds like you have an imperfect design :D
You may want to post some additional information about the rules that
govern the whole deletion/editing process. Like, how often do the client
connect to the database to sync their data sets? What happens when two
clients edit the same data, who takes precedence? How do you handle
duplicate data? etc.
Zach
> "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> news:#t8hQQF5EHA.1976@.TK2MSFTNGP09.phx.gbl...
>>One way to solve this is to never delete a row. Add a column called
>>'Visible' that will act as a boolean for the UI to display or not display
>>the row. When a user 'deletes' a row, the row should really just be
> marked
>>as not visible. Then you can implement some logic (via a trigger) such
> that
>>if a row is updated when it's marked 'not visible', it will be marked
>>'visible' again.
>>--
>>Adam Machanic
>>SQL Server MVP
>>http://www.sqljunkies.com/weblog/amachanic
>>--
>>
>>"Leila" <Leilas@.hotpop.com> wrote in message
>>news:eU2lWsE5EHA.1596@.tk2msftngp13.phx.gbl...
>>Hi all,
>>Suppose that client A and client B read a record and B begins editing
>>that.
>>Meanwhile A attempts to delete the record. Our project's rules says that
>>the
>>record must not be deleted while it is being edited by other user.
> Whereas
>>our clients are disconnected, client B cannot lock the record. How can I
>>solve this problem?
>>Any help would be greatly appreciated.
>>Leila
>>
>>
>|||If client B crashes, it cannot submit the changes and make the record
visible again. I mean the record will remain invisible
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:O5#E6xF5EHA.1976@.TK2MSFTNGP09.phx.gbl...
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:ukmR7uF5EHA.3120@.TK2MSFTNGP12.phx.gbl...
> > Thanks Adam,
> > But how the visibility helps me? Should client B(who is editing the
> record)
> > mark the record as invisible? What if client B crashes while editing and
> the
> > record remains invisible in table?
>
> ClientA is looking at the record.
> ClientB is editing the record.
> ClientA hits the "delete" button on the UI. This flips the "Visible"
> column on the row.
> ClientB submits the edits...
> And now the "Visible" column gets flipped back.
> You will probably also want to investigate how to periodically delete
> all of the rows marked "not visible" so that your table isn't full of too
> much unused legacy data.
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>|||Thanks Zach,
Actually each record has lots of details and the poor user must take time
and accuracy to edit these particular records. This is why we need to
protect the row while it's being edited. The logics and rules have a lot of
details to be explained here :(
Please just focus on this problem: client A must be prevented from deleting
the record which is being edited!
"Zach Wells" <zwells@.ain_removethis.com> wrote in message
news:OfNLJ3F5EHA.208@.TK2MSFTNGP12.phx.gbl...
> Leila wrote:
> > Thanks Adam,
> > But how the visibility helps me? Should client B(who is editing the
record)
> > mark the record as invisible? What if client B crashes while editing and
the
> > record remains invisible in table?
> The real problem here is that you didn't provide much real detail so
> people have to make guesses.
> However, you can implement date/time stamps to track when rows are
> "checked out" and create an interface to override checked out rows if
> there is a crash.
> But, you said your clients are "disconnected". If that is indeed the
> case, and both clients can have the same data locally, how do you expect
> ANY kind of concurrency checking to take place? Your design doesn't
> really allow for it. One solution that does come to mind is that you
> create a system to manage changes/deletes each time a client reconnects
> to the source data.
> But, back to your lack of problem description. When you say that A
> cannot delete while B is editing, is that ONLY during the exact time
> that B is editing? Honestly, why does it matter? If you're going to let
> A delete the data anyway, you're not gaining much by adding in this
> check. In fact, you should create a system so that if A does in fact
> delete a row while B is editing it, and B then saves the data, they are
> notified that the data was deleted by another client and then allow be
> to with discard their data (and thus totally deleting the data) or
> optionally read the data back to the database. Imperfect solution but it
> sounds like you have an imperfect design :D
> You may want to post some additional information about the rules that
> govern the whole deletion/editing process. Like, how often do the client
> connect to the database to sync their data sets? What happens when two
> clients edit the same data, who takes precedence? How do you handle
> duplicate data? etc.
> Zach
> >
> > "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> > news:#t8hQQF5EHA.1976@.TK2MSFTNGP09.phx.gbl...
> >
> >>One way to solve this is to never delete a row. Add a column called
> >>'Visible' that will act as a boolean for the UI to display or not
display
> >>the row. When a user 'deletes' a row, the row should really just be
> >
> > marked
> >
> >>as not visible. Then you can implement some logic (via a trigger) such
> >
> > that
> >
> >>if a row is updated when it's marked 'not visible', it will be marked
> >>'visible' again.
> >>
> >>--
> >>Adam Machanic
> >>SQL Server MVP
> >>http://www.sqljunkies.com/weblog/amachanic
> >>--
> >>
> >>
> >>"Leila" <Leilas@.hotpop.com> wrote in message
> >>news:eU2lWsE5EHA.1596@.tk2msftngp13.phx.gbl...
> >>
> >>Hi all,
> >>Suppose that client A and client B read a record and B begins editing
> >>
> >>that.
> >>
> >>Meanwhile A attempts to delete the record. Our project's rules says
that
> >>
> >>the
> >>
> >>record must not be deleted while it is being edited by other user.
> >
> > Whereas
> >
> >>our clients are disconnected, client B cannot lock the record. How can
I
> >>solve this problem?
> >>Any help would be greatly appreciated.
> >>Leila
> >>
> >>
> >>
> >>
> >
> >|||"Leila" <Leilas@.hotpop.com> wrote in message
news:Os6KBVG5EHA.1296@.TK2MSFTNGP10.phx.gbl...
> If client B crashes, it cannot submit the changes and make the record
> visible again. I mean the record will remain invisible
>
That's correct, and in that case the DBA will have to get involved and fix
it.
No scheme is perfect, unfortunately.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||"Leila" <Leilas@.hotpop.com> wrote in message
news:utxzFVG5EHA.1296@.TK2MSFTNGP10.phx.gbl...
> Please just focus on this problem: client A must be prevented from
deleting
> the record which is being edited!
Search Google and the archives of this group for "optimistic locking"
(my preference, always) and "pessimistic locking".
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||Leila wrote:
> Thanks Zach,
> Actually each record has lots of details and the poor user must take
> time and accuracy to edit these particular records. This is why we
> need to protect the row while it's being edited. The logics and rules
> have a lot of details to be explained here :(
> Please just focus on this problem: client A must be prevented from
> deleting the record which is being edited!
>
Coming in late here, but, you might also consider using a partitioned
view: Two tables: one for ready rows and one for rows being edited. This
will eliminate any query hit when accessing the "ready" table as it is
separate from the editing table. Your application could be designed to
show the edited rows and "unlock" them if someone requests the
application do so. Maybe only by users with certain rights. So if a
client crashes before the edit is complete, the row can be recovered
without much intervention.
--
David Gugick
Imceda Software
www.imceda.com|||Can this be a solution? suppose that:
client A will attempt to delete the row. It finds out that the row has been
marked (client B is editing). It sends a message to B to get a confirmation.
If B confirms that it is editing the row, delete will fail unless it will be
successful.
But I'm not sure that if COM or Notification Services can help for this
communication.
What is your idea?
Thanks!
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:eBivEgG5EHA.2580@.TK2MSFTNGP10.phx.gbl...
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:Os6KBVG5EHA.1296@.TK2MSFTNGP10.phx.gbl...
> > If client B crashes, it cannot submit the changes and make the record
> > visible again. I mean the record will remain invisible
> >
> That's correct, and in that case the DBA will have to get involved and fix
> it.
> No scheme is perfect, unfortunately.
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>|||"Leila" <Leilas@.hotpop.com> wrote in message
news:efspn6G5EHA.2428@.TK2MSFTNGP14.phx.gbl...
> Can this be a solution? suppose that:
> client A will attempt to delete the row. It finds out that the row has
been
> marked (client B is editing). It sends a message to B to get a
confirmation.
> If B confirms that it is editing the row, delete will fail unless it will
be
> successful.
> But I'm not sure that if COM or Notification Services can help for this
> communication.
> What is your idea?
> Thanks!
>
Again, I don't think the database should have any idea what the UI is
doing (so it shouldn't know that ClientB is editing). In my opinion, loose
coupling between databases and applications is very important. Giving the
database knowledge of what the UI is doing very tightly couples them.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--|||Interesting idea!
But if these communication are done only between application, does it still
mean that DB is aware of UI?
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:#eZ8q9G5EHA.924@.TK2MSFTNGP14.phx.gbl...
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:efspn6G5EHA.2428@.TK2MSFTNGP14.phx.gbl...
> > Can this be a solution? suppose that:
> > client A will attempt to delete the row. It finds out that the row has
> been
> > marked (client B is editing). It sends a message to B to get a
> confirmation.
> > If B confirms that it is editing the row, delete will fail unless it
will
> be
> > successful.
> > But I'm not sure that if COM or Notification Services can help for this
> > communication.
> > What is your idea?
> > Thanks!
> >
> Again, I don't think the database should have any idea what the UI is
> doing (so it shouldn't know that ClientB is editing). In my opinion,
loose
> coupling between databases and applications is very important. Giving the
> database knowledge of what the UI is doing very tightly couples them.
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
>|||On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
>Suppose that client A and client B read a record and B begins editing that.
>Meanwhile A attempts to delete the record. Our project's rules says that the
>record must not be deleted while it is being edited by other user. Whereas
>our clients are disconnected, client B cannot lock the record. How can I
>solve this problem?
What you are talking about is pessimistic locking. This is currently
not fashionable, instead, people prefer to do optimistic locking,
which assumes that the collisions will occur so rarely, that they are
hardly worth worrying about - they are still detected and handled, but
basically by letting the *second* client have his way with the record,
and giving a "sorry" message to the first client.
BOL suggests you do pessimistic locking by putting a field into a
record and using it to indicate when the record is locked. This is
really crude, but it does work even in the stateless-client
(disconnected) environments everyone has these days. If you have rich
(thick, smart, whatever) clients only who keep connections open,
SQLServer *does* support pessimistic locking, though it's a bit tricky
and indifferently documented.
BEGIN TRANSACTION
SELECT pk FROM mytable with (updlock)
...
will keep a record locked from deletion as long as the client keeps
his connection alive - thirty seconds, thirty hours, whatever. But
you really don't want a lot of this going on, for one thing it will
block table scans at a read-commited (default) isolation level.
Or, instead of lock fields in a record, you can implement a separate
lock table that lists locked tablename and PK. This is probably
better, but still a lot of work.
Note that you get additional options if you run in Yukon (or Oracle).
Good luck!
J.|||Thanks David,
How will be the recovery process? Can it be an automatic task?
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OxZKf1G5EHA.2664@.TK2MSFTNGP10.phx.gbl...
> Leila wrote:
> > Thanks Zach,
> > Actually each record has lots of details and the poor user must take
> > time and accuracy to edit these particular records. This is why we
> > need to protect the row while it's being edited. The logics and rules
> > have a lot of details to be explained here :(
> > Please just focus on this problem: client A must be prevented from
> > deleting the record which is being edited!
> >
> >
> Coming in late here, but, you might also consider using a partitioned
> view: Two tables: one for ready rows and one for rows being edited. This
> will eliminate any query hit when accessing the "ready" table as it is
> separate from the editing table. Your application could be designed to
> show the edited rows and "unlock" them if someone requests the
> application do so. Maybe only by users with certain rights. So if a
> client crashes before the edit is complete, the row can be recovered
> without much intervention.
> --
> David Gugick
> Imceda Software
> www.imceda.com
>|||Thanks J!
I cannot use lock hints because the connection is closed after reading the
row.
Storing the PK in separate table is good idea but if the client which has
done this, crashes, then it cannot submit the changes, therefore the row
remains locked actually.
"JXStern" <JXSternChangeX2R@.gte.net> wrote in message
news:khd6s09cqnuegm95o1adbsg6449l9efdvd@.4ax.com...
> On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
> >Suppose that client A and client B read a record and B begins editing
that.
> >Meanwhile A attempts to delete the record. Our project's rules says that
the
> >record must not be deleted while it is being edited by other user.
Whereas
> >our clients are disconnected, client B cannot lock the record. How can I
> >solve this problem?
> What you are talking about is pessimistic locking. This is currently
> not fashionable, instead, people prefer to do optimistic locking,
> which assumes that the collisions will occur so rarely, that they are
> hardly worth worrying about - they are still detected and handled, but
> basically by letting the *second* client have his way with the record,
> and giving a "sorry" message to the first client.
> BOL suggests you do pessimistic locking by putting a field into a
> record and using it to indicate when the record is locked. This is
> really crude, but it does work even in the stateless-client
> (disconnected) environments everyone has these days. If you have rich
> (thick, smart, whatever) clients only who keep connections open,
> SQLServer *does* support pessimistic locking, though it's a bit tricky
> and indifferently documented.
> BEGIN TRANSACTION
> SELECT pk FROM mytable with (updlock)
> ...
> will keep a record locked from deletion as long as the client keeps
> his connection alive - thirty seconds, thirty hours, whatever. But
> you really don't want a lot of this going on, for one thing it will
> block table scans at a read-commited (default) isolation level.
> Or, instead of lock fields in a record, you can implement a separate
> lock table that lists locked tablename and PK. This is probably
> better, but still a lot of work.
> Note that you get additional options if you run in Yukon (or Oracle).
> Good luck!
> J.
>|||Thanks J!
I cannot use lock hints because the connection is closed after reading the
row.
Storing the PK in separate table is good idea but if the client which has
done this, crashes, then it cannot submit the changes, therefore the row
remains locked actually.
"JXStern" <JXSternChangeX2R@.gte.net> wrote in message
news:khd6s09cqnuegm95o1adbsg6449l9efdvd@.4ax.com...
> On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
> >Suppose that client A and client B read a record and B begins editing
that.
> >Meanwhile A attempts to delete the record. Our project's rules says that
the
> >record must not be deleted while it is being edited by other user.
Whereas
> >our clients are disconnected, client B cannot lock the record. How can I
> >solve this problem?
> What you are talking about is pessimistic locking. This is currently
> not fashionable, instead, people prefer to do optimistic locking,
> which assumes that the collisions will occur so rarely, that they are
> hardly worth worrying about - they are still detected and handled, but
> basically by letting the *second* client have his way with the record,
> and giving a "sorry" message to the first client.
> BOL suggests you do pessimistic locking by putting a field into a
> record and using it to indicate when the record is locked. This is
> really crude, but it does work even in the stateless-client
> (disconnected) environments everyone has these days. If you have rich
> (thick, smart, whatever) clients only who keep connections open,
> SQLServer *does* support pessimistic locking, though it's a bit tricky
> and indifferently documented.
> BEGIN TRANSACTION
> SELECT pk FROM mytable with (updlock)
> ...
> will keep a record locked from deletion as long as the client keeps
> his connection alive - thirty seconds, thirty hours, whatever. But
> you really don't want a lot of this going on, for one thing it will
> block table scans at a read-commited (default) isolation level.
> Or, instead of lock fields in a record, you can implement a separate
> lock table that lists locked tablename and PK. This is probably
> better, but still a lot of work.
> Note that you get additional options if you run in Yukon (or Oracle).
> Good luck!
> J.
>|||Leila,
I'm coming in late, too, but I notice that you have said some things won't
work (or need more work) because they don't handle this situation:
Client X is off-line editing row R. [Business requirements say R may
not be deleted at this point.]
Client X crashes (or perhaps keeps R open for years without crashing?).
This is definitely a situation you need to address. Do the business
requirements address it at all?
(If the business requirements are incomplete, or include "clients never
crash", and "clients never take forever to finish editing", you could
suggest some rules yourself, or you can wait until the first complaint
about a locked row following a crash, at which point someone
might realize there need to be rules about this.)
Can you find out what is supposed to happen in this situation?
Steve Kass
Drew University
Leila wrote:
>Thanks J!
>I cannot use lock hints because the connection is closed after reading the
>row.
>Storing the PK in separate table is good idea but if the client which has
>done this, crashes, then it cannot submit the changes, therefore the row
>remains locked actually.
>"JXStern" <JXSternChangeX2R@.gte.net> wrote in message
>news:khd6s09cqnuegm95o1adbsg6449l9efdvd@.4ax.com...
>
>>On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
>>
>>Suppose that client A and client B read a record and B begins editing
>>
>that.
>
>>Meanwhile A attempts to delete the record. Our project's rules says that
>>
>the
>
>>record must not be deleted while it is being edited by other user.
>>
>Whereas
>
>>our clients are disconnected, client B cannot lock the record. How can I
>>solve this problem?
>>
>>What you are talking about is pessimistic locking. This is currently
>>not fashionable, instead, people prefer to do optimistic locking,
>>which assumes that the collisions will occur so rarely, that they are
>>hardly worth worrying about - they are still detected and handled, but
>>basically by letting the *second* client have his way with the record,
>>and giving a "sorry" message to the first client.
>>BOL suggests you do pessimistic locking by putting a field into a
>>record and using it to indicate when the record is locked. This is
>>really crude, but it does work even in the stateless-client
>>(disconnected) environments everyone has these days. If you have rich
>>(thick, smart, whatever) clients only who keep connections open,
>>SQLServer *does* support pessimistic locking, though it's a bit tricky
>>and indifferently documented.
>>BEGIN TRANSACTION
>>SELECT pk FROM mytable with (updlock)
>>...
>>will keep a record locked from deletion as long as the client keeps
>>his connection alive - thirty seconds, thirty hours, whatever. But
>>you really don't want a lot of this going on, for one thing it will
>>block table scans at a read-commited (default) isolation level.
>>Or, instead of lock fields in a record, you can implement a separate
>>lock table that lists locked tablename and PK. This is probably
>>better, but still a lot of work.
>>Note that you get additional options if you run in Yukon (or Oracle).
>>Good luck!
>>J.
>>
>
>|||On Fri, 17 Dec 2004 23:31:27 +0330, "Leila" <Leilas@.hotpop.com> wrote:
>Thanks J!
>I cannot use lock hints because the connection is closed after reading the
>row.
>Storing the PK in separate table is good idea but if the client which has
>done this, crashes, then it cannot submit the changes, therefore the row
>remains locked actually.
Right, that's the natural problem with that approach. You simply
write a master unlocker applet for when it happens, and let only the
application supervisor have access to it. Crufty, but workable.
People built systems that way all the time, in the 1970s!
J.|||"Leila" <Leilas@.hotpop.com> wrote in message
news:uRli$uF5EHA.3120@.TK2MSFTNGP12.phx.gbl...
> Thanks,
> Actually I thought about that but I don't know what to do if the client
> crashes? Because the PK remains in that table and no longer will be
> deleted..
Typically in cases like this you use a "deadman's switch"
Store the time the row is copied to the new table.
Then every X hours or minutes run a scheduled task that checks this table.
Any rows older than Y time are removed, with the assumption that the client
crashed, etc.
s
>
> <myelton1@.Lincare.com> wrote in message
> news:1103300244.952647.179750@.z14g2000cwz.googlegroups.com...
> > I'm not sure what you mean by 'our clients are disconnected' but you
> > could throw the Primary Key value of the row being edited into a table.
> > A "this row is locked" table of sorts. Then any other user reading
> > that row you require your application to check your Lock table for the
> > Primary key value, if it is found then you return a message saying "you
> > can't delete this record, it's being edited by another user." Or
> > something like that, we've done that for our OLTP system in the past.
> >
>|||Thanks Steve,
You mentioned that:
<Client X is off-line editing row R. [Business requirements say R may
not be deleted at this point.]>
I think I haven't realized your meaning,
How the row may not be deleted? Who prevents it?
"Steve Kass" <skass@.drew.edu> wrote in message
news:#z2eA0L5EHA.2568@.TK2MSFTNGP10.phx.gbl...
> Leila,
> I'm coming in late, too, but I notice that you have said some things
won't
> work (or need more work) because they don't handle this situation:
> Client X is off-line editing row R. [Business requirements say R may
> not be deleted at this point.]
> Client X crashes (or perhaps keeps R open for years without crashing?).
> This is definitely a situation you need to address. Do the business
> requirements address it at all?
> (If the business requirements are incomplete, or include "clients never
> crash", and "clients never take forever to finish editing", you could
> suggest some rules yourself, or you can wait until the first complaint
> about a locked row following a crash, at which point someone
> might realize there need to be rules about this.)
> Can you find out what is supposed to happen in this situation?
> Steve Kass
> Drew University
>
> Leila wrote:
> >Thanks J!
> >I cannot use lock hints because the connection is closed after reading
the
> >row.
> >Storing the PK in separate table is good idea but if the client which has
> >done this, crashes, then it cannot submit the changes, therefore the row
> >remains locked actually.
> >
> >"JXStern" <JXSternChangeX2R@.gte.net> wrote in message
> >news:khd6s09cqnuegm95o1adbsg6449l9efdvd@.4ax.com...
> >
> >
> >>On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
> >>
> >>
> >>Suppose that client A and client B read a record and B begins editing
> >>
> >>
> >that.
> >
> >
> >>Meanwhile A attempts to delete the record. Our project's rules says
that
> >>
> >>
> >the
> >
> >
> >>record must not be deleted while it is being edited by other user.
> >>
> >>
> >Whereas
> >
> >
> >>our clients are disconnected, client B cannot lock the record. How can
I
> >>solve this problem?
> >>
> >>
> >>What you are talking about is pessimistic locking. This is currently
> >>not fashionable, instead, people prefer to do optimistic locking,
> >>which assumes that the collisions will occur so rarely, that they are
> >>hardly worth worrying about - they are still detected and handled, but
> >>basically by letting the *second* client have his way with the record,
> >>and giving a "sorry" message to the first client.
> >>
> >>BOL suggests you do pessimistic locking by putting a field into a
> >>record and using it to indicate when the record is locked. This is
> >>really crude, but it does work even in the stateless-client
> >>(disconnected) environments everyone has these days. If you have rich
> >>(thick, smart, whatever) clients only who keep connections open,
> >>SQLServer *does* support pessimistic locking, though it's a bit tricky
> >>and indifferently documented.
> >>
> >>BEGIN TRANSACTION
> >>SELECT pk FROM mytable with (updlock)
> >>...
> >>
> >>will keep a record locked from deletion as long as the client keeps
> >>his connection alive - thirty seconds, thirty hours, whatever. But
> >>you really don't want a lot of this going on, for one thing it will
> >>block table scans at a read-commited (default) isolation level.
> >>
> >>Or, instead of lock fields in a record, you can implement a separate
> >>lock table that lists locked tablename and PK. This is probably
> >>better, but still a lot of work.
> >>
> >>Note that you get additional options if you run in Yukon (or Oracle).
> >>
> >>Good luck!
> >>
> >>J.
> >>
> >>
> >>
> >
> >
> >
> >|||Leila wrote:
>Thanks Steve,
>You mentioned that:
><Client X is off-line editing row R. [Business requirements say R may
>not be deleted at this point.]>
>I think I haven't realized your meaning,
>How the row may not be deleted? Who prevents it?
>
Apparently I misunderstood. I thought preventing the delete was
exactly what you were trying to accomplish. In order to know how
to accomplish it, I suggested more information was needed.
SK
>
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:#z2eA0L5EHA.2568@.TK2MSFTNGP10.phx.gbl...
>
>>Leila,
>> I'm coming in late, too, but I notice that you have said some things
>>
>won't
>
>>work (or need more work) because they don't handle this situation:
>> Client X is off-line editing row R. [Business requirements say R may
>>not be deleted at this point.]
>> Client X crashes (or perhaps keeps R open for years without crashing?).
>>This is definitely a situation you need to address. Do the business
>>requirements address it at all?
>>(If the business requirements are incomplete, or include "clients never
>>crash", and "clients never take forever to finish editing", you could
>>suggest some rules yourself, or you can wait until the first complaint
>>about a locked row following a crash, at which point someone
>>might realize there need to be rules about this.)
>>Can you find out what is supposed to happen in this situation?
>>Steve Kass
>>Drew University
>>
>>Leila wrote:
>>
>>Thanks J!
>>I cannot use lock hints because the connection is closed after reading
>>
>the
>
>>row.
>>Storing the PK in separate table is good idea but if the client which has
>>done this, crashes, then it cannot submit the changes, therefore the row
>>remains locked actually.
>>"JXStern" <JXSternChangeX2R@.gte.net> wrote in message
>>news:khd6s09cqnuegm95o1adbsg6449l9efdvd@.4ax.com...
>>
>>
>>On Fri, 17 Dec 2004 18:00:23 +0330, "Leila" <Leilas@.hotpop.com> wrote:
>>
>>
>>Suppose that client A and client B read a record and B begins editing
>>
>>
>>that.
>>
>>
>>Meanwhile A attempts to delete the record. Our project's rules says
>>
>that
>
>>
>>the
>>
>>
>>record must not be deleted while it is being edited by other user.
>>
>>
>>Whereas
>>
>>
>>our clients are disconnected, client B cannot lock the record. How can
>>
>I
>
>>solve this problem?
>>
>>
>>What you are talking about is pessimistic locking. This is currently
>>not fashionable, instead, people prefer to do optimistic locking,
>>which assumes that the collisions will occur so rarely, that they are
>>hardly worth worrying about - they are still detected and handled, but
>>basically by letting the *second* client have his way with the record,
>>and giving a "sorry" message to the first client.
>>BOL suggests you do pessimistic locking by putting a field into a
>>record and using it to indicate when the record is locked. This is
>>really crude, but it does work even in the stateless-client
>>(disconnected) environments everyone has these days. If you have rich
>>(thick, smart, whatever) clients only who keep connections open,
>>SQLServer *does* support pessimistic locking, though it's a bit tricky
>>and indifferently documented.
>>BEGIN TRANSACTION
>>SELECT pk FROM mytable with (updlock)
>>...
>>will keep a record locked from deletion as long as the client keeps
>>his connection alive - thirty seconds, thirty hours, whatever. But
>>you really don't want a lot of this going on, for one thing it will
>>block table scans at a read-commited (default) isolation level.
>>Or, instead of lock fields in a record, you can implement a separate
>>lock table that lists locked tablename and PK. This is probably
>>better, but still a lot of work.
>>Note that you get additional options if you run in Yukon (or Oracle).
>>Good luck!
>>J.
>>
>>
>>
>>
>
>|||You have a dual problem, i.e. there is no differences with being disconnected
and crashing, therefore you won't be able to deal efficiently with both
situations. You will need to mark your record as being edited prior to
disconnecting, then you need to have a process that cleans up those records
that were marked in edit mode and had a long time lapse (clients crashing).
Therefore you will also need to record the date/time the record was placed in
edit mode in order to perform this clean up. As far as implementation
schemes, you can think of a few ways to do that. The only lingering problem
is that you may have records that can potentially stay uneditable for a
relatively long period of time. I can suggest an AuditDate as an additional
column in your table that will be updated as soon as the client starts the
edit process, your update process will look at that date and if it is not the
same then you know someone else is editing it.
I hope this will help.
"Leila" wrote:
> Hi all,
> Suppose that client A and client B read a record and B begins editing that.
> Meanwhile A attempts to delete the record. Our project's rules says that the
> record must not be deleted while it is being edited by other user. Whereas
> our clients are disconnected, client B cannot lock the record. How can I
> solve this problem?
> Any help would be greatly appreciated.
> Leila
>
>