Click here to Skip to main content
15,886,919 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Pin
talamar10-May-04 15:46
talamar10-May-04 15:46 
GeneralCreate an Access Database at runtime Pin
bsargos29-Apr-04 4:55
bsargos29-Apr-04 4:55 
GeneralRe: Create an Access Database at runtime Pin
BadJerry29-Apr-04 5:13
BadJerry29-Apr-04 5:13 
GeneralRe: Create an Access Database at runtime Pin
Santanu Lahiri29-Apr-04 10:24
Santanu Lahiri29-Apr-04 10:24 
GeneralRe: Create an Access Database at runtime Pin
Santanu Lahiri30-Apr-04 5:55
Santanu Lahiri30-Apr-04 5:55 
GeneralSage Accounting Version 10 Pin
Kryptos Sol29-Apr-04 4:43
Kryptos Sol29-Apr-04 4:43 
Generalexec two stored procedure in a main stored procedure Pin
manasrahfantom29-Apr-04 2:27
manasrahfantom29-Apr-04 2:27 
GeneralRe: exec two stored procedure in a main stored procedure Pin
Jeff Varszegi29-Apr-04 3:11
professionalJeff Varszegi29-Apr-04 3:11 
Check out this transaction documentation from the MSDN site.

Note especially this paragraph:

Naming multiple transactions in a series of nested transactions with a transaction name has little effect on the transaction.  Only the first (outermost) transaction name is registered with the system.  A rollback to any other name (other than a valid savepoint name) generates an error.  None of the statements executed before the rollback are in fact rolled back at the time this error occurs.  The statements are rolled back only when the outer transaction is rolled back.

Over time, I've learned to always use named transactions as a matter of course. When I use them in stored procedures, I often name them after the procedure; so in procedure pr_execute_code_a, I'd probably use

BEGIN TRANSACTION peca

This only minimizes the chance of a naming conflict, so you still have to be careful, but you get the idea. With named transactions, you're free to wrap stored procedures in other ones at will and still guarantee data integrity; the inner stored procedures can roll back just their own data if that's appropriate, and the outermost procedure has complete control over its own transaction; it can roll everything back or not.

When I am creating an "open" stored-procedure API, I always make sure that the procedure returns some non-zero value (always 1 if I'm not returning specific error codes) in case of an error, in addition to a RAISERROR call and/or a rollback of a transaction. That way calling code (which may be an enclosing procedure) has enough information to roll back a transaction. You know how to get this from an EXECUTE statement, right?

<br />
DECLARE @returnCode         AS INT<br />
<br><br />
-- ...<br />
-- ...<br />
<br><br />
EXEC @returnCode = pr_DoSomething<br />
--<br />
IF (@returnCode <> 0) BEGIN<br />
   -- roll back your transaction, if appropriate<br />
   -- raise an error, if appropriate<br />
   RETURN(1) -- if appropriate<br />
END -- IF<br />


In your case, if you're the one controlling and using the code and the inner procedures are always called by some other, you may not need transactions in your inner procedures at all, only in the outermost one(s).

Regards,

Jeff Varszegi

EEEP!
GeneralRe: exec two stored procedure in a main stored procedure Pin
manasrahfantom30-Apr-04 21:33
manasrahfantom30-Apr-04 21:33 
GeneralRe: exec two stored procedure in a main stored procedure Pin
Jeff Varszegi1-May-04 6:49
professionalJeff Varszegi1-May-04 6:49 
GeneralADO.NET Deletion from SQL DB problem. Pin
Member 105947128-Apr-04 19:52
Member 105947128-Apr-04 19:52 
GeneralTransferring Data Pin
ibok2328-Apr-04 5:40
ibok2328-Apr-04 5:40 
Generalcheck login exists Pin
Dpriya28-Apr-04 2:50
Dpriya28-Apr-04 2:50 
GeneralRe: check login exists Pin
Mazdak28-Apr-04 3:47
Mazdak28-Apr-04 3:47 
GeneralRe: check login exists Pin
Jeff Martin28-Apr-04 5:33
Jeff Martin28-Apr-04 5:33 
GeneralRe: check login exists Pin
Jeff Martin28-Apr-04 5:32
Jeff Martin28-Apr-04 5:32 
Generalcheck database exists Pin
Dpriya27-Apr-04 2:56
Dpriya27-Apr-04 2:56 
GeneralRe: check database exists Pin
Jeff Varszegi27-Apr-04 7:51
professionalJeff Varszegi27-Apr-04 7:51 
GeneralRe: check database exists Pin
Jeff Martin28-Apr-04 5:35
Jeff Martin28-Apr-04 5:35 
GeneralRe: check database exists Pin
Jeff Varszegi28-Apr-04 7:08
professionalJeff Varszegi28-Apr-04 7:08 
GeneralRe: check database exists Pin
Jeff Martin29-Apr-04 9:02
Jeff Martin29-Apr-04 9:02 
GeneralRe: check database exists Pin
Jeff Varszegi29-Apr-04 9:38
professionalJeff Varszegi29-Apr-04 9:38 
GeneralInstalling ole db provider for microsoft project without installing microsoft project Pin
vinay_mat26-Apr-04 20:39
vinay_mat26-Apr-04 20:39 
GeneralLinked server from SQL Server 2000 to Sybase 12 Pin
Janya26-Apr-04 14:30
Janya26-Apr-04 14:30 
QuestionHow to create linked tables using ADOX? Pin
Santanu Lahiri26-Apr-04 12:06
Santanu Lahiri26-Apr-04 12:06 

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

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