Click here to Skip to main content
15,899,679 members
Home / Discussions / Database
   

Database

 
GeneralRe: 2 thread use the same database connection to do transaction Pin
Colin Angus Mackay3-Jan-05 22:59
Colin Angus Mackay3-Jan-05 22:59 
GeneralRe: 2 thread use the same database connection to do transaction Pin
ting6684-Jan-05 0:13
ting6684-Jan-05 0:13 
GeneralRe: 2 thread use the same database connection to do transaction Pin
Colin Angus Mackay4-Jan-05 0:22
Colin Angus Mackay4-Jan-05 0:22 
GeneralMSDE Server Connection Settings Pin
Axsys3-Jan-05 11:49
Axsys3-Jan-05 11:49 
GeneralRe: MSDE Server Connection Settings Pin
Colin Angus Mackay3-Jan-05 22:55
Colin Angus Mackay3-Jan-05 22:55 
GeneralRe: MSDE Server Connection Settings Pin
Colin Angus Mackay4-Jan-05 22:03
Colin Angus Mackay4-Jan-05 22:03 
QuestionHow to get the index of a table-row after find-command Pin
fracalifa3-Jan-05 8:49
fracalifa3-Jan-05 8:49 
GeneralUpdating Fields In Specified Order Pin
perlmunger3-Jan-05 6:13
perlmunger3-Jan-05 6:13 
I am trying to determine if there is a way to ensure that one field gets updated before another in my stored procedure. I am finding that I usually have to run the sproc twice to get the values that I want, but it seems to me that there must be an easier way. In the sproc below, I want to ensure that Profit gets updated, but I don't know how. Any ideas?
CREATE PROCEDURE [dbo].[UpdatePricePoint]

            (@StoreID [int],
             @StoreDate [datetime] )
AS
BEGIN

UPDATE TicketItems
SET 
            Cost = 
		(CASE WHEN TicketItems.Qty = 0 
                        THEN 
		1 
		ELSE 
                           TicketItems.Qty 
           			 END ) 
                       * 
                       (CASE WHEN StoreItems.CurrentCasePack = 0 
                       THEN 
                           StoreItems.CurrentCaseCost 
                       ELSE 
                           StoreItems.CurrentCaseCost / StoreItems.CurrentCasePack 
                       END),
            NormalPrice = 
                        CASE WHEN StoreItems.NormalMSU = 0 
                        THEN 
                            StoreItems.NormalUnitSell 
                        ELSE 
                            StoreItems.NormalUnitSell / StoreItems.NormalMSU 
                        END,
            NormalAmount = 
                        (CASE WHEN StoreItems.NormalMSU = 0 
                        THEN 
                            StoreItems.NormalUnitSell 
                        ELSE 
                            StoreItems.NormalUnitSell / StoreItems.NormalMSU 
                        END)
                        * 
                        (CASE WHEN TicketItems.Qty = 0 
                        THEN 
                            1 
                        ELSE 
                            TicketItems.Qty 
                        END),
            PricePoint = 
                        (TicketItems.Amount - TicketItems.DiscountAmount) 
                        /
                        (CASE WHEN Qty = 0 
                        THEN 
                            1 
                        ELSE 
                            TicketItems.Qty 
                        END),
            Price = 
                        TicketItems.Amount
                        /
                        (CASE WHEN Qty = 0 
                        THEN 
                            1 
                        ELSE 
                            TicketItems.Qty 
                        END),
	Unit = (CASE WHEN TicketItems.Flag2 = 16 OR TicketItems.Flag2 = 32 OR TicketItems.Flag2 = 64
		THEN
			1
		ELSE
			TicketItems.Qty
		END),
	NormalMSU = StoreItems.NormalMSU,
	MSU = StoreItems.CurrentMSU,
	Profit = TicketItems.Amount - TicketItems.Cost
FROM TicketItems
INNER JOIN StoreItems 
ON 
            TicketItems.StoreID = StoreItems.StoreID AND 
            TicketItems.Plu = StoreItems.Plu
INNER JOIN TicketTotal
ON
            TicketItems.StoreID = TicketTotal.StoreID AND 
            TicketItems.TicketDate = TicketTotal.TicketDate AND 
            TicketItems.TicketTime = TicketTotal.TicketTime AND 
            TicketItems.POSID = TicketTotal.POSID AND 
            TicketItems.TicketID = TicketTotal.TicketID
WHERE
            TicketTotal.StoreID = @StoreID AND 
            TicketTotal.StoreDate = @StoreDate
END

Notice that I set pofit last, however, it is still null on the first run so I can only assume that it is updatint profit before cost is getting updated.

Thanks.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: Updating Fields In Specified Order Pin
Colin Angus Mackay3-Jan-05 22:52
Colin Angus Mackay3-Jan-05 22:52 
GeneralCreating a DSN Pin
Member 3600823-Jan-05 3:16
Member 3600823-Jan-05 3:16 
GeneralRe: Creating a DSN Pin
perlmunger3-Jan-05 9:47
perlmunger3-Jan-05 9:47 
GeneralI am... Pin
KORCARI2-Jan-05 2:27
KORCARI2-Jan-05 2:27 
GeneralRe: I am... Pin
Colin Angus Mackay2-Jan-05 22:30
Colin Angus Mackay2-Jan-05 22:30 
Generalserver application not available Pin
Member 12288431-Jan-05 23:22
Member 12288431-Jan-05 23:22 
GeneralOracle forms 6i problem Pin
missnazar1-Jan-05 20:12
missnazar1-Jan-05 20:12 
GeneralCreating a Web Form Using a DataSet Pin
macsgirl1-Jan-05 16:17
macsgirl1-Jan-05 16:17 
GeneralRe: Creating a Web Form Using a DataSet Pin
perlmunger3-Jan-05 9:40
perlmunger3-Jan-05 9:40 
GeneralWhere... Pin
KORCARI1-Jan-05 1:22
KORCARI1-Jan-05 1:22 
GeneralSQL Server does not exist or access denied Pin
nikneem200531-Dec-04 6:07
nikneem200531-Dec-04 6:07 
GeneralRe: SQL Server does not exist or access denied Pin
kings_131-Dec-04 7:51
kings_131-Dec-04 7:51 
GeneralRe: SQL Server does not exist or access denied Pin
Colin Angus Mackay31-Dec-04 15:26
Colin Angus Mackay31-Dec-04 15:26 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:00
nikneem20051-Jan-05 4:00 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:28
nikneem20051-Jan-05 4:28 
GeneralHuge Memory Consumption Pin
Developer567831-Dec-04 0:41
Developer567831-Dec-04 0:41 
GeneralRe: Huge Memory Consumption Pin
Mike Dimmick2-Jan-05 6:16
Mike Dimmick2-Jan-05 6:16 

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.