Search Results

Search found 546 results on 22 pages for 'rollback'.

Page 4/22 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Oracle database on trigger fail rollback

    - by GigaPr
    Hi I want to create a trigger that execute on update of a table. in particular on update of a table i want to update another table via a trigger but if the trigger fails (REFERENTIAL INTEGRITY-- ENTITY INTEGRITY) i do not want to execute the update anymore. Any suggestion on how to perform this? Is it better to use a trigger or do it anagrammatically via a stored procedure? Thanks

    Read the article

  • What is the best way to restore(rollback) data in an application to a specified state(date) ?

    - by panzerschreck
    Hello, An example would set the context right, the example below captures the various states of the entity, which needs to be reverted(rolled back) . State 1 - Recorded on 01-Mar-2010 Column1 Column2 Data1 0.56 State 2 - Recorded on 02-Mar-2010 Column1 Column2 Data1 0.57 State 3 - Recorded on 03-Mar-2010 Column1 Column2 Data1 0.58 User notices that state3 is not what he intended to be in, decides to revert back to state2. One approach that I can think of, without modifying the entity is via "auditing" all the inserts/updates, as below, the rollback information captures the data just before the updates/modifications on the entity, so that it can be applied in an order when you need to revert.Please note that changing the entity's schema, is not an option. Rollback - R1 recorded on 01-Mar-2010 Column1 Column2 Data1 0.56 Rollback - R2 Recorded on 02-Mar-2010 Column1 Column2 Data1 0.56 Rollback - R3 Recorded on 03-Mar-2010 Column1 Column2 Data1 0.57 So, to get to state2 , we would start with rollback information R1,apply R2 onto it. Is there a better approach to achieve this ? Thanks for your time.

    Read the article

  • Why are transactions not rolling back when using SpringJUnit4ClassRunner/MySQL/Spring/Hibernate

    - by Trevor
    I am doing unit testing and I expect that all data committed to the MySQL database will be rolled back... but this isn't the case. The data is being committed, even though my log was showing that the rollback was happening. I've been wrestling with this for a couple days so my setup has changed quite a bit, here's my current setup. LoginDAOTest.java: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"file:web/WEB-INF/applicationContext-test.xml", "file:web/WEB-INF/dispatcher-servlet-test.xml"}) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) public class UserServiceTest { private UserService userService; @Test public void should_return_true_when_user_is_logged_in () throws Exception { String[] usernames = {"a","b","c","d"}; for (String username : usernames) { userService.logUserIn(username); assertThat(userService.isUserLoggedIn(username), is(equalTo(true))); } } ApplicationContext-Text.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/test"/> <property name="username" value="root"/> <property name="password" value="Ecosim07"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> <bean id="userService" class="Service.UserService"> <property name="userDAO" ref="userDAO"/> </bean> <bean id="userDAO" class="DAO.UserDAO"> <property name="hibernateTemplate" ref="hibernateTemplate"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <value>/himapping/User.hbm.xml</value> <value>/himapping/setup.hbm.xml</value> <value>/himapping/UserHistory.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> </beans> I have been reading about the issue, and I've already checked to ensure that the MySQL database tables are setup to use InnoDB. Also I have been able to successfully implement rolling back of transactions outside of my testing suite. So this must be some sort of incorrect setup on my part. Any help would be greatly appreciated :)

    Read the article

  • How to salvage SQL server 2008 query from KILLED/ROLLBACK state?

    - by littlegreen
    I have a stored procedure that inserts batches of millions of rows, emerging from a certain query, into an SQL database. It has one parameter selecting the batch; when this parameter is omitted, it will gather a list of batches and recursively call itself, in order to iterate over batches. In (pseudo-)code, it looks something like this: CREATE PROCEDURE spProcedure AS BEGIN IF @code = 0 BEGIN ... WHILE @@Fetch_Status=0 BEGIN EXEC spProcedure @code FETCH NEXT ... INTO @code END END ELSE BEGIN -- Disable indexes ... INSERT INTO table SELECT (...) -- Enable indexes ... Now it can happen that this procedure is slow, for whatever reason: it can't get a lock, one of the indexes it uses is misdefined or disabled. In that case, I want to be able kill the procedure, truncate and recreate the resulting table, and try again. However, when I try and kill the procedure, the process frequently oozes into a KILLED/ROLLBACK state from which there seems to be no return. From Google I have learned to do an sp_lock, find the spid, and then kill it with KILL <spid>. But when I try to kill it, it tells me SPID 75: transaction rollback in progress. Estimated rollback completion: 0%. Estimated time remaining: 554 seconds. I did find a forum message hinting that another spid should be killed before the other one can start a rollback. But that didn't work for me either, plus I do not understand, why that would be the case... could it be because I am recursively calling my own stored procedure? (But it should be having the same spid, right?) In any case, my process is just sitting there, being dead, not responding to kills, and locking the table. This is very frustrating, as I want to go on developing my queries, not waiting hours on my server sitting dead while pretending to be finishing a supposed rollback. Is there some way in which I can tell the server not to store any rollback information for my query? Or not to allow any other queries to interfere with the rollback, so that it will not take so long? Or how to rewrite my query in a better way, or how kill the process successfully without restarting the server?

    Read the article

  • How to salvage SQL server 2008 query from KILLED/ROLLBACK state without waiting half a day?

    - by littlegreen
    I have a stored procedure that inserts batches of millions of rows, emerging from a certain query, into an SQL database. It has one parameter selecting the batch; when this parameter is omitted, it will gather a list of batches and recursively call itself, in order to iterate over batches. In (pseudo-)code, it looks something like this: CREATE PROCEDURE spProcedure AS BEGIN IF @code = 0 BEGIN ... WHILE @@Fetch_Status=0 BEGIN EXEC spProcedure @code FETCH NEXT ... INTO @code END END ELSE BEGIN -- Disable indexes ... INSERT INTO table SELECT (...) -- Enable indexes ... Now it can happen that this procedure is slow, for whatever reason: it can't get a lock, one of the indexes it uses is misdefined or disabled. In that case, I want to be able kill the procedure, truncate and recreate the resulting table, and try again. However, when I try and kill the procedure, the process frequently oozes into a KILLED/ROLLBACK state from which there seems to be no return. From Google I have learned to do an sp_lock, find the spid, and then kill it with KILL <spid>. But when I try to kill it, it tells me SPID 75: transaction rollback in progress. Estimated rollback completion: 0%. Estimated time remaining: 554 seconds. I did find a forum message hinting that another spid should be killed before the other one can start a rollback. But that didn't work for me either, plus I do not understand, why that would be the case... could it be because I am recursively calling my own stored procedure? (But it should be having the same spid, right?) In any case, my process is just sitting there, being dead, not responding to kills, and locking the table. This is very frustrating, as I want to go on developing my queries, not waiting hours on my server sitting dead while pretending to be finishing a supposed rollback. Is there some way in which I can tell the server not to store any rollback information for my query? Or not to allow any other queries to interfere with the rollback, so that it will not take so long? Or how to rewrite my query in a better way, or how kill the process successfully without restarting the server?

    Read the article

  • Transactions in codeigniter with multiple tables.

    - by Ethan
    Hey SO, I'm new to transactions in general, but especially with CodeIgniter. I'm using InnoDB and everything, but my transactions aren't rolling back when I want them to. Here's my code (slightly simplified). $dog_db = $this->load->database('dog', true); $dog_db->trans_begin(); $dog_id = $this->dogs->insert($new_dog); //Gets primary key of insert if(!$dog_id) { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } $new_review['dog_id'] = $dog_id; $new_review['user_id'] = $user_id; $new_review['date_added'] = time(); if(!$this->reviews->insert($new_review)) //If the insert fails { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } //ADD DESCRIPTION $new_description['description'] = $add_dog['description']; $new_description['dog_id'] = $dog_id; $new_description['user_id'] = $user_id; $new_description['date_added'] = time(); if(!$this->descriptions->insert($new_description)) { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } $booze_db->trans_rollback(); //THIS IS JUST TO SEE IF IT WORKS throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); $booze_db->trans_commit(); } catch(Exception $e) { echo $e->getMessage(); } I'm not getting any error messages, but it's not rolling back either. It should roll back at that final trans_rollback right before the commit. My models are all on the "dog" database, so I think that the transaction would carry into the models' functions. Maybe you just can't use models like this. Any help would be greatly appreciated! Thanks!

    Read the article

  • Rolling back file moves, folder deletes and mysql queries

    - by Workoholic
    This has been bugging me all day and there is no end in sight. When the user of my php application adds a new update and something goes wrong, I need to be able to undo a complex batch of mixed commands. They can be mysql update and insert queries, file deletes and folder renaming and creations. I can track the status of all insert commands and undo them if an error is thrown. But how do I do this with the update statements? Is there a smart way (some design pattern?) to keep track of such changes both in the file structure and the database? My database tables are MyISAM. It would be easy to just convert everything to InnoDB, so that I can use transactions. That way I would only have to deal with the file and folder operations. Unfortunately, I cannot assume that all clients have InnoDB support. It would also require me to convert many tables in my database to InnoDB, which I am hesitant to do.

    Read the article

  • Grails Services / Transactions / RuntimeException / Testing

    - by Rob
    I'm testing come code in a service with transactional set to true , which talks to a customer supplied web service the main part of which looks like class BarcodeService { .. /// some stuff ... try{ cancelBarCodeResponse = cancelBarCode(cancelBarcodeRequest) } catch(myCommsException e) { throw new RuntimeException(e) } ... where myCommsException extends Exception .. I have a test which looks like // As no connection from my machine, it should fail .. shouldFailWithCause(RuntimeException){ barcodeServices.cancelBarcodeDetails() } The test fails cause it's catching a myCommsException rather than the RuntimeException i thought i'd converted it to .. Anyone care to point out what i'm doing wrong ? Also will the fact that it's not a RuntimeException mean any transaction related info done before my try/catch actually be written out rather than thrown away ?? Thanks

    Read the article

  • Have I to count transactions before rollback one in catch block in T-SQL?

    - by abatishchev
    I have next block in the end of each my stored procedure for SQL Server 2008 BEGIN TRY BEGIN TRAN -- my code COMMIT END TRY BEGIN CATCH IF (@@trancount > 0) BEGIN ROLLBACK DECLARE @message NVARCHAR(MAX) DECLARE @state INT SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE() RAISERROR (@message, 11, @state) END END CATCH Is it possible to switch CATCH-block to BEGIN CATCH ROLLBACK DECLARE @message NVARCHAR(MAX) DECLARE @state INT SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE() RAISERROR (@message, 11, @state) END CATCH or just BEGIN CATCH ROLLBACK END CATCH ?

    Read the article

  • Is it okay to rollback code if your client refuses to pay you?

    - by JustinY
    A friend of mine did some contracting work to add localization support to an existing mobile app. He was not contracted to add any other features or fix any already existing bugs. He has finished his work, but the client refuses to pay him because of an already existing bug that he hasn't fixed. The only card my friend has left is to rollback the server code to the state it was before he began working, which will probably break the mobile app and hopefully force the client's hand. Is this legal? Is there a better way to handle the situation?

    Read the article

  • JTA Transaction: What happens if an exception happens but rollback is not called on the transaction?

    - by kellyfj
    We have some third party code wherein they do the following 1) Create a User Transaction e.g. txn = (UserTransaction)ctx.lookup( "UserTransaction" ); txn.begin( ); 2) Do some work persisting to the database (via JPA) to a MySQL database 3) txn.commit() They have Exception blocks but NONE of them call txn.rollback. Good coding practice says they NEED to call rollback if an exception occurs but my question is If the txn is not commited, and an exception occurs what is the negative effect of them NOT calling rollback?

    Read the article

  • Installshield Development Error durring the Installation process

    - by Alopekos
    Hey guys, I've been stuck by a problem for the past couple days that makes no sense to me. My installer builds fine in the Installshiled IDE but when it is about to finish the installation, int gets two errors then rollbacks: installation failure. Right when the install bar is at about 100%, an error box pops up that states this: "Error 1001.Exception occurred while initializing the installation: System.IO.FileLoadException: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)." The box pops up once, then the installer flashes its status to "rollback" then pops up another error box, then once 'ok'ed it procedes to rollback as usual. I don't understand that error message so i looked in the msi loggings and found this: "InstallShield 13:20:08: Initializing Property Bag... InstallShield 13:20:08: Getting file count from property bag InstallShield 13:20:08: File Count : 7 InstallShield 13:20:08: Sorting Based On Order... InstallShield 13:20:08: This setup is running on a 32-bit Windows...No need to load ISBEW64.exe InstallShield 13:20:08: Registering file C:\Program Files\Cadwell\Easy III\QMWSChartDataServer.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\DataDelivery.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\QMGlobalData.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\QMAdoDB.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\QMPatientData.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\MedShareGlobalData.dll (32-bit) InstallShield 13:20:09: Registering file C:\Program Files\Cadwell\Easy III\MedDirectory.dll (32-bit) InstallShield 13:20:09: Begin Comitting Property Bag InstallShield 13:20:09: Write KeyList count InstallShield 13:20:09: Finished Comitting Property Bag Action 13:20:09: _EBDE7916DF6AF3B644016C54F66930DC.commit. Action 13:20:09: _EBDE7916DF6AF3B644016C54F66930DC.rollback. Action 13:20:09: _EBDE7916DF6AF3B644016C54F66930DC.install. Error 1001.Exception occurred while initializing the installation: System.IO.FileLoadException: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019). MSI (s) (34!84) [13:20:26:455]: Info 2769.Custom Action _EBDE7916DF6AF3B644016C54F66930DC.install did not close 1 MSIHANDLEs. Action ended 13:20:26: InstallFinalize. Return value 3. Action 13:20:26: Rollback. Rolling back action: Rollback: _EBDE7916DF6AF3B644016C54F66930DC.install Rollback: _EBDE7916DF6AF3B644016C54F66930DC.rollback Error 1001.Exception occurred while initializing the installation: System.IO.FileLoadException: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019). MSI (s) (34!E8) [13:20:27:036]: Info 2769.Custom Action _EBDE7916DF6AF3B644016C54F66930DC.rollback did not close 1 MSIHANDLEs. Rollback: _EBDE7916DF6AF3B644016C54F66930DC.commit Rollback: ISSelfRegisterFiles Rollback: Registering modules Rollback: Registering type libraries Rollback: Writing system registry values Rollback: Registering program identifiers" All rollbacking commands after this point. For some reason it looks like to me that installshield is trying to launch my program before it finishes the installation, even when I told it to prompt the user to decide to launch. Is this a registering command system that makes it attemp or what? I've been scouring the web all day and I've found some ideas, but I havent seen any solutions as of yet. The installers that I've tried(and failed) have always needed to be Setup.exes, when i try to build a .msi only setup I get this error message. It may help someone who knows more about this system than I do. Your project contains InstallShield prerequisites. A Setup.exe setup launcher is required if you are build a release that includes InstallShield prerequisites. Change your release settings to build Setup.exe, or remove the prerequisites from your project. -7076 There's nothing on the site that has anything from the error code, so I'm at a loss. Thanks for any help possible, I'm an intern and I'm fresh out of ideas... Josh System: XP SP3 Installshield 2010 Pro Install being tested on a VirtualPC

    Read the article

  • Is it necessary to write ROLLBACK if queries fail?

    - by Donator
    I write mysql_query("SET AUTOCOMMIT=0"); mysql_query("START TRANSACTION"); before I write all queries. Then check if all of them are true and then write: mysql_query("COMMIT"); But if one of query fails, I just pass COMMIT query. So do I really need ROLLBACK function if one of the queries fail? Because without ROLLBACK it also works. Thanks.

    Read the article

  • Does rails do a rollback if I use begin...rescue?

    - by codeman73
    I'd like to add a begin...rescue block to one of my controllers create method, in order to log better info and construct the correct error message to return to the client. Does the rescue in any way 'interrupt' the rollback process? I'm assuming rails automatically does a rollback. When does it happen? Has it already happened by the time I get in the rescue clause? I'm using mySQL on Dreamhost and I think they use innoDB.

    Read the article

  • Transaction Boundaries and Rollbacks in Oracle SOA Suite

    - by Antonella Giovannetti
    A new eCourse/video is available in the Oracle Learning Library, "Transaction Boundaries and Rollbacks in Oracle SOA Suite" . The course covers: Definition of transaction, XA, Rollback and transaction boundary. BPEL transaction boundaries from a fault propagation point of view Parameters bpel.config.transaction and bpel.config.oneWayDeliveryPolicy for the configuration of both synchronous and asynchronous BPEL processes. Transaction behavior in Mediator Rollback scenarios based on type of faults Rollback using bpelx:rollback within a <throw> activity. The video is accessible here

    Read the article

  • How to uninstall Internet Explorer 9 or Rollback to Internet Explorer 8?

    - by Denja
    Hi, I wanted to try and I installed Internet Explorer 9 and now Firefox is acting strangely, For example the URL Windows aren't opening in time, when I Maximize Firefox the window Title is blinking crazy. But Google Earth is acting even more strangely,The application seems to work but when I browse or zoom Earth I immediately experience lots of blinking on my screen. How do I uninstall Internet Explorer 9 or Rollback to Internet Explorer 8?

    Read the article

  • How to rollback a database deployment without losing new data?

    - by devlife
    My company uses virtual machines for our web/app servers. This allows for very easy rollbacks of a deployment if something goes wrong. However, if an app server deployment also requires a database deployment and we have to rollback I'm kind of at a loss. How can you rollback database schema changes without losing data? The only thing that I can think of is to write a script that will drop/revert tables/columns back to their original state. Is this really the best way?

    Read the article

  • Is there a way to rollback and exit a psql script on error?

    - by metanaito
    I have a psql script that looks like this: -- first set of statements begin sql statement; sql statement; sql statement; exception when others then rollback write some output (here I want to exit the entire script and not continue on to the next set of statements) end / -- another set of statements begin sql statement; sql statement; sql statement; exception when others then rollback write some output (here I want to exit the entire script and not continue) end / ... and so on Is it possible to exit the script and stop processing the rest of the script?

    Read the article

  • Does a rollback still occur if I use begin...rescue and an error occurs?

    - by codeman73
    I've got some strange errors happening in my rails app and I'm trying to log better errors instead of the whole stack of passenger stuff that I don't care about. I thought I would do this with a Rescue clause and explicit error handling, like logging the params hash. But I'm concerned if this would interrupt any rollback that is happening. For that matter, I'm assuming rollbacks automatically occur when an error occurs as part of the normal rails error handling, but I haven't been able to find that documented anywhere. I'm using Dreamhost with MySQL, so I thought transactions and rollbacks were happening there.

    Read the article

  • Are log records removed from ldf file for rollbacks?

    - by TiborKaraszi
    Seems like a simple enough question, right? This question (but more targeted, read on) was raised in an MCT forum. While the discussion was on-going and and I tried to come up with answers, I realized that this question are really several questions. First, what is a rollback? I can see three different types of rollbacks (there might be more, of course): Regular rollback, as in ROLLBACK TRAN (or lost/terminated connection) Rollback done by restore recovery. I.e., end-time of backup included some transaciton...(read more)

    Read the article

  • Which version management design methodology to be used in a Dependent System nodes?

    - by actiononmail
    This is my first question so please indicate if my question is too vague and not understandable. My question is more related to High Level Design. We have a system (specifically an ATCA Chassis) configured in a Star Topology, having Master Node (MN) and other sub-ordinate nodes(SN). All nodes are connected via Ethernet and shall run on Linux OS with other proprietary applications. I have to build a recovery Framework Design so that any software entity, whether its Linux, Ramdisk or application can be rollback to previous good versions if something bad happens. Thus I think of maintaining a State Version Matrix over MN, where each State(1,2....n) represents Good Kernel, Ramdisk and application versions for each SN. It may happen that one SN version can dependent on other SN's version. Please see following diagram:- So I am in dilemma whether to use Package Management Methodology used by Debian Distributions (Like Ubuntu) or GIT repository methodology; in order to do a Rollback to previous good versions on either one SN or on all the dependent SNs. The method should also be easier for upgrading SNs along with MNs. Some of the features which I am trying to achieve:- 1) Upgrade of even single software entity is achievable without hindering others. 2) Dependency checks must be done before applying rollback or upgrade on each of the SN 3) User Prompt should be given in case dependency fails.If User still go for rollback, all the SNs should get notification to rollback there own releases (if required). 4) The binaries should be distributed on SNs accordingly so that recovery process is faster; rather fetching every time from MN. 5) Release Patches from developer for bug fixes, feature enhancement can be applied on running system. 6) Each version can be easily tracked and distinguishable. Thanks

    Read the article

  • Session does not giving right records?

    - by Jugal
    I want to keep one session, but when I rollback transaction then transaction gets isActive=false, so I can not commit and rollback in next statements by using same transaction. then I need to create new transaction but what is going wrong here ? var session = NHibernateHelper.OpenSession();/* It returns new session. */ var transaction1 = session.BeginTransaction(); var list1 = session.Query<Make>().ToList(); /* It returs 4 records. */ session.Delete(list1[2]); /* After Rollback, transaction is isActive=false so I can not commit * and rollback from this transaction in future. so I need to create new transaction. */ transaction1.Rollback(); var transaction2 = session.BeginTransaction(); /* It returns 3 records. * I am not getting object(which was deleted but after that rollback) here why ? */ var list2 = session.Query<Make>().ToList(); Anyone have idea what is going wrong here ? I am not getting deleted object which was rollback.

    Read the article

  • Is it possible to force an error in an Integration Services data flow to demonstrate its rollback?

    - by Matt
    I have been tasked with demoing how Integration Services handles an error during a data flow to show that no data makes it into the destination. This is an existing package and I want to limit the code changes to the package as much as possible (since this is most likely a one time deal). The scenario that is trying to be understood is a "systemic" failure - the source file disappears midstream, or the file server loses power, etc. I know I can make this happen by having the Error Output of the source set to Failure and introducing bad data but I would like to do something lighter than that. I suppose I could add a Script Transform task and look for a certain value and throw an error but I was hoping someone has come up with something easier / more elegant. Thanks, Matt

    Read the article

  • How to nest transactions nicely - &quot;begin transaction&quot; vs &quot;save transaction&quot; and SQL Server

    - by Brian Biales
    Do you write stored procedures that might be used by others?  And those others may or may not have already started a transaction?  And your SP does several things, but if any of them fail, you have to undo them all and return with a code indicating it failed? Well, I have written such code, and it wasn’t working right until I finally figured out how to handle the case when we are already in a transaction, as well as the case where the caller did not start a transaction.  When a problem occurred, my “ROLLBACK TRANSACTION” would roll back not just my nested transaction, but the caller’s transaction as well.  So when I tested the procedure stand-alone, it seemed to work fine, but when others used it, it would cause a problem if it had to rollback.  When something went wrong in my procedure, their entire transaction was rolled back.  This was not appreciated. Now, I knew one could "nest" transactions, but the technical documentation was very confusing.  And I still have not found the approach below documented anywhere.  So here is a very brief description of how I got it to work, I hope you find this helpful. My example is a stored procedure that must figure out on its own if the caller has started a transaction or not.  This can be done in SQL Server by checking the @@TRANCOUNT value.  If no BEGIN TRANSACTION has occurred yet, this will have a value of 0.  Any number greater than zero means that a transaction is in progress.  If there is no current transaction, my SP begins a transaction. But if a transaction is already in progress, my SP uses SAVE TRANSACTION and gives it a name.  SAVE TRANSACTION creates a “save point”.  Note that creating a save point has no effect on @@TRANCOUNT.  So my SP starts with something like this: DECLARE @startingTranCount int SET @startingTranCount = @@TRANCOUNT IF @startingTranCount > 0 SAVE TRANSACTION mySavePointName ELSE BEGIN TRANSACTION -- … Then, when ready to commit the changes, you only need to commit if we started the transaction ourselves: IF @startingTranCount = 0 COMMIT TRANSACTION And finally, to roll back just your changes so far: -- Roll back changes... IF @startingTranCount > 0 ROLLBACK TRANSACTION MySavePointName ELSE ROLLBACK TRANSACTION Here is some code that you can try that will demonstrate how the save points work inside a transaction. This sample code creates a temporary table, then executes selects and updates, documenting what is going on, then deletes the temporary table. if running in SQL Management Studio, set Query Results to: Text for best readability of the results. -- Create a temporary table to test with, we'll drop it at the end. CREATE TABLE #ATable( [Column_A] [varchar](5) NULL ) ON [PRIMARY] GO SET NOCOUNT ON -- Ensure just one row - delete all rows, add one DELETE #ATable -- Insert just one row INSERT INTO #ATable VALUES('000') SELECT 'Before TRANSACTION starts, value in table is: ' AS Note, * FROM #ATable SELECT @@trancount AS CurrentTrancount --insert into a values ('abc') UPDATE #ATable SET Column_A = 'abc' SELECT 'UPDATED without a TRANSACTION, value in table is: ' AS Note, * FROM #ATable BEGIN TRANSACTION SELECT 'BEGIN TRANSACTION, trancount is now ' AS Note, @@TRANCOUNT AS TranCount UPDATE #ATable SET Column_A = '123' SELECT 'Row updated inside TRANSACTION, value in table is: ' AS Note, * FROM #ATable SAVE TRANSACTION MySavepoint SELECT 'Save point MySavepoint created, transaction count now:' as Note, @@TRANCOUNT AS TranCount UPDATE #ATable SET Column_A = '456' SELECT 'Updated after MySavepoint created, value in table is: ' AS Note, * FROM #ATable SAVE TRANSACTION point2 SELECT 'Save point point2 created, transaction count now:' as Note, @@TRANCOUNT AS TranCount UPDATE #ATable SET Column_A = '789' SELECT 'Updated after point2 savepoint created, value in table is: ' AS Note, * FROM #ATable ROLLBACK TRANSACTION point2 SELECT 'Just rolled back savepoint "point2", value in table is: ' AS Note, * FROM #ATable ROLLBACK TRANSACTION MySavepoint SELECT 'Just rolled back savepoint "MySavepoint", value in table is: ' AS Note, * FROM #ATable SELECT 'Both save points were rolled back, transaction count still:' as Note, @@TRANCOUNT AS TranCount ROLLBACK TRANSACTION SELECT 'Just rolled back the entire transaction..., value in table is: ' AS Note, * FROM #ATable DROP TABLE #ATable The output should look like this: Note                                           Column_A ---------------------------------------------- -------- Before TRANSACTION starts, value in table is:  000 CurrentTrancount ---------------- 0 Note                                               Column_A -------------------------------------------------- -------- UPDATED without a TRANSACTION, value in table is:  abc Note                                 TranCount ------------------------------------ ----------- BEGIN TRANSACTION, trancount is now  1 Note                                                Column_A --------------------------------------------------- -------- Row updated inside TRANSACTION, value in table is:  123 Note                                                   TranCount ------------------------------------------------------ ----------- Save point MySavepoint created, transaction count now: 1 Note                                                   Column_A ------------------------------------------------------ -------- Updated after MySavepoint created, value in table is:  456 Note                                              TranCount ------------------------------------------------- ----------- Save point point2 created, transaction count now: 1 Note                                                        Column_A ----------------------------------------------------------- -------- Updated after point2 savepoint created, value in table is:  789 Note                                                     Column_A -------------------------------------------------------- -------- Just rolled back savepoint "point2", value in table is:  456 Note                                                          Column_A ------------------------------------------------------------- -------- Just rolled back savepoint "MySavepoint", value in table is:  123 Note                                                        TranCount ----------------------------------------------------------- ----------- Both save points were rolled back, transaction count still: 1 Note                                                            Column_A --------------------------------------------------------------- -------- Just rolled back the entire transaction..., value in table is:  abc

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >