Parameters hanging on to previous values
Post Author: sharonmtowler
CA Forum: General
I have a report where the parameters are sent from the stored procedure to the report. crystal 8.5 sql 2000.
when i run the report locally and prompt for new parameters it displays the old values from the last time it was run. (i am dropping my temp table @ end of proc) i change the value but it isnt pulling what i try to pass through. i attached my stored procedure to see if anyone knows why the values are hanging.
SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GO
/**************************************************************************** Program : Inventory Status Detail with QC results Program ID : Pr_Customer_QC_Data Type : Stored Procedure Owner : Ashish Out To : Customer_QC_Data.rpt Description : Name : Sharon Towler Date : 04/28/2008 Modification-01 : xx/xx/xxxxx xxxxxx 1 xxxxxxxxxxxxx
***************************************************************************/ ALTER PROCEDURE DBO.Pr_Customer_QC_Data @gl_cmp_key varchar(2), @in_whs_key varchar(275), @beg_in_item_key varchar(20), @end_in_item_key varchar(20), @beg_in_lot_key varchar(25), @end_in_lot_key varchar(25), @SO_From_Crt_Dte datetime, @SO_TO_Crt_Dte datetime
AS
SET NOCOUNT ON
/************************************************************************/ /***********************************************************************/ / STEP 1: Set multiple wareshouses selection / /***********************************************************************/ /************************************************************************/
CREATE TABLE #T_Localwhs ( warehouse varchar(6) null )
DECLARE @var varchar(6), @i numeric, @whs varchar(6), @chk numeric
SET @i = 1 SET @var = (charindex(',',@in_whs_key))
IF @var <> 0 BEGIN WHILE (@i < @var) BEGIN --SET @var = (CHARINDEX(',',@in_whs_key)) SET @whs = LTRIM(LEFT(@in_whs_key, (@var-1))) INSERT #T_Localwhs (warehouse) VALUES (@whs) SET @in_whs_key = RIGHT(@in_whs_key, (LEN(@in_whs_key)-@var)) SET @var = (CHARINDEX(',',@in_whs_key)) END
INSERT #T_Localwhs (warehouse) VALUES (LTRIM(@in_whs_key)) END ELSE BEGIN INSERT #T_Localwhs (warehouse) VALUES (LTRIM(@in_whs_key)) END
--SELECT * FROM #T_Localwhs
/************************************************************************/ /***********************************************************************/ / STEP 2: Main selection / /***********************************************************************/ /************************************************************************/
SELECT DISTINCT so_hdr_tbl.gl_cmp_key, so_hdr_tbl.so_hdr_key ORDER_NUMBER, so_hdr_tbl.so_hdr_crtdt ORDER_DATE, so_hdr_tbl.ar_bill_key BILL_TO, so_dtl_tbl.ar_ship_key SHIP_TO, so_dtl_tbl.so_dtl_key SO_LINE, in_pklot_tbl.in_item_key ITEM, in_pklot_tbl.im_pack_key PACK, en_lotqc_tbl.en_lot_key LOT, so_dtlpr_tbl.so_dtlpr_basec UNIT_COST, en_lotqc_tbl.en_qcmst_key TEST, en_lotqc_tbl.en_lotqc_value RESULT, en_plc_tbl.en_plc_dsc FAMILY, in_whitmpk_tbl.gl_acct_key GL_ACCT, so_rtdtl_tbl.so_rthdr_key RMA, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'BD2' THEN en_lotqc_tbl.en_lotqc_value END AS BD2, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'CONTAM' THEN en_lotqc_tbl.en_lotqc_value END AS CONTAM, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'EL' THEN en_lotqc_tbl.en_lotqc_value END AS EL, CASE WHEN en_lotqc_tbl.en_qcmst_key LIKE 'GEL' THEN en_lotqc_tbl.en_lotqc_value END AS GEL, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'MFR' THEN en_lotqc_tbl.en_lotqc_value END AS MFR, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'MIT' THEN en_lotqc_tbl.en_lotqc_value END AS MIT, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'MP' THEN en_lotqc_tbl.en_lotqc_value END AS MP, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'PCI' THEN en_lotqc_tbl.en_lotqc_value END AS PCI, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'PS' THEN en_lotqc_tbl.en_lotqc_value END AS PS, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'SG' THEN en_lotqc_tbl.en_lotqc_value END AS SG, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'TS' THEN en_lotqc_tbl.en_lotqc_value END AS TS, CASE WHEN en_lotqc_tbl.en_qcmst_key = 'VOL' THEN en_lotqc_tbl.en_lotqc_value END AS VOL FROM in_whitmpk_tbl INNER JOIN so_hdr_tbl INNER JOIN so_dtl_tbl ON so_hdr_tbl.gl_cmp_key = so_dtl_tbl.gl_cmp_key AND so_hdr_tbl.so_brnch_key = so_dtl_tbl.so_brnch_key AND so_hdr_tbl.so_hdr_key = so_dtl_tbl.so_hdr_key INNER JOIN so_dtlpr_tbl ON so_dtl_tbl.gl_cmp_key = so_dtlpr_tbl.gl_cmp_key AND so_dtl_tbl.so_brnch_key = so_dtlpr_tbl.so_brnch_key AND so_dtl_tbl.so_hdr_key = so_dtlpr_tbl.so_hdr_key AND so_dtl_tbl.so_dtl_key = so_dtlpr_tbl.so_dtl_key INNER JOIN in_pklot_tbl ON so_dtl_tbl.so_dtl_key = in_pklot_tbl.in_pklot_line AND so_dtl_tbl.so_hdr_key = in_pklot_tbl.in_pklot_doc AND so_dtl_tbl.gl_cmp_key = in_pklot_tbl.gl_cmp_key INNER JOIN en_lotqc_tbl ON in_pklot_tbl.in_item_key = en_lotqc_tbl.en_item_key AND in_pklot_tbl.in_lot_key = en_lotqc_tbl.en_lot_key ON in_whitmpk_tbl.gl_cmp_key = in_pklot_tbl.gl_cmp_key AND in_whitmpk_tbl.in_whs_key = in_pklot_tbl.in_whs_key AND in_whitmpk_tbl.in_item_key = in_pklot_tbl.in_item_key AND in_whitmpk_tbl.im_pack_key = in_pklot_tbl.im_pack_key AND SUBSTRING(in_whitmpk_tbl.gl_acct_key,5,4) = '1510' AND in_whitmpk_tbl.in_item_key <> 'LESS THAN MIN CHG' AND in_whitmpk_tbl.in_item_key <> 'SH_CHG_EQUIPMENT' LEFT OUTER JOIN so_rtdtl_tbl ON so_dtl_tbl.so_dtl_key = so_rtdtl_tbl.so_dtl_key AND so_dtl_tbl.so_hdr_key = so_rtdtl_tbl.so_hdr_key AND so_dtl_tbl.gl_cmp_key = so_rtdtl_tbl.gl_cmp_key AND so_dtl_tbl.so_brnch_key = so_rtdtl_tbl.so_brnch_keyLEFT OUTER JOIN en_plc_tbl INNER JOIN en_pgc_tbl ON en_plc_tbl.en_plc_key = en_pgc_tbl.en_plc_key ON in_pklot_tbl.in_item_key = en_pgc_tbl.en_pgc_keyand CONVERT(datetime,CONVERT(char(10),so_hdr_tbl.so_hdr_crtdt,101)) >= CONVERT(datetime,CONVERT(char(10),@SO_From_Crt_Dte,101)) and CONVERT(datetime,CONVERT(char(10),so_hdr_tbl.so_hdr_crtdt,101)) <= CONVERT(datetime,CONVERT(char(10),@SO_TO_Crt_Dte,101))and @gl_cmp_key = so_hdr_tbl.gl_cmp_keyand @in_whs_key IN (SELECT DISTINCT Warehouse FROM #T_Localwhs)and in_pklot_tbl.in_item_key >= @beg_in_item_key and in_pklot_tbl.in_item_key <= @end_in_item_keyand en_lotqc_tbl.en_lot_key >= @beg_in_lot_keyand en_lotqc_tbl.en_lot_key <= @end_in_lot_key
DROP TABLE #T_Localwhs
GOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO
Post Author: sharonmtowler
CA Forum: General
i figured it out, a where statement is always helpful......
Similar Messages
-
How to get a summ of all previous values
Hello ALL,
Could you please give an advice on how to find the sums of all previous values in 1 select without using dynamic sql. Cross join is not a variant because of a huge response time.
OR may be there are any other ideas on how to find first rows with total sum equals to some general value? My idea is to find a sum of all preceding values and the first of such sums that would be equal to the general value or greater it is a necessary result.
For example we have goods receipts:
MATERIAL | BATCH | QTY
material1 batch1 1
material1 batch2 2
material1 batch3 3
material1 batch4 4
material1 batch5 5
material1 batch6 6
and general qty is 7 - it's our current stock. So I should take material from [batch1 to batch4] to get necessary QTY >=7 (1+2+3+4=10>7) So our current stock consists of batch1,batch2,batch3 and remains of batch4.
Thanks in advance!
Edited by: user9321926 on Jun 18, 2010 3:56 AMSome thing like:
1 select
2 empno,
3 sal,
4 (select sum(sal) from emp b where b.empno <= a.empno) running_total
5* from (select * from emp order by empno) a
SQL> /
EMPNO SAL RUNNING_TOTAL
7369 800 800
7499 1600 2400
7521 1250 3650
7566 2975 6625
7654 1250 7875
7698 2850 10725
7782 2450 13175
7788 3000 16175
7839 5000 21175
7844 1500 22675
7876 1100 23775
EMPNO SAL RUNNING_TOTAL
7900 950 24725
7902 3000 27725
7934 1300 29025
14 rows selected.
SQL> -
Create a new column in a table that compares the value of one column with its previous value
The DDL:
DECLARE
@T TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
DECLARE
@K TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
INSERT
INTO @T
VALUES(22,'C_V_Harris','2014-01-02 10:23:49.0000000',
23.335,
23.347)
INSERT
INTO @T
VALUES(21,'C_V_Harris','2014-01-02 10:05:13.0000000',
23.357,
23.369)
INSERT
INTO @T
VALUES(20,'C_V_Harris','2014-01-02 09:56:15.0000000',
23.364,
23.377)
INSERT
INTO @T
VALUES(19,'C_V_Harris','2014-01-02 09:45:26.0000000',
23.351,
23.367)
INSERT
INTO @T
VALUES(18,'C_V_Harris','2014-01-02 09:43:20.0000000',
23.380,
23.396)
INSERT
INTO @T
VALUES(17,'C_V_Harris','2014-01-02 09:34:28.0000000',
23.455,
23.468)
INSERT
INTO @T
VALUES(16,'C_V_Harris','2014-01-02 09:30:37.0000000',
23.474,
23.486)
INSERT
INTO @T
VALUES(15,'C_V_Harris','2014-01-02 09:18:12.0000000',
23.419,
23.431)
INSERT
INTO @T
VALUES(14,'C_V_Harris','2014-01-02 09:16:06.0000000',
23.360,
23.374)
INSERT
INTO @K
SELECT
ROW_NUMBER()
OVER (ORDER
by IDNO)
AS RN,*
FROM
@T
SELECT
* FROM
@K
--not working:
SELECT
a.RN,a.Price2
FROM
@K a
INNER
JOIN @K
b
ON
a.RN=b.RN-1
WHERE
a.Price2>b.Price2
I need to create a view with a column (say 'Comp' below) that compares the value of each row in Price2 with the previous Price2 row, and it is greater then +1, the
same 0, and less -1.
The processed table should be:
IDNO
name
Date
Price1
Price2
Comp
22
C_V_Harris
1/2/2014 10:23:49
23.335
23.347
0
21
C_V_Harris
1/2/2014 10:05:13
23.357
23.369
1
20
C_V_Harris
1/2/2014 9:56:15
23.364
23.377
1
19
C_V_Harris
1/2/2014 9:45:26
23.351
23.367
-1
18
C_V_Harris
1/2/2014 9:43:20
23.38
23.396
1
17
C_V_Harris
1/2/2014 9:34:28
23.455
23.468
1
16
C_V_Harris
1/2/2014 9:30:37
23.474
23.486
1
15
C_V_Harris
1/2/2014 9:18:12
23.419
23.431
-1
14
C_V_Harris
1/2/2014 9:16:06
23.36
23.374
-1
How can I structure the statement to get (the most recent - order by date ) result for Comp?Satheesh Variath, I just had to make some corrections from your script to get the correct answer:
CREATE
VIEW vw_Comp
AS
SELECT
TOP 1 t.IDNO,t.name,t.[Date],t.Price1,t.Price2,
CASE
WHEN t.Price2
> LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNO)
THEN 1
WHEN t.Price2
< LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNo)
THEN -1
ELSE 0
END
AS Comp
FROM
@T t
ORDER
BY DATE
DESC
The adjustments: the selection of the most recent comparison (Top 1) and the use of the function LAG (instead of LEAD) to get the previous value of the column. -
Previous Values of Selected Items in a Datagrid
I have a datagrid which the dataprovider is bound to an ArrayCollection of Value Objects from a web service.
One other thing which is important to point out. The Value Objects are created automatically for the Data/Service and so if I change the files, they will just be overwritten the next time I make a change to the service.
The grid displays Inventory Items. Lets say that Item 1 has a qty of 20. Item 5 has a Qty of 10.
The list in this grid is based upon the selection of a Location tree. So it lists the inventory items for a certain location.
I also have a second tree and grid for the to location inventory items.
Between the two grids, there is a button which when clicked it iterates thru the selected items and creates a new item in the to list with qty 1 and saves it. then decreases the current qty in the from list by one.
So lets say I selected items 1 and 5 and then clicked the button. A new copy of Items 1 and 5 are created in the to list with a qty of 1 and then saved. Then the qty in the from list is decreased by 1 and saved and so the vales for 1 is now 19 and for 5 is 9.
I would like to be able to change the qty in the from list to the qty I want to move. So when the button is clicked the new item in the to list reflects the new qty and is saved. Then the previous value of the current qty is decreased by the qty which is displayed in the grid
So lets say I changed item 1 to 2 and Item 5 to 3 and then selected items 1 and 5 and then clicked the button. A new copy of Items 1 and 5 are created in the to list with a qty of 2 for item 1 and 3 for item 5 and then saved. Then the qty in the from list is decreased for Item 1 by 2 and item 5 by 3 and so now Item 1s qty is now 18 and items 5 qty is now 7.
My first thought was if I had the previous values stored then no big deal. But I put a break point at the point where the SelectedItems list is being iterated through and the previous values are not stored anywhere.
Any suggestions for this?...in the mean time, this should be enough
win.pnl.list1.onChange = function() {
alert(this.selection.index); // for this to work set, multiselect:false
I guess you already tried and the result is "undefined", the reason is you have this property
multiselect:true
in that case, selection returns an array,
this.selection[0].index;
would give you the first selected item, even if you only have one item selected, to get all selected items loop thru all items in the selection array.
not sure if Peter's wonderful guide explains this (it is explained in the Tools Guide), but you should read it too, it has tons of great info. -
How to get the previous value of a field before saving the record
Hi All,
I have a requirement like, listing out the modified field values with their previous value and new value using integration events or any method.
For Ex: If i modify the customer name from "Jack" to "Amith" in the record.
Then i have a requirement to display the message like : CustomerName has changed from "Jack" to "Amith"
Please post your help notes on this.It's Urgent.
Thanks & Regards
AmithHello Amith,
How does a user perform the modification? Do you already have access to the existing value when the user makes the update? How are you identifying the record to be updated within CRMOD and what method are you using to perform the update?
Thanks,
Sean -
How to find the PREVIOUS value of a non-DB item?
I want to do a simple thing but found it impossible.
I want to find the previous value of a non-DB item in a form.
I tried creating a text item and populating it using PRE-TEXT-ITEM but that does not work.
WHEN-VALIDATE-ITEM does not work either because WVI fires only after item value has changed.
Any suggestions will be greatly appreciated.
Edited by: Channa on Apr 2, 2010 4:34 AMChanna wrote:
I want to do a simple thing but found it impossible.
I want to find the previous value of a non-DB item in a form.
I tried creating a text item and populating it using PRE-TEXT-ITEM but that does not work.
WHEN-VALIDATE-ITEM does not work either because WVI fires only after item value has changed.
Any suggestions will be greatly appreciated.
Edited by: Channa on Apr 2, 2010 4:34 AMPlease make it clear what is your requirement then possibly we can provide you a better answer
You can use Global variables for to store old values also on Post-query populate a value in separate field or Parameter -
How to compare previouse value in pl/sql array
DECLARE
CURSOR stg_raw_cur IS
SELECT RAW_STG_ID,
DEVICE_CD,
MODEL_VERSION,
PLATFORM_CD,
PROFILE_COOKIE,
LOCATION_CD,
SAMPLE_RATE,
EVENT_TYPE_CD,
to_char(to_date(to_date(substr(EVENT_DATE_TIME,1,8),'yyyymmdd')-1 ||
'T' ||
substr(EVENT_DATE_TIME,10,8)
|| 'Z','DD-MON-RR"T"HH24:MI:SS"Z"'), 'YYYYMMDDYY"T"HH24:MI:SS"Z"' ) EVENT_DATE_TIME,
EVENT_SPECIFIC,
BATCH_ID,
DWH_ARVL_DT,
DWH_ARVL_DT_ID,
DWH_CREATE_DT from dwh_stg.stg_raw where batch_id >= 200
order by batch_id asc;
TYPE stgrawarr IS TABLE OF stg_raw_cur%ROWTYPE;
stg_raw_rec stgrawarr;
l_batch_id NUMBER :=0 ;
v_ctr NUMBER :=0;
l_temp_batch_id number :=0;
BEGIN
OPEN stg_raw_cur;
LOOP
FETCH stg_raw_cur BULK COLLECT INTO stg_raw_rec LIMIT 100;
EXIT
WHEN stg_raw_cur%NOTFOUND;
END LOOP;
CLOSE stg_raw_cur;
for i in stg_raw_rec.first..stg_raw_rec.last
loop
dbms_output.put_line('batch id is '|| stg_raw_rec(i).batch_id );
IF l_batch_id != stg_raw_rec(i).batch_id
then
dbms_output.put_line('Different');
end if;
l_temp_batch_id := stg_raw_rec(i).batch_id;
commit;
end loop;
END;
I want to compare previous value of stg_raw_rec(i).batch_id if differnet then increament the value
else leave the same.
thanks.Try this,
FOR i IN stg_raw_rec.FIRST .. stg_raw_rec.LAST
LOOP
IF l_temp_batch_id != stg_raw_rec (i).batch_id
THEN
--increment
l_temp_batch_id := l_temp_batch_id + 1;
END IF;
DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id||' unique batch id is '||l_temp_batch_id);
-- DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id);
-- IF l_batch_id != stg_raw_rec (i).batch_id
-- THEN
-- DBMS_OUTPUT.PUT_LINE ('Different');
-- END IF;
l_temp_batch_id := stg_raw_rec (i).batch_id;
COMMIT;
END LOOP; -
How to get the previous value of Potential Revenue, as Number
PRE('<Revenue>') will return the previous value of the Potential Revenue (in Opportunity object), as a string.
However, i need to manipulate the returned value as number in order to evaluate if the previous value is less a certain amount.
PRE('<Revenue>')*.3204<50000
The expression about, is meant to convernt the value to a different currency, and evaluate if its less than 50000.
Is there any way I can be able to achive this?
appreciate you response! :)
Edited by: mack on Apr 15, 2012 1:31 AManswered.
-
PPR event getting previous value
Hi
There is a PPR event on a standard text box. I am handling PPR event in my custom CO. Whenever I change the value abd tab out of the text box I get the previous value not the current(changed) value.
ExpenseReportLinesVORowImpl expensereportlinesvorowimpl = (ExpenseReportLinesVORowImpl)expensereportlinesvoimpl.getCurrentRow();
please help
ThanksHi,
Here are three different ideas:
(1) Copy the current row into a local RECORD variable inside the loop.
(2) Do a self-join in the query, so that the cursor itself has the previous and current rows. (If necessary, use the analytic ROW_NUMBER function to number the rows so you can do the self-join correctly.)
(3) Use the analytic LAG function to copy the necesssary columns from the previous row in the query. -
Newbie: How can I store a previous value??
I am trying to figure out how to do the following:
int xcoor=0, ycoor=0, hstep, vstep;
while true do
update_step(hstep, vstep); // essentially have a big while loop to generate the necessary hstep/vsteps
xcoor = xcoor + hstep; // I need to add a new hstep to the xcoor
ycoor = ycoor + vstep; // I need to add a new vstep to the ycoor
updategraph(xcoor, ycoor); // and feed the updated xcoor/ycoor to an XYgraph
I think I should use a Master/Slave design? but how do I keep the previous value the first time in the Slave and then add the new values to the stored value??
Attachments:
new_Block_Diagram.bmp 2137 KB
new_Block_Diagram.jpg 174 KBYou probably want to use a shift register.
Right-click on the right edge of the loop. Select the "Add Shift Register" option.
It will add a widget on both the right and left sides of the loop.
An item wired to the right side will appear on the left side during the next pass through the loop. You can initialize the value by wiring an input to the left side widget.
[email protected] -
I have Dreamweaver CS3 on a PC with Windows Vista SP2. The program recently began to hang when opening previously created HTML files. How do I fix this?
Hi rmarchione,
Can you try restoring preferences and let us know if it helps?
Restore preferences | Dreamweaver CS4, CS5, CS5.5, CS6
Thanks,
Preran -
Compare the current value with the previous value in the same column
Hi all,
I have to include a statement in a query which allows to compare the current value of column A with the previous value of column A (same column). from there, I need to add a condition in order to have the expected result.
Let's take an example to illustrate what I want to achieve:
I have the following columns in table called 'Charges':
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 50
SID1111 9999 MD5553 50
SID2222 8887 MD6661 80
SID2222 8887 MD6662 80
SID2222 8887 MD6662 80
SID3333 6666 MD7771 90
I want to check if the ship_id of row 2,3 (and more if available) is equal to the ship_id of row 1.
If it is the case, then value 'together with the first batch_nr' in row 2 and 3 under Price column. If not, then keep the original value of Price column
PLease see below the expected result:
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 together with 9997
SID1111 9999 MD5553 together with 9997
SID2222 8887 MD6661 80
SID2222 8887 MD6662 together with 8887
SID2222 8887 MD6663 together with 8887
SID3333 6666 MD7771 90
Thanks in advance for your help, it is really urgent.
Imco20030Hi,
user11961002 wrote:
Hi,
Here is the query that I use:
[ select
sl.ship_id,
o.ordnum,
o.reffld_5 "BatchNR",
sum(tc1.chrg_amt) "FreightPRC",
sum(tc2.chrg_amt) "FuelPRC",
sum (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt) "Total Price"
from ord_line ol
join ord o on (ol.ordnum = o.ordnum and ol.client_id = o.client_id)
join shipment_line sl on (ol.ordnum = sl.ordnum and ol.client_id = sl.client_id and ol.ordlin = sl.ordlin)
join adrmst a2 on (o.rt_adr_id = a2.adr_id)
left join tm_chrg tc1 on (tc1.chargetype = 'FREIGHT' and tc1.chrg_role = 'PRICE' and tc1.ship_id = sl.ship_id)
left join tm_chrg tc2 on (tc2.chargetype = 'FUELSURCHARGE'and tc2.chrg_role = 'PRICE' and tc2.ship_id = sl.ship_id)
where sl.ship_id = 'SID0132408'
group by o.client_id, o.ordnum, o.reffld_2, sl.ship_id, a2.adrnam, a2.adrln1, a2.adrpsz, a2.adrcty, a2.ctry_name,
o.reffld_5, ol.early_shpdte
order by ship_id
]That looks like the query you were using before you started this thread.
Modify it, using the analytic fucntions FIRST_VALUE and LAG, like I showed you.
I see that you did simplify the problem quite a bit, and it's good that you did that.
It doesn't matter that your real problem involves joins or GROUP BY. Analytic functions are calculated on the results after all joins and GROUPS BYs are done. Just substitute your real expressions for the simplified ones.
For example, in your simplified problem, there was a column called order_nr, but I see now that's it's really called o.ordnum. Where the solution I posted earlier says "ORDER BY order_nr", you should say "ORDER BY o.ordnum".
Here's a less obvious example: in your simplifed problem, there was a column called price, but I see now that it's really SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt). Where the solution I posted earlier says "TO_CHAR (price)", you should say "TO_CHAR (SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt))". (You can't use an alias, like "Total Price", in the same SELECT clasue where it is defined.)
I removed some columns from the select as they are not relevant for the wanted action like 'adress details or other references'.
Now here is the result:
Shipment ID Order Number WMS Batch Freight Fuel Price Order Total Price
SID0132408 MDK-000014-05602649 04641401 110 10 120
SID0132408 MDK-000014-05602651 04641402 110 10 120
SID0132408 MDK-000014-05602652 04641363 110 10 120
as you can see, the 3 orders have the same shipment ID.
The expected result should be shown under column 'Total Price' as follows:
Shipment ID Order Number WMS Batch Freight Fuel Price Order Total Price
SID0132408 MDK-000014-05602649 04641401 110 10 120
SID0132408 MDK-000014-05602651 04641402 110 10 tog with 04641401
SID0132408 MDK-000014-05602652 04641363 110 10 tog with 04641401Okay, so those are the correct results that I asked for, plus the incorrect results you're getting now. Thanks; extra information doesn't hurt.
But where is the raw data that you're starting with?
It looks like you tried to format the code (but not the results) by typing this 1 character:
before the formatted section and this different character
after the formatted section. To post formatted text on this site, type these 6 characters
before the formatted section, and the exact same 6 characters again after the formatted section. -
Application hangs for non existing value
Hi,
At the DB level I tried to query non existing value from the table, query came out with "no rows selected" . But when I try to do the same from front end, application hangs! I just checked in the statspack report it shows like query is taking more cpu time to execute. what could be the reason for this?
when I join the v$session,v$sql to get the currently running query on database, it shows the query which try to execute from the application as active.
why it is hanging in application and why not in DB?
can any one brief me on this regard? why does application hangs for non exsting value?
With Regards
BooHi,
At the DB level I tried to query non existing value from the table, query came out with "no rows selected" . But when I try to do the same from front end, application hangs! I just checked in the statspack report it shows like query is taking more cpu time to execute. what could be the reason for this?
when I join the v$session,v$sql to get the currently running query on database, it shows the query which try to execute from the application as active.
why it is hanging in application and why not in DB?
can any one brief me on this regard? why does application hangs for non exsting value?
With Regards
Boo -
Calculating based on a previous value when initial column values differ from the rest
Let me preface this by saying I am new to the BO world. I'm trying to build a report/chart that tracks incoming loads. The first supply on hand value is pulled from the database and each successive supply on hand is based on the previous row's values.
In the supply arriving column below, the iniital value differs from the rest using the formula:
=If [Row Number]=1 Then [First Supply Arriving] Else [Supply Arriving]
The supply on hand uses the same idea, but is where I'm running into problems. The first column value should be [Supply On Hand], easy enough. Each successive column value needs to follow this equation:
Previous([Supply On Hand] (this won't always be [Supply On Hand] though, only for the second row essentially - problem 1) + Previous([Supply Arriving] (same as problem 1, where this is first supple arriving for the second row and then supply arriving moving forward) - [Usage Rate]
If someone could help me in getting the calculation to pull the previous values correctly without making a ton of variables, I'd greatly appreciate it. We just upgraded to 4.1Yes, the supply on hand and the supply arriving from the previous row need added together. The usage rate, which is a constant is then subtracted from that. The result is the on hand total for the next day.
For example:
Date
On Hand
Arriving
Usage Rate
9/9/2014
100,000
250,000
100,000
9/10/2014
250,000
1,000,000
100,000
9/11/2014
1,150,000
0
100,000 -
Compare previous value in the table
Hi:
I want to compare the previous value in the Acute Amt# with the current record and pass previous value to the Return Value column based on they are eqaul or not. Can you please help me how to get this ?
Here is the sample data.
REN# End# Acute Amt# Return Value
1 0 1583 1583
2 0 1587 1587
2 1 1572 1572
3 0 1572 Null
3 1 1572 Null
4 0 1572 Null
4 1 1572 Nullhttp://download.oracle.com/docs/cd/B13789_01/appdev.101/b10795/adfns_fl.htm
Would this feature help with your problem? Depending on the version of your database.
"This example uses a Flashback Query to examine the state of a table at a previous time............."
Maybe you are looking for
-
Hi, Does anyone know how to suppress the SSO and reports authentication when we run reports from either Oracle Forms or URL - by using the standalone/custom report server? Whenever we call reports from Forms or URL, the login page comes up. Thanks. A
-
I can no longer save SIMs 2 games
Dear Apple, I include a letter below that I sent to Aspyr Tech Support, which will help explain the situation. There were also problems with Fetch not uploading, because it said that that I could not save to the folder, and to try selecting another f
-
What does the -currentHost parameter do in a defaults command?
Kind of read the man page, but didnt find what i was looking for.
-
Calling a java program from a perl CGI
The perl program takes form data, does stuff with it, writes it to a file, and then calls a java program to encrypt it, and email it. When I telnet to the server, I can run the java program using: java CryptoMail.class [email protected] data.txt The
-
Applications STILL Automatically Reopening upon Start-up in OS X 10.8.5
I am having a problem whereby the last application I use automatically restarts when I reboot my laptop. I have unchecked the "reopen windows when logging back in" option when I go to shut down my computer (both by physically pushing the power button