Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:36:29+00:00 2026-05-21T07:36:29+00:00

I am updating a Trades Transactions Log using a SQL Stored Procedure, and I

  • 0

I am updating a Trades Transactions Log using a SQL Stored Procedure, and I am updating Current Order Table at the same time with the same sproc.

Because I had a serious problem where the Log table did not update and the Current Order table did… I added a (3rd) routine to the bottom which checks to see if the Log Table was updated referencing an ID (ClientID), then entering an error if not present to error table.

I am asking… how badly written is this sproc ?? Help or advice appreciated.

ALTER PROCEDURE dbo.sprocVT4_addTradeLong
@seqno varchar(35) = NULL,
@exctyp varchar(35) = NULL,
@ordstat varchar(35) = NULL,
@clid varchar(35) = NULL,
@exid varchar(35) = NULL,
@type varchar(35) = NULL,
@side varchar(35) = NULL,
@exch varchar(35) = NULL,
@sym varchar(35) = NULL,
@lstqty varchar(35) = NULL,
@lstpri varchar(35) = NULL,
@text varchar(35) = NULL,
@cumqty varchar(35) = NULL,
@lftqty varchar(35) = NULL,
@now varchar(35) = NULL
AS
BEGIN
-- NO EXISTS ------------
Declare @RC int

SELECT [Symbol] FROM TradesLongForex T WHERE T.ExecId = @exid

SELECT @RC = @@ROWCOUNT
IF @RC <= 0

INSERT INTO TradesLongForex ([SeqNo], [ExecType], [Status], [ClientId], [ExecId], [Type], [Side], [Exchange], [Symbol], [LastQty], [LastPrice], [Text], [CummQty], [LeftQty], [Date])

VALUES (@seqno, @exctyp, @ordstat, @clid, @exid, @type, @side, @exch, @sym, @lstqty, @lstpri, @text, @cumqty, @lftqty, @now)

UPDATE OrdersIdHoldForex SET [OrdExcType] = @exctyp, [OrdStatus] = @ordstat, [OrdType] = @type, [OrdSide] = @side, [OrdPrice] = @lstpri, [OrdQty] = @cumqty, [OrdRemain] = @lftqty

WHERE [Ticker] = @sym

DECLARE @RC2 int

SELECT @RC2 = @@ROWCOUNT

SELECT [ClientId] FROM TradesLongForex WHERE [ClientId] = @clid
if @RC2 <=0

INSERT INTO ERRLOG ([Date], [Message])

VALUES (GETDATE(), 'ERROR INSERTING TRADESLONGFOREX CLID = ' + CONVERT(varchar(10),@CLID))

END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:36:30+00:00Added an answer on May 21, 2026 at 7:36 am

    Phil makes a good point about transactions. This concept is called “Atomicity” and basically means each transaction/process is atomic and self contained.

    The general syntax for transactions in SQL server would be something like:

    BEGIN TRY
    BEGIN TRANSACTION
    ...
    
    your code here
    
    ...
    
    COMMIT TRANSACTION
    END TRY
    BEGIN CATCH
    IF @@TRANCOUNT > 1 ROLLBACK
    
    ... error reporting code ...
    
    END CATCH
    

    The gist of this is, use TRY/CATCH blocks to trap the errors, and only commit the transaction if you get through the whole TRY block without issues. Any errors send you to the CATCH block, which rolls back the open transaction.

    Here’s a primer on error handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Updating an old ASP/Access site for a client - I need SQL to add
After updating or creating a record I use url helper to redirect to the
Does updating statistics cause tables to be inaccessible? In other words, can you run
I'm updating some of our legacy C++ code to use the MFC feature pack
In the process of updating a web app from ASP to ASP.NET, I want
I'm updating some old AWStats config files to filter out some specific IP ranges.
I'm wondering if updating statistics has helped you before and how did you know
I am tasked with updating a family of web sites that promote scientific conferences
I'm involved with updating an Access solution. It has a good amount of VBA,
I am updating a VBA program (excel). At startup the program checks if it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.