Trying to form complex query - need help
I have a fairly complex query that I need to join the results of to show actual and goal by day. The actuals are an aggregation of records that get put in every day, while the targets are a single entry in range format indicating an active range for which the target applies. I'm working on a query that will put things together by month and I'm running into a snag. Can someone please point out where appropriate naming needs to go to get this to come together?
This one works:
(select DATE_INDEX, SUM(LDS) as TTLLDS, SUM(TONS) as TTLTONS from
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC)
group by DATE_INDEX)Now I need to add in the following query:
select (u.MACH_TPH_D+u.MACH_TPH_N)/2 as MTPH_TGT, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2 as LTPH_TGT
from UTIL_TARGET_LOADERS u
where u.ORG_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)The join needs to be based on VEH_LOC and DAY in the form:
... WHERE u.ORG_ID = x.VEH_LOC
AND x.DATE_INDEX between u.START_DATE and NVL(u.END_DATE,sysdate)I had one that worked just fine when only one entity was involved; the complication arises in that this is a division-level report so I have to individually resolve the subordinates and their goals before I can aggregate. This is one of two queries I need to tie together using a WITH clause so I can pivot the whole thing and present it in month-by-month fashion. When I try to tie it together like the query below, I get: invalid relational operator.
select ttls.DATE_INDEX, SUM(ttls.LDS) as TTLLDS, SUM(ttls.TONS) as TTLTONS, u.TARGET_LTPH, u.TARGET_MTPH
from UTIL_TARGET_LOADERS u,
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC) ttls
where ttls.DATE_INDEX beween u.START_DATE and NVL(u.END_DATE,sysdate)
and ttls.VEH_LOC = u.ORG_ID
group by ttls.DATE_INDEXI know this is a nested mess, as it has to grab the production from two tables for a range of VEH_LOC values and sum and aggregate by day and VEH_LOC, then I have to try and match that to the targets based on VEH_LOC and day. My final query is to aggregate the whole mess of sums and averages by month.
I'd appreciate it if someone can point me in the right direction.
Figured it out.
select ttl.DATE_INDEX, SUM(ttl.LDS) as TTLLDS, SUM(ttl.TONS) as TTLTONS,
AVG((u.MACH_TPH_D+u.MACH_TPH_N)/2) as MTPH_TGT,
AVG((u.LABOR_TPH_D+u.LABOR_TPH_N)/2) as LTPH_TGT
from
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC) ttl, UTIL_TARGET_LOADERS u
where u.ORG_ID = ttl.VEH_LOC
and ttl.DATE_INDEX between u.START_DATE and NVL(U.END_DATE,sysdate)
group by ttl.DATE_INDEX, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2
Similar Messages
-
I'm trying to install elements 12 need help?
I'm trying to install elements 12 need help?
What problem are you encountering in trying to install Elements 12?
-
Hi all,
i have solution i got earlier form this forum.
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),1,101,5000);
INSERT INTO LHEADER VALUES (TO_DATE('01022009','DD/MM/YYYY'),2,102,3000);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),3,103,6000);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,1500,NULL,NULL,10);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,NULL,20,15,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),1,101,NULL,20,12,20);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),1,101,NULL,20,16,20);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),1,101,NULL,20,20,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,2000,15,NULL,15);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,NULL,12,10,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),2,102,NULL,12,15,8);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),2,102,NULL,12,12,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,3000,NULL,30,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,NULL,30,20,25);
SELECT ddt
, dhsr
, dhcode
, NVL ( CASE
WHEN d1 + d2 + d3 IS NULL
THEN LAG (run_tot) OVER ( PARTITION BY dhcode
, dhsr
ORDER BY ddt
END
, amount
) AS amount
, d1
, d2
, d3
, run_tot
FROM (
SELECT d.ddt
, d.dhsr
, d.dhcode
, NVL ( d.damount
, h.hamount
) AS amount
, d.d1
, d.d2
, d.d3
, h.hamount - CASE
WHEN d1 + d2 + d3 IS NULL
THEN NULL
ELSE SUM ( d.d1
+ d.d2
+ d.d3
) OVER ( PARTITION BY d.dhcode
, d.dhsr
ORDER BY d.ddt
END AS run_tot
FROM ddetail d
, lheader h where d.dhcode = h.hcode
AND d.dhsr = h.hsr
ORDER BY ddt
, dhcode
, d1 + d2 + d3 NULLS FIRST
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
31/01/2009 1.000 101 1500.000 10.000
31/01/2009 1.000 101 5000.000 20.000 15.000 20.000 4945.000
31/01/2009 3.000 103 6000.000 30.000 20.000 25.000 5925.000
28/02/2009 1.000 101 5000.000 20.000 12.000 20.000 4893.000
28/02/2009 2.000 102 2000.000 15.000 15.000
28/02/2009 2.000 102 3000.000 12.000 10.000 15.000 2963.000
28/02/2009 3.000 103 6000.000 30.000 20.000 25.000 5850.000
31/03/2009 1.000 101 5000.000 20.000 16.000 20.000 4837.000
31/03/2009 2.000 102 3000.000 12.000 15.000 8.000 2928.000
31/03/2009 3.000 103 6000.000 30.000 20.000 25.000 5775.000
30/04/2009 1.000 101 5000.000 20.000 20.000 20.000 4777.000
30/04/2009 2.000 102 3000.000 12.000 12.000 15.000 2889.000
30/04/2009 3.000 103 5775.000 30.000 25.000
30/04/2009 3.000 103 6000.000 30.000 20.000 25.000 5700.000
14 rows selected.i want to the output to be like this now;
the query should SUM d1,d2 & d3 where RUN_TOT is NULL.
Rows with Null RUN_TOT should not be shown.
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
31/01/2009 1.000 101 5000.000 20.000 15.000 *30.000* 4945.000
31/01/2009 3.000 103 6000.000 30.000 20.000 25.000 5925.000
28/02/2009 1.000 101 5000.000 20.000 12.000 20.000 4893.000
28/02/2009 2.000 102 3000.000 *27.000* 10.000 *30.000* 2963.000
28/02/2009 3.000 103 6000.000 30.000 20.000 25.000 5850.000
31/03/2009 1.000 101 5000.000 20.000 16.000 20.000 4837.000
31/03/2009 2.000 102 3000.000 12.000 15.000 8.000 2928.000
31/03/2009 3.000 103 6000.000 30.000 20.000 25.000 5775.000
30/04/2009 1.000 101 5000.000 20.000 20.000 20.000 4777.000
30/04/2009 2.000 102 3000.000 12.000 12.000 15.000 2889.000
30/04/2009 3.000 103 6000.000 30.000 *50.000 50.000* 5700.000
14 rows selected.Hello Mr. Frank..
I designed a report based on your solution, but when executed with the actual data, with what the user have entered,
the report didn't returned the expected result. Yes, your logic with the earlier data provided by me was correct.
but now the data has appeared in different manner.
i tried to modify your query but didn't exactly succeed.
for this data;
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('10/03/2010','DD/MM/YYYY'),12,1392,48571.1);
INSERT INTO LHEADER VALUES (TO_DATE('16/03/2010','DD/MM/YYYY'),14,1526,40732);
INSERT INTO LHEADER VALUES (TO_DATE('08/01/2010','DD/MM/YYYY'),9,1835,31600);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,217.434);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,2470,NULL,0,2.335);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.850,209.466);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,5.836,23.765);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,2.918,26.311);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,39573,0,13.855,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2008','DD/MM/YYYY'),14,1526,11620,NULL,0,50.046);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,58.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/04/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,103.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,106.921);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,7600,NULL,NULL,17.73);
INSERT INTO DDETAIL VALUES (TO_DATE('01/06/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,144.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/07/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,149.200);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,48.129);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,NULL,106.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,5700,NULL,NULL,8.620);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,190.576);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,172.133);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,37745,NULL,13.21,221.196);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,5225,NULL,NULL,4.939);
INSERT INTO DDETAIL VALUES (TO_DATE('04/01/2010','DD/MM/YYYY'),9,1835,31600,131.667,11.06,185.185);
INSERT INTO DDETAIL VALUES (TO_DATE('05/02/2010','DD/MM/YYYY'),9,1835,31468.333,131.667,11.014,166.567);
INSERT INTO DDETAIL VALUES (TO_DATE('08/03/2010','DD/MM/YYYY'),9,1835,31336.666,131.667,10.968,183.641);
INSERT INTO DDETAIL VALUES (TO_DATE('10/04/2010','DD/MM/YYYY'),9,1835,31204.999,131.667,10.922,176.971);
i modified your query like this;
SELECT ddt
, dhsr
, dhcode
, amount
, d1
, d2
, d3
, run_tot
FROM (
SELECT ddt
, dhsr
, dhcode
, NVL ( CASE
WHEN NVL(d1 + d2 + d3,0) = 0
THEN LAG (run_tot) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY ddt
END
, amount
) AS amount
, SUM (NVL(d1,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d1
, SUM (NVL(d2,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d2
, SUM (NVL(d3,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d3
, run_tot
FROM (
SELECT d.ddt
, d.dhsr
, d.dhcode
, NVL ( d.damount
, h.hamount
) AS amount
, d.d1
, d.d2
, d.d3
, h.hamount - CASE
WHEN NVL(d1 + d2 + d3,0) = 0
THEN NULL
ELSE SUM ( NVL(d.d1
+ d.d2
+ d.d3,0)
) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY d.ddt
END AS run_tot
, COUNT (d1 + d2 + d3) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY d.ddt DESC
) AS a_cnt
FROM ddetail d
, lheader h where d.dhcode = h.hcode
AND d.dhsr = h.hsr
--WHERE run_tot IS NOT NULL
WHERE to_char(ddt,'yyyymm') = '201003'
ORDER BY ddt
, dhcode
, d1 + d2 + d3
i got this output;
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 4489.7 0 16.773 258.22
01/03/2010 12 1392 39573 0 16.773 258.22 48325.336
01/03/2010 14 1526 37745 0 13.21 226.135
01/03/2010 14 1526 5225 0 13.21 226.135
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31273.724
but the expected result should be like this;
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 39573 0 16.773 258.220 39573.000
01/03/2010 14 1526 37745 13.210 226.135 37745.000
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31204.999
and when i change the last condition part...to
WHERE run_tot IS NOT NULL
AND to_char(ddt,'yyyymm') = '201003'
ORDER BY ddt
, dhcode
, d1 + d2 + d3 ...
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 39573 0 16.773 258.22 48325.336
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31273.724
1. The row for dhcode 1526 does not appear and
2. The runtot for 1835 gets wrongly calculated (it should be 31336.666-131.667=31204.999)Please suggest .
TYVM. -
New in Oracle forms and I need help
Good afternoon to all of you.
I need a help for my problem. I have 7 tables and i create a form with 7 blocks in oracle 10g. The items are lists and text items. I am trying to choose a value from the list or write something into the text items and i have a message
FRM-40200: Form is protected against update
and FRM-40208 : Form Running in Query Only Mode. Can Not Change. Database Field.
Please can anybody help me!!!When you create the block, i recomend you to use the Wizard. The Wizard creates the block automatically and it works well, you will not find these problems that you are facing.
Maybe the reasons for problem is:
- You set the property "UPDATE_ALLOWED "of the block/item to "NO", set to "YES";
- You set the property "INSERT_ALLOWED "of the block/item to "NO", set to "YES";
- You set the property "QUERY_ONLY"of the block/item to "YES", set to "NO"; -
JPA: Complex query needed to load object / special processing on store
I have what I think is a tricky situation with an ORM scenario, and I am wondering what I need to do to get JPA to work with this situation:
I have a table that looks like:
key_with_rev_id INTEGER (sequence based, unique pk)
key_id INTEGER (sequence based)
rev_id INTEGER (sequence based, with key_id forms unique index)
del_flag VC(1)
+ various data fields
The object would contain these attributes (preferably):
key_id (as the "unique" id)
max_rev_id (transient, defaults to null)
+ various data attributes
When I load it -- for max_rev_id = null, it should basically do this:
select <data fields> from revved_table
where key_id = <object.key_id>
and rev_id = (select max(rev_id) from revved_table where key_id = <object.key_id>)
and del_flag is null or del_flag = 'N'
The query is a little more complex when max_rev_id is not null, but same idea.
Now then -- when I store the object, whether it is to insert or update, I want it to always insert rows, with the key_with_rev_id and rev_id values from the corresponding sequences. (On insert, it will also use another seq to populate key_id). When I delete, I also want to insert a new row, but set del_flag = 'Y'
Is this too complex for JPA such that it would be a huge hassle, or is there an elegant way to set this up?
My apologies for any unusual terminology in the above -- I am quite new to JPA.
Thanks,
ken clarkDoes anyone have any suggestions as to where to start looking?
Thanks,
ken -
Heterogeneous Query, need help ASAP!
Post Author: zen69
CA Forum: Data Connectivity and SQL
Hi all! I'm trying to make a report that uses a view with linked table (tables from a linked server).I tested my view in SQL Server and it's working but when I try to use it in my report I get these two error messages:Error #1: Failed to retrieve data from the databaseError #2:
Failed to retrieve data from the database. Details:
42000:[Microsoft][ODBC SQL Server Driver][SQL Server]Heterogeneous queries
require the ANSI_NULLS and ANSI_WARNINGS options to be set for the
connection. This ensures cosistent query semantics. Enable these options and
then reissue your query. [Database Vendor Code: 7405 ]I'm using
Crystal Reports CR Professional; Product Type: FullVersion : 11.0.0.895. Please help me ASAP, I really need it to be done! Thanks,J.B.Post Author: zen69
CA Forum: Data Connectivity and SQL
I forgot to say that I'm using MS SQL Server 2005... -
I created a pdf that I just wanted people to be able to fill in, download, print out and then mail to me. I followed the instructions from a previous acrobat expert who replied to me yesterday and that did not work. Now, I've tried this 5 times and the system has blocked me out unless I pay for your advanced system which is $143. Please help
Re: Want to delete the "submit" link on a pdf
created by Lucia Lao in FormsCentral - View the full discussion
Hi,
I believe this is a form that you created with FormsCentral and then you downloaded/saved as PDF via the "Save Submission-Enabled PDF" button via the Distribute Tab.
Please select via FormsCentral app main menu:
- File -> Save As PDF Form... and then
- when you get the dialog "Would you like your PDF form to collect responses online in the "View Responses" tab?" select "Don't Collect Responses" button.
This will save the PDF form without the Submit button/link.
Thanks,
Lucia
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5218029#5218029
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: [http://forums.adobe.com/message/5218029#5218029]
To unsubscribe from this thread, please visit the message page at [http://forums.adobe.com/message/5218029#5218029]. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in FormsCentral by email or at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.The instructions Lucia gave you were correct. It seems you have a Basic trial account (5 forms). You can just delete the forms you are not using so you can create more. Can you explain in more detail how those instructions above didn't work? I think there is some confusion so any details you can provide will help clear it up.
Randy -
New on forms server 6i : need help
Hi,
I have installed a web sever that have to use Form Server Listener to read .fmx file on the website.
When I launch my web page, all the classes are founded and imported, IExplorer indicate applet initialized, But I have no picture from the applet... the form where the applet have to be executed is a white page and the server isn't displaying any error.
- My web server is correctly configured (I've tried with OAS and IIS)
- The HTML pages are correct (website is running on an other server)
- Ifsrv60 and Ifweb60 are running
- My environement variables seems to be correct and my registry entries too.
- No problem with the database connection
I also got this error on Java Console
Following Exception occured: sun.applet.AppletSecurityException: checkconnect.networkhost3
sun.applet.AppletSecurityException: checkconnect.networkhost3
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at java.lang.RuntimeException.<init>(RuntimeException.java:50)
at java.lang.SecurityException.<init>(SecurityException.java:42)
at sun.applet.AppletSecurityException.<init>(AppletSecurityException.java:29)
at sun.applet.AppletSecurityException.<init>(AppletSecurityException.java:34)
at sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:643)
at sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:666)
at sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:566)
at sun.plugin.ActivatorAppletContext.getImage(ActivatorAppletContext.java:65)
at java.applet.Applet.getImage(Applet.java:197)
at oracle.forms.engine.FormsImageLoader.loadFormsImage(Unknown Source)
at oracle.forms.engine.FormsImageLoader.getDefaultImage(Unknown Source)
at oracle.forms.engine.Main.getDefaultImage(Unknown Source)
at oracle.forms.engine.Main.getParamImage(Unknown Source)
at oracle.forms.engine.Main.getLogo(Unknown Source)
at oracle.forms.engine.Main.initDesktop(Compiled Code)
at oracle.forms.engine.Main.start(Unknown Source)
at sun.applet.JinitAppletPanel.run(Compiled Code)
at java.lang.Thread.run(Thread.java:466)
Does anyone Knows where the problem could come from. Any suggestion will be welcomed.
nullHi,
it seems that you Java VM doesn't allow a connection to a server on you network.
You'd better try to configure your HTML file or CGI environment to use Oracle JInitiator.
Otherwise you need to use IE 5.0 and configure it's security so that it allows you to connect to the correct host.
HTH,
Michael -
What's wrong with this query--need help
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected
please help.
thanks in advance.Hi,
861173 wrote:
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected Try:
WHERE TO_CHAR (hiredate, 'fmday') = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding. -
Hello,
I am having trouble in getting the result at the bottom. I have two tables as below. I need Idno,transdt,cycdt,amt from joining two tables.
The criteria is that if the transdt greater than same month of cycdt then we need get the next month cycdt and corresponding amount for that, if it is less than or equal to same months cycdt then get the same months cycdt and amt.
Table1
idno,trandt
12345,04/15/2005
12345,04/22/2005
12345,07/03/2005
12345,09/10/2005
3421,03/05/2005
3421,05/06/2005
3421,07/04/2005
3421,07/15/2005
Table2
idno,cycdt,amt
12345,02/10/2005,15.43
12345,03/13/2005,40.84
12345,04/18/2005,10.10
12345,05/24/2005,13.00
12345,06/16/2005,20.89
12345,07/18/2005,12.12
12345,08/17/2005,10.89
12345,09/17/2005,12.87
12345,10/16/2005,13.89
3421,05/10/2005,15.00
3421,06/11/2005,20.00
3421,07/11/2005,14.15
3421,08/12/2005,15.54
Expected result.
12345,04/15/2005,12345,04/18/2005,10.10
12345,04/22/2005,12345,05/24/2005,13.00
12345,07/03/2005,12345,07/18/2005,12.12
12345,09/10/2005,12345,09/17/2005,12.87
3421,05/06/2005,3421,05/10/2005,15.00
3421,07/04/2005,3421,07/11/2005,14.15
3421,07/15/2005,3421,08/12/2005,15.54
I really appreciate if someone can give a solution for this using a query.
ThanksWill this help you
SELECT IDNO,TRANDT,IDNO1,CYCDT,AMT FROM
SELECT IDNO,TRANDT,
IDNO1,
CYCDT,
AMT,
COUNT(TRANDT) OVER(PARTITION BY TRANDT ORDER BY 1) CNT
FROM
SELECT T1.IDNO IDNO,T1.TRANDT,T2.IDNO IDNO1,T2.CYCDT,T2.AMT
FROM T1,T2
WHERE T1.IDNO=T2.IDNO
WHERE (TO_CHAR(TRANDT,'MM') = TO_CHAR(CYCDT,'MM') AND
TO_CHAR(TRANDT,'DD') < TO_CHAR(CYCDT,'DD'))
OR
(TO_NUMBER(TO_CHAR(TRANDT,'MM'))+1 = TO_CHAR(CYCDT,'MM'))
ORDER BY 1,2,4
WHERE TO_CHAR(TRANDT,'MM') = TO_CHAR(CYCDT,'MM') OR CNT=1
ORDER BY 1 DESC,2,4Output:
IDNO TRANDT IDNO1 CYCDT AMT
12345 4/15/2005 12345 4/18/2005 10.1
12345 4/22/2005 12345 5/24/2005 13
12345 7/3/2005 12345 7/18/2005 12.12
12345 9/10/2005 12345 9/17/2005 12.87
3421 5/6/2005 3421 5/10/2005 15
3421 7/4/2005 3421 7/11/2005 14.15
3421 7/15/2005 3421 8/12/2005 15.54 -
Row_number query - need help ASAP
Hi ,
Need some help bout query
I need a query for display output like below
DATE CODE MAC_NO BATCH_NO
01-OCT-07 1119 02 1
20-OCT-07 1210 01 2
01-NOV-07 1209 01 3
01-NOV-07 1510 01 4
01-NOV-07 4025 01 5
01-NOV-07 4025 01 5
01-NOV-07 4051 03 6
02-NOV-07 1209 01 7
i hv no idea how to do it. My query doesn't work for tat requirement.Tis is my query
SELECT date
,code
,mac_no
,ROW_NUMBER()
OVER (PARTITION by date,code,mac_no
ORDER by date,code,mac_no)
as batch_no
FROM PAYMENT
WHERE npcs_cycle_num = 27
AND txn_insert_seq_num > 0;
The output juz like below.I need everybody help ASAP.
DATE CODE MAC_NO BATCH_NO
01-OCT-07 1119 02 1
20-OCT-07 1210 01 1
01-NOV-07 1209 01 1
01-NOV-07 1510 01 1
01-NOV-07 4025 01 1
01-NOV-07 4025 01 2
01-NOV-07 4051 03 1
02-NOV-07 1209 01 1
Thanks
CTI'm sorry..Maybe my words it not that clear enough. You were right about how ROW_NUMBER works (it
assigns a numeric value and resets based on the grouping you specify in the PARTITION clause).
What I want actually is the row number increment based on the txn_date,poc_code and machine_no.
I'm not sure whether using the row_number() can solve my solutions. I really hope that you could help me.
I thought of using row_number() may help. Do you have any other solution?
Here is my table description.
DESC PAYMENT;
Name Null? Type
TXN_ID_NUM NOT NULL NUMBER(12)
ACCT_NO NOT NULL VARCHAR2(14)
CANCEL_CODE VARCHAR2(5)
ADJ_TYPE_NO VARCHAR2(2)
REASON_CODE VARCHAR2(5)
CASHIER_ID_NO VARCHAR2(10)
SUPERVISOR_ID_NO VARCHAR2(10)
REV_CODE VARCHAR2(5)
TXN_DATE DATE
PAY_ADJ_DATE DATE
POC_CODE VARCHAR2(10)
MACHINE_NO VARCHAR2(3)
PAY_MODE_CODE VARCHAR2(5)
ORIG_ACCT_NO VARCHAR2(14)
PAY_AMT NUMBER(12,2)
INVOICE_NO VARCHAR2(20)
PAY_RECEIPT_NO VARCHAR2(24)
PAY_BATCH_NO VARCHAR2(20)
NPCS_CYCLE_NUM NUMBER(4)
TXN_INSERT_SEQ_NUM NOT NULL NUMBER(12)
2) Below is the query before assigning the row number:
SQL> SELECT TXN_DATE,POC_CODE,MACHINE_NO,PAY_BATCH_NO,PAY_AMT,REV_CODE,ADJ_TYPE_NO,PAY_MODE_CODE
2 FROM PAYMENT
3 WHERE NPCS_CYCLE_NUM=27
4 AND REV_CODE IN (SELECT rev_code
5 FROM OUTBND_REV_CODE
6 WHERE outbnd_agen_file_code = 'TMB'
7 AND sys_appl_id ='CCC')
8 ORDER BY TXN_DATE,POC_CODE,MACHINE_NO;
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1
01-NOV-07 1510 01 20071101402501100000 493 014 00 1
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1
3)This is my query and the result:
SQL> SELECT /* SQL_ID 2703 */
2 txn_date
3 ,poc_code
4 ,machine_no
5 ,pay_batch_no
6 ,pay_amt
7 ,rev_code
8 ,adj_type_no
9 ,pay_mode_code
10 ,ROW_NUMBER()
11 OVER (PARTITION by txn_date,poc_code,machine_no
12 ORDER by txn_date,poc_code,machine_no)
13 as row_number
14 FROM PAYMENT
15 WHERE npcs_cycle_num = 27
16 AND txn_insert_seq_num > 0
17 AND rev_code IN (SELECT rev_code
18 FROM OUTBND_REV_CODE
19 WHERE outbnd_agen_file_code = 'TMB'
20 AND sys_appl_id ='CCC');
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M ROW_NUMBER
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1 1 (1)
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5 1 (2)
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1 1 (3)
01-NOV-07 1510 01 20071101402501100000 493 014 00 1 1 (4)
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3 1 (5)
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1 2 (5)
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3 1 (6)
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1 1 (7)
8 rows selected.
What I want actually as in the bracket (group by three fields which are txn_date,poc_code and machine_no)
.I hope this is clearer. -
Hi Experts,
I've gone through so many mpls documents and I believe i have a decent grasp of how it works but applying those principles i appear to be stuck in a setup that just won't work.
The setup is pretty straigh forward: R1 is connected to R2 and R2 is connected to R3.
R1 has ospf peering with R2 and R2 has ospf peering with R3.
OSPF working fine and connectivity via Lo on all routers working.
R1 has MP-BGP bgp peering with R3 where R1 and R3 is advertising its Lo100 interface to each other.
BGP working fine and I can see from R1 the Lo100 ip of R3 on the vrf myvrf routing table of R1.
When I do a show ip route vrf myvrf on R1, route to Lo100 of R3 (99.1.1.3) has an egress of 5.1.1.3 (default global table).
But when i try to ping from R1, 'ping vrf myvrf 99.1.1.3 source 99.1.1.1' , ping fails.
Documentation says that this should work but apparently it doesn't for me; am not sure what i am missing here.
I even tried to leak the route on both R1 and R3. But still no go.
R1:
ip route vrf myvrf 5.1.1.3 255.255.255.255 f0/0 1.1.1.2
R3:
ip route vrf myvrf 5.1.1.1 255.255.255.255 f0/0 2.1.1.1
Don't know what i am doing wrong here. And to be honest am getting confused. Please help.
Setup is as follows:
R1:
int f0/0
ip 1.1.1.1 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.1
int Lo100
ip vrf forwarding myvrf
ip add 99.1.1.1 255.255.255.255
ip vrf myvrf
rd 10:20
route-target both 10:20
router ospf 1
router-id 5.1.1.1
network 1.1.1.0 0.0.0.255 area 0
network 5.1.1.3 0.0.0.0.0 area 0
router bgp 10
neighbor 5.1.1.3 remote-as 10
no neighbor 5.1.1.3 active
neighbor 5.1.1.3 update-source Lo0
address-family vpnv4
neighbor 5.1.1.3 activate
neighbor 5.1.1.3 send-community both
address-family ipv4 vrf myvrf
network 99.1.1.1 mask 255.255.255.255
R2:
int f0/0
ip add 1.1.1.2 255.255.255.0
mpls ip
int f1/0
ip add 2.1.1.1 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.2 255.255.255.0
router ospf 1
router-id 5.1.1.2
network 1.1.1.0 0.0.0.255 area 0
network 2.1.1.0 0.0.0.255 area 0
network 5.1.1.2 0.0.0.0 area 0
R3:
int f0/0
ip add 2.1.1.2 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.3 255.255.255.0
int Lo100
ip vrf forwarding myvrf
ip add 99.1.1.3 255.255.255.255
router ospf 1
network 2.1.1.0 0.0.0.255 area 0
network 5.1.1.2 0.0.0.0 area 0
router bgp 10
neighbor 5.1.1.1 remote-as 10
no neighbor 5.1.1.1 activate
neighbor 5.1.1.1 update-source Lo0
address-family vpnv4
neighbor 5.1.1.3 activate
neighbor 5.1.1.3 send-community both
address-family ipv4 vrf myvrf
network 99.1.1.3 mask 255.255.255.255Hello Marcusbrutus,
blau grana is right you have an issue with loopback addresses subnet masks.
Your control plane looks like fine because you have all the expected MP BGP VPNv4 routes in place, but the forwarding plane is broken.
MPLS L3 VPN packets are sent within the LSP with destination the remote PE loopback address so from R1 point of view is R3's L0.
If you go on R2 device and you check the state of MPLS forwarding for R3 L0 IP address you will see that instead of seeing a POP TAG action you will see an untagged action.
The reason for the wrong LSP binding is the subnet mask on R3 loopback address: OSPF advertises all loopback addresses with a /32 mask by default, but the subnet mask is different. LDP carries the configured subnet mask. But installation of labels is made after check with IGP (OSPF in this case).
As a result of this the R2 router cannot install the correct POP TAG = implicit null label as action to do to reach R3 L0.
With POP TAG action the R2 router removes the external label (POP a label) and sends a packet (with MPLS ethertype on ethernet) with a single label MPLS stack to the egress PE R3. R3 sees a label associated to the VRF and it is able to route the packet to the appropriate interface.
With untagged action R2 removes a label take all the packet content and sends it as it was an IP packet to the downstream device. (with ethertype 0x800 on ethernet) The downstream device finds a packet that is supposed to be an IP packet but it isn't (for the inner label still there) and silently drops it.
This is what we had seen in lab tests.
To solve this issue you should:
use /32 loopback addresses this the recommended best practice
or you can still use non overlapping non /32 loopback addresses but you need to add the command ip ospf network point-to-point under loopback configuration as this makes OSPF to advertise the true IP subnet mask
Hope to help
Giuseppe -
I have a row output like this
select * from test;
s.no C1 C2 C3
1 a1 b1 x1
2 a1 b1 x2
3 a1 b1 x3
i want the output as with the new added column as like this
s.no C1 C2 C3 C4
1 a1 b1 x1 a1
2 a1 b1 x2 b1
3 a1 b1 x3 x3
pls help me in this query its urgent for the solutionHello,
So, what is the complexity in this query? Would you like to mention from where you will get that C4 column?
-Ammad -
Trying to activate cs6 and need help please
i just spent an hour with this dude in india trying to activate cs6 production premium academic
i am trying to 'offline' activate my editing rig because it's too heavy to move to internet
also i installed the trial version of cs6 production premium
and tried to activate that with the academic serial numbers (because it installed correctly and the updates, too)
i got the REQUEST code: when you type it into the activation page do you use the spacebar between each set of 4 characters?
are the 0's upper case letter o's or are they zeros?
we tried all sorts of combinations and nothing works so i'm supposed to wait 4-5 hours until licensing/activation people get into the office...
does anyone have any help or advice on this please?
thanks again,
j>editing rig because it's too heavy to move to internet
Since there have been bug fix updates, you will need to get the update files to your computer
Either by using a different computer and a USB flash drive, or by buying a LONG network cable
All Adobe updates start here and select product, read to see if you need to install updates in number order, or if the updates are cumulative for the individual product http://www.adobe.com/downloads/updates/ -
FORMS - WEB DEPLOYMENT - NEED HELP -
Hi
We have developed some forms using Forms 6.0 on Win NT and now
wish to deploy that on Web. We have installed Developer Server
(For Forms, Reports and Graphics) in one of our UNIX boxes.
What steps are needed to get the Forms run on our Intranet as
HTML documents?
Thanks for reply in advance
Karthi
nullKarthi (guest) wrote:
: Hi
: We have developed some forms using Forms 6.0 on Win NT and now
: wish to deploy that on Web. We have installed Developer Server
: (For Forms, Reports and Graphics) in one of our UNIX boxes.
: What steps are needed to get the Forms run on our Intranet as
: HTML documents?
: Thanks for reply in advance
: Karthi
Hi Karthi,
Forms is not a HTML web deployment. The deployment is based on
generic Applets. This means that we are transferring the UI to a
browser by simply replacing Motif (in your case) with Java on the
server side. If you want to deploy a Forma application in the web
just create s static HTML file (example files can be viewed after
installing JInitiator) with a reference to your Forms Module that
you use as a starting point. Start the Forms Server on the
command shell with f60ctl start port=9000 (if yiou want to use
port 9000). Via the web you access the Forms Server by calling
the static HTML File. In this HTML there is a request for the
Forms Listener.
Hope this short answer will give you a hint.
null
Maybe you are looking for
-
Problem in converting an xdp file to xsd
Hi, I designed one form and i saved that form as both xdp and pdf.I also created an xfaform variable in the workbench to hold that form.But in the variable dialogue box,in the schema settings ,the form schema is not displaying as no schema is a
-
Can I use Photoshop from Creative Cloud on my Chrome OS laptop?
I have a Chromebook laptop, which runs the Chrome OS. Can I use my creative cloud products on that OS?
-
Contact sheet II, grayed out photos
Going to: Source Images>Folder>Choose... when choosing my folder all pix are grayed out so I cannot import them. This happens to all pix. I'm using a MacBook Pro. Thank you....
-
Hello, my client gave me the following requirement and I am having a bit hard time trying to code it....Here it is. Data is coming in like this Reporting App Time Category Company Costcenter Shipto Account Signeddata 2011.jan Actu
-
Trouble accepting my serial number for CS2 Illustrator and activation Illustrator