Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update syntaxe for a stock programmation.
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01228160
Message ID:
01241294
Views:
27
Sergey,

it 's Ok ! Thank

1) I am constrained to make you work! ..:)

2) I see my probleme
V_AgendaPhar is a view for a precies day. ( whereClaus = iagendadateid = Vp_datePrecies )
The code is dus a little different.
UPDATE ap   ;
  SET nstkjour = pd.nStkjourCor ;
  FROM  V_AgendaPhar ap ;
  JOIN(;
  SELECT apd.nstkjour AS nStkjourCor, ;
  apd.itraiterId , apd.iagendadateid ;
  FROM  AgendaPhar apd ;
  WHERE apd.iagendadateid < lnVp_Id ;
  AND NOT EXISTS ( SELECT * FROM AgendaPhar  ;
  WHERE itraiterId = apd.itraiterId ;
  AND iagendadateid < lnVp_Id ;
  AND iagendadateid > apd.iagendadateid)) pd ;
  ON ap.itraiterId = pd.itraiterId ;
  WHERE ap.iagendadateid = lnVp_Id
3) For the first day , there is no previous days with stock.
 SET nstkjour = NVL( pd.nStkjourCor , V_AgendaPhar.nstkjour )  ?????????
>To update one day
>lnVp_Id = 2
>
>UPDATE ap   ;
>		SET nstkjour = pd.nStkjourCor - pd.nConsjourCor ;
>	FROM V_AgendaPhar ap ;
>	JOIN(;
>			SELECT apd.nStkjour AS nStkjourCor, nConsjour AS nConsjourCor, ;
>					apd.itraiterId , apd.iagendadat ;
>				FROM  V_AgendaPhar apd ;
>				WHERE apd.iagendadat < lnVp_Id ;
>					AND NOT EXISTS ( SELECT * FROM  V_AgendaPhar  ;
>						WHERE itraiterId = apd.itraiterId ;
>							AND iagendadat < lnVp_Id ;
>							AND iagendadat > apd.iagendadat)) pd ;
>	ON ap.itraiterId = pd.itraiterId ;
>	WHERE ap.iagendadat = lnVp_Id
>
>
>>Ok sergey ( sorry for my poor english ).
>>
>>I would like to know a number (Stock) over day.
>>The 01/07/2007 a patient has one limps of drug eg (ASPRO 500) .
>>There are 50 compressed in a drug.
>>He consumes 1 compressed per day.
>>The stock , this day is 50 - 1 = 49
>>
>>The 02/07/2007 it thus has 49 - 1 (consumption) = 48 (the stock of the previous day) - 1
>>The 03/07/2007 it thus has 48 - 1 = 47 (the stock of the previous day) - 1 = 47
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform