Data aggregation problem in query
Hi everyone,
I have the data in the following format in ODS with Doc# IT# SC# and DT# as KEY. My requirement is to see the data in query as shown below (Query view 1 and Query view 2).
DOC# IT# SC# DT# QTY
123 01 1 9/01/04 10
123 01 1 9/02/04 10
123 01 1 9/03/04 10
123 01 2 9/04/04 10
123 01 3 9/05/04 10
123 01 3 9/06/04 10
Query view 1
DOC# IT# SC# QTY
123 01 1 10
123 01 2 10
123 01 3 10
Query view 2
DOC# IT# QTY
123 01 30
Can anyone let me know how can I achieve this ?
Helpful answers will be rewarded.
AK
No replies ???
AK
Similar Messages
-
Webi report data aggregation problem
Hi Gurus,
I have a problem when running webi report upon BI query.
In infoview, report shows as below,
Material Plant Sales
A 001 100
A 002 100
B 001 120
If I drap Plant column out, it shows,
Material Sales
A 100
B 120
Material A's sales is 100, not 200 as in BI rsrt1.
What might be the problem, any clue?Hi Rongliang,
I've checked it, it is set as you said.
The problem still exists.
Another thing is , we got 3 dimensions, Material, Sales Org, Plant,
Key figure aggregates well for Sales Org and Plant, but not working for Material.
Any clue? -
hi
i have following query to show the monthly sales after summing up monthly sales total but i have facing a problem this query is not properly perform order by clause according to the months like jan,feb,mar etc... please tell me where i made mistake
SELECT CashName AS AccountName, LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate) AS Months, SUM(Total) AS NetSales
FROM dbo.CashSales
GROUP BY LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate), CashNameSelect AccountName, Months, NetSales from
(SELECT CashName AS AccountName, LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate) AS Months, SUM(Total) AS NetSales,
DATEADD(month, DATEDIFF(month, 0, CashDate), 0) as dt
FROM dbo.CashSales
GROUP BY LEFT(DATENAME(month, CashDate), 3) + ' - ' + DATENAME(year, CashDate), CashName, DATEADD(month, DATEDIFF(month, 0, CashDate), 0)
t
Order By dt -
Key Date variable; Interval in query properties for Time Dep. Masterdata
Hi,
I've been searching on the forum, and I think I know the answer already, but still I'd like
to ask you all whether it's possible to create a Key Date Interval variable to be used in the query properties.
As far as I can see you can only report by a single key date used in the query properties field for time dependant masterdata, but my customer has asked me to investigate the possibility to enter a date range.
As all masterdata is time dependant I don't see how this would work, but if someone can shine a light on this maybe there is a solution available?
Thanks for your help.
M.Hi marc
I understand your problem.
I had an idea for a workaround.
If you can create master data compounded with Valid from and Valid to both of these characteristics , how the query is computing
the keyfigures.
Every change in valid from or valid to is unique for the system in this case.
Thanks
N.Ganesh -
The problem of query in oracle xml db
hello everybody!
I create a table of xmltype,and insert data in it. But I query data ,the problem comes up.
the xml instance is :
<?xml version="1.0" encoding="UTF-8"?>
<!-- File: cambridge.xml -->
<CityModel xmlns="http://www.opengis.net/examples" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/examples city.xsd">
<gml:name>Cambridge</gml:name>
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0.0</gml:X>
<gml:Y>0.0</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>100.0</gml:X>
<gml:Y>100.0</gml:Y>
</gml:coord>
</gml:Box>
</gml:boundedBy>
<cityMember>
<River>
<gml:description>The river that runs through Cambridge.</gml:description>
<gml:name>Cam</gml:name>
<gml:centerLineOf>
<gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0</gml:X>
<gml:Y>50</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>70</gml:X>
<gml:Y>60</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>100</gml:X>
<gml:Y>50</gml:Y>
</gml:coord>
</gml:LineString>
</gml:centerLineOf>
</River>
</cityMember>
<cityMember>
<Road>
<gml:name>M11</gml:name>
<linearGeometry>
<gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0</gml:X>
<gml:Y>5.0</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>20.6</gml:X>
<gml:Y>10.7</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>80.5</gml:X>
<gml:Y>60.9</gml:Y>
</gml:coord>
</gml:LineString>
</linearGeometry>
<classification>motorway</classification>
<number>11</number>
</Road>
</cityMember>
<cityMember xlink:type="simple" xlink:title="Trinity Lane" xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239" gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
<!-- a mountain doesn't belong here! Uncomment this cityMember and see
the parser complain!
<cityMember>
<Mountain>
<gml:description>World's highest mountain is in Nepal!</gml:description>
<gml:name>Everest</gml:name>
<elevation>8850</elevation>
</Mountain>
</cityMember>
-->
<dateCreated>2000-11</dateCreated>
</CityModel>
I query it:
set long 50000
SELECT extract(value(X),
'/CityModel/gml:boundedBy/gml:Box/gml:coord')
FROM city X;
ERROR:
ORA-31011: XML 语法分析失败
ORA-19202: XML 处理
LPX-00601: Invalid token in: '/CityModel/gml:boundedBy/gml:Box/gml:coord' 时出错
未选定行
when query it again:
set long 50000
SELECT extract(value(X),
'/CityModel/boundedBy/Box/coord')
FROM city X; (it has no namespace)
EXTRACT(VALUE(X),'/CITYMODEL/BOUNDEDBY/BOX/COORD')
has no result.
thank you very much!<?xml version="1.0" encoding="UTF-8"?>
<!-- File: cambridge.xml -->
<CityModel xmlns="http://www.opengis.net/examples" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<gml:name>Cambridge</gml:name>
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0.0</gml:X>
<gml:Y>0.0</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>100.0</gml:X>
<gml:Y>100.0</gml:Y>
</gml:coord>
</gml:Box>
</gml:boundedBy>
<cityMember>
<River>
<gml:description>The river that runs through Cambridge.</gml:description>
<gml:name>Cam</gml:name>
<gml:centerLineOf>
<gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0</gml:X>
<gml:Y>50</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>70</gml:X>
<gml:Y>60</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>100</gml:X>
<gml:Y>50</gml:Y>
</gml:coord>
</gml:LineString>
</gml:centerLineOf>
</River>
</cityMember>
<cityMember>
<Road>
<gml:name>M11</gml:name>
<linearGeometry>
<gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>0</gml:X>
<gml:Y>5.0</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>20.6</gml:X>
<gml:Y>10.7</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>80.5</gml:X>
<gml:Y>60.9</gml:Y>
</gml:coord>
</gml:LineString>
</linearGeometry>
<classification>motorway</classification>
<number>11</number>
</Road>
</cityMember>
<cityMember xlink:type="simple" xlink:title="Trinity Lane" xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239" gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
<!-- a mountain doesn't belong here! Uncomment this cityMember and see
the parser complain!
<cityMember>
<Mountain>
<gml:description>World's highest mountain is in Nepal!</gml:description>
<gml:name>Everest</gml:name>
<elevation>8850</elevation>
</Mountain>
</cityMember>
-->
<dateCreated>2000-11</dateCreated>
</CityModel>
SQL>create table city of xmltype;
then insert the data into the table
and query:
set long 50000
SELECT extract(value(X),
'/CityModel/boundedBy/Box/coord')
FROM city X; (it has no namespace)
EXTRACT(VALUE(X),'/CITYMODEL/BOUNDEDBY/BOX/COORD')
and I query it again:
set long 50000
SELECT extract(value(X),
'/CityModel/gml:boundedBy/gml:Box/gml:coord')
FROM city X;
ERROR:
ORA-31011: XML 语法分析失败
ORA-19202: XML 处理
LPX-00601: Invalid token in: '/CityModel/gml:boundedBy/gml:Box/gml:coord' 时出错
未选定行
ma oracle is 10g
thank you very much!
Message was edited by:
user508129 -
View with columns based on function - problem with query
Hi,
I'm using Oracle 9i;
I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
The function takes ID as the first argument and name of the column to determine which value to return as the second one.
Here is a sample of such function (simplified):
FUNCTION my_function
(in_id IN NUMBER, in_col_name IN VARCHAR2)
RETURN VARCHAR2
IS
c_name VARCHAR2(100);
c_last_name VARCHAR2(100);
BEGIN
SELECT T.NAME, T.LAST_NAME
INTO c_name, c_last_name
FROM TABLE_1 T, TABLE_2 Z
WHERE T.PK = Z.FK
AND Z.ID = in_id;
IF in_col_name = 'NAME' THEN
RETURN c_name;
ELSIF in_col_name = 'LAST_NAME' THEN
RETURN c_last_name;
END IF;
END;
For simplicty I've restricted the number of columns.
CREATE OR REPLACE VIEW my_view
(ID, NAME, LAST_NAME)
AS
SELECT
T.ID ID
,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
FROM TABLE T;
There is no problem with query:
SELECT * FROM my_view;
The problem arises when I query the view (regardles of '=' or 'LIKE'):
SELECT * FROM my_view
WHERE name LIKE '%some_part_of_name%'
The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
Help needed.
Greetings.The problem is more complicated than the solutions provided here.
The reason why I'm using the function is this:
the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
Here are real DDLs:
View:
CREATE OR REPLACE VIEW V_DOK_ARCH
(ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
AS
SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
Z.ID_ZDAR ID_ZDAR
, Z.TYP TYP
, Z.STAN STAN
, Z.DATE_CREATED DATE_CREATED
, Z.CREATED_BY CREATED_BY
, Z.DATE_MODIFIED DATE_MODIFIED
, Z.MODIFIED_BY MODIFIED_BY
, Z.SPRA_ID_SPRA SPRA_ID_SPRA
, Z.PODM_ID_PODM PODM_ID_PODM
, Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
, Z.NR_WFS NR_WFS
, Z.WFS_NR_INTER WFS_NR_INTER
, Z.UWAGI_OPER UWAGI_OPER
, Z.FUNDUSZ FUNDUSZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
, F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
, CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
FROM T_ZDARZENIA Z
WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
and functions:
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN VARCHAR2
IS
c_numer T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
c_rodzaj T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
c_typ_przy T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
c_typ_ubez T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
c_nazwisko T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
c_imie T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
c_imie_ojca T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
c_nazwa_firmy T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
c_jest VARCHAR2(1) := 'T';
c EXCEPTION;
BEGIN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
--raise c;
IF WE_KOLUMNA = 'NUMER' THEN
RETURN c_numer;
ELSIF WE_KOLUMNA = 'RODZAJ' THEN
RETURN c_rodzaj;
ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
RETURN c_typ_przy;
ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
RETURN c_typ_ubez;
ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
RETURN c_nazwisko;
ELSIF WE_KOLUMNA = 'IMIE' THEN
RETURN c_imie;
ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
RETURN c_imie_ojca;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
RETURN c_nazwa_firmy;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
RETURN c_nazwa_firmy_skr;
ELSIF WE_KOLUMNA = 'JEST' THEN
RETURN c_jest;
END IF;
END;
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN DATE
IS
d_data DATE;
BEGIN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
d_data := NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
RETURN d_data;
END IF;
END; -
ORA-01403: no data found Problem when using AUTOMATIC ROW FETCH to populate
ORA-01403: no data found Problem when using AUTOMATIC ROW FETCH to populate a form.
1) Created a FORM on EMP using the wizards. This creates an AUTOMATIC ROW FETCH
TABLE NAME - EMP
Item Containing PRIMARY KEY - P2099_EMPNO
Primary key column - EMPNO
By default the automatic fetch has a ‘Process Error Message’ of ‘Unable to fetch row.’
2) Created a HTML region. Within this region add
text item P2099_FIND_EMPNO
Button GET_EMP to submit
Branch Modified the conditional branch created during button creation to set P2099_EMPNO with &P2099_FIND_EMPNO.
If I then run the page, enter an existing employee number into P2099_EMPNO and press the GET_EMP button the form is populated correctly. But if I enter an employee that does not exist then I get the oracle error ORA-01403: no data found and no form displayed but a message at the top of the page ‘Action Processed’.I was expecting a blank form to be displayed with the message ‘Unable to fetch row.’
I can work around this by making the automated fetch conditional so that it checks the row exists first. Modify the Fetch row from EMP automated fetch so that it is conditional
EXIST (SQL query returns at least one row)
select 'x'
from EMP
where EMPNO = :P2099_EMPNO
But this means that when the employee exists I must be fetching from the DB twice, once for the condition and then again for the actual row fetch.
Rather than the above work around is there something I can change so I don’t get the Oracle error? I’m now wondering if the automatic row fetch is only supposed to be used when linking a report to a form and that I should be writing the fetch process manually. The reason I haven’t at the moment is I’m trying to stick with the automatic wizard generation as much as I can.
Any ideas?
Thanks PeteHi Mike,
I've tried doing that but it doesn't seem to make any difference. If I turn debug on it shows below.
0.05: Computation point: AFTER_HEADER
0.05: Processing point: AFTER_HEADER
0.05: ...Process "Fetch Row from EMP": DML_FETCH_ROW (AFTER_HEADER) F|#OWNER#:EMP:P2099_EMPNO:EMPNO
0.05: Show ERROR page...
0.05: Performing rollback...
0.05: Processing point: AFTER_ERROR_HEADER
I don't really wan't the error page, either nothing with the form not being populated or a message at the top of the page.
Thanks Pete -
How to compare dates in a select query in open sql
Hi
How can I retrieve data pertaining to a specified date using a select query.
I have inserted date using the following code:
String dateString = "2009-03-11";
java.sql.Date date = java.sql.Date.valueOf(dateString);
PreparedStatement stmt =con.prepareStatement("insert into DATEACCESS"
+ "(DATETEST)"
+ "values (?)");
stmt.setDate(1,date);
stmt.executeUpdate();
How can I pass this in a select query,the below mentioned query did not fetch me any results.
Select * from DATEACCESS where DATETEST='2009-03-11'Hi
Has ur date problem resolved ?
If not resolved u can do the following
As u already have sql date today declared . You want to get the data depending on that date
As ur query is
if( today != null)
String query2 = select * from DATEACCESS where DATETEST<= ?
PreparedStatement ps = conn.prepareStatement(query2);
ps.setDate(1,today)
ResultSet rs = ps.executeQuery();
While(rs.next)
////// Here u will get data from query u needed ///
If this also does not work just print the date and check in which format is it returning u .
Regards
Anuradha Rao
Edited by: Anuradha Rao on Mar 20, 2009 10:16 AM -
Problem in query with the u0091Document numberu0092
Hi,
I got problem in query with the Document number
There are three columns in the cube 1) Document number 2) Country 3) Count
In the cube there are multiple entries for same document number as below.
Document number country Count
10000 US 1
10001 US 1
10002 US 1
10002 US 1
10002 US 1
10003 UK 1
10004 IN 1
10004 IN 1
When I ran the query on this cube for country US it shows count as 5 but I want count as 3 (i.e. it has to take count only once for the same document nos)
Similarly for country IN I want count as 1Hi,
You have to create a counter based on the document number (exception aggregation). There is a How-to paper available for this. It is called: How-to...count the occurences of a characteristic.
Regards,
P. -
hi
i m having problem in query please help me
here data is not coming
SELECT HBKID FROM PAYR INTO CORRESPONDING FIELDS OF TABLE INT_PAYR WHERE
ZBUKR = P_BUKRS
AND UBHKT IN (P_OHKONT).
loop at int_payr.
OUT_HBKID = int_payr-W_hbkid .
MODIFY INT_PAYR.
endloop.
give me advice.
thanks .This example will help you ...
data: begin of i_mara occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of i_mara.
data: wa_maktx type maktx.
select matnr into table i_mara from mara where matnr =
'000000000000000001'.
select maktx into wa_maktx from makt
for all entries in i_mara where matnr = i_mara-matnr.
endselect.
loop at i_mara.
i_mara-maktx = wa_maktx.
modify i_mara transporting maktx .
endloop.
Regards,
Jayant
Please award if helpful -
Tab Canvas : 1 data block 2 different query for each tab) Forms 10g
Hello allllll,
I have 2 blocks Master datail ,the master is non-db the tab canvas is for one data block:
Problem 1: How 2 display same data block in each tab.?
Problem 2: How when pressing excute Query button each tab display the data
----------------------specified by the Master block..?
Regards,
Abdetu..-- When-New-Form-instance
IF :SYSTEM.Record_Status ='query' THEN
go_block('PLN_STOCK_TAKING_HEADER');
execute_query;
go_block('PLN_STOCK_TAKING_DETAIL');
execute_query;
go_block('PLN_STOCK_TAKING_DETAIL2');
execute_query;
END IF;
same behaviour,excute on tab2 not tab1,well i think it has something to do with the relation..!
Regards,
Abdetu.. -
Date function problems with dates from core not recognized as dates
Our core provides dates in two formats: YYYYDDD and MMDDYY (YYYYDDD for today [2/21/12] would be 2012052). We have determined that Crystal Reports is not viewing them as dates, but rather numbers. If querying on just a specific date, no problem. But if I want to use a date function like DayOfWeek, then things don't work.
I need a report to always provide yesterday's data - except on Monday, where it needs to look back at Friday.
I tried a criteria of:
if DayOfWeek(CurrentDate) = 1 then {DDMAST.DATOP7} = CurrentDate - 2 else
if DayOfWeek(CurrentDate) = 2 then {DDMAST.DATOP7} = CurrentDate - 3 else
{DDMAST.DATOP7} = CurrentDate -1
{DDMAST.DATOP7} is the date field from our core.
I tried this but got an error message of "A Number is Required Here" and it highlights the CurrentDate - 2.
Since we believe that Crystal Report is not viewing our dates as dates - but viewing them as numbers, what do I need to do to correct this? Someone suggested I'd need to extract each date portion (month, date, and year) and create variables to "build" a date that Crystal Reports would understand. Any suggestions?Hi,
You're correct. There appears to be two branches in this thread.
To address your issue, Crystal only recognizes actual date types, ie. Months, Days and Years. Your serial date isn't a recognized date type so we have to:
1) Determine which format your date field is
2) Convert your number to a date using the appropriate formatting.
I am assuming your dates will either be 6 (MMddyy) or 7 (yyyyddd) characters long. If there are other patterns you'll need to determine that.
The problem I found is what does your date for today (March 6, 2012) look like in MMddyy format?
Any month before October would never have a leading 0 if your date is stored as a number. So you should take that into account as well using my logic.
I added that into the logic by checking for a length of 5.
NumberVar Full := 030612;
StringVar myDate;
myDate := ToText (Full, 0, "", "");
Select Length (myDate)
Case 5: Date (2000 + ToNumber (myDate [4 to 5]), ToNumber (myDate [1]), ToNumber (myDate [2 to 3]))
Case 6: Date (2000 + ToNumber (myDate [5 to 6]), ToNumber (myDate [1 to 2]), ToNumber (myDate [3 to 4]))
Case 7: Date (ToNumber (myDate[1 to 4]), 1, 1) + (ToNumber (myDate [5 to 7]) - 1)
Default: Date (0, 0, 0);
If you edit the first line and change it to:
NumberVar Full := 2012066;
You will also get today's date. -
Problems about query filter (BEx).
Hello there,
I have some problems about query filter (BEx).
I have master data and I want to use attribute in this master data to dynamic filter in query(BEx).
But this attribute is key figure. I can't done it now. TT
Is this possible? If yes, could anyone advise how this is to be done?
Thanks in advance.Hi
In BEx there is option as 'Exceptions' & 'Conditions'. If you go in condition, you can specify range for key figure output. This is either predefined or by user selection. You create the condition as per your requirement & it will show you filtered data.
How to create conditions you will find easily on this site.
You can create as many conditions as no of filters you want. You can create these at query level also at report output level. -
TopLink doesn't sort data received using Named query
Hello!
I'm trying to build a Tree table using a TopLink Named query in my application.
There are Id, Parent|_Id, Code and Name columns in the corresponding database table, where Id and Parent|_Id are linked together by Foreign key (typical tree). I used TopLink to describe this table in the Model part of my application. There I wrote a Named query, without using a query constructor (not Expression radio button, but SQL radio button). Here the text of query:
select * from regions a connect by prior a.Id = a.Parent_Id start
with a.Id is null order by a.Code
Then I created a Data control and tried to build a JSF page with data based on this query, as tree-table.
But I discovered the fact, that data under the same node on the same leaf level of the Tree are not sorted by code on the JSF page. For example, data may be situated as follows (Code - Name):
2. wwwwwwwwwwww
2.3.kkkkkkkkkkkk
2.1.fffffffffffffffffffff
2.2.oooooooooo
1. qqqqqqqqqqqqqqqq
1. 2. lllllllllllllllllllllllllllll
1. 1. hhhhhhhhhhhhhh
etc.
I verified this query on other environment (PL/SQL Developer, SQL+), but didn't found such unsorted results anywhere.
Please, give me an advice to avoid this problem.
Thanks.Hi
Something to do with TreeMap(TreeSet). I tried with TreeSet but it didn't work. Here is the code :
In servlet :
Connection lConnection = getConnection(pRequest);
String lSQL = "";
Statement lStatement;
ResultSet lResultSet;
Hashtable lLtypeHashtable = new Hashtable();
lStatement = lConnection.createStatement();
lSQL = "SELECT RCID,RCMEANING FROM REFERENCECODES WHERE RCDOMAIN = 'LOCATIONTYPE' AND RCROWSTATE > 0 order by RCMEANING";
lResultSet = lStatement.executeQuery(lSQL);
while(lResultSet.next())
String lRcid = lResultSet.getString(1);
String lRcmeaning = lResultSet.getString(2);
lLtypeHashtable.put(lRcid.trim(),lRcmeaning.trim());
if(lResultSet != null) lResultSet.close();
if(lStatement != null) lStatement.close();
pRequest.setAttribute("LtypeHashtable",lLtypeHashtable);
//Below Query is executed when one data from select element is selected
String lLType = DisplayUtilities.getString(pRequest.getParameter("LType"),true);
//LType is name of select element in JSP.
if (lLType != null)
lSQL = lSQL + " AND " + lUpperCaseFunction + "(LOCATIONTYPE)" +
" = " + DBUtilities.formatString(lLType.toUpperCase());
pRequest.setAttribute("rLType",lLType+"");
In JSp :
<%
Hashtable lLtypeHashtable = (Hashtable)request.getAttribute("LtypeHashtable");
%>
<TR>
<TD width="15%"> <div align="left">
<select name="LType" size="1" >
<option Value="">< Select ></option>
<%
if(lLtypeHashtable != null)
Enumeration enum = lLtypeHashtable.keys();
while(enum.hasMoreElements())
String key = (String)enum.nextElement();
String value = (String)lLtypeHashtable.get(key);
String flagBack = "";
if(key.equals((String)request.getAttribute("rLType")))
flagBack = "selected";
%>
<option Value="<%=key%>" <%=flagBack%>><%=value%></option>
<%
%>
</select></div>
</TD>
</TR>
How should I implement TreeSet?
Looking forward for an early reply.
Thanks. -
Dynamic Aggregation Using BI Query Wizard
Hi,
Is it poosible to perform dynamic aggregation using Oralce Query Wizard. In other words , is it possible to change/filter the dimension members of a particular dimension and recalculate the aggregation with out changing the fact/dimension table contents.
Your help is appreciated.
PanneerHi,
Not sure exactly what you are tying to achieve. However, if your data is stored in Analytic Workspace objects then you can recalculate data via OLAP DML programs or models dynamically from within a BI Beans application. The AW environment is always attached in read-only mode as a default. Hence, you can change the data during a session and then dump the changes when the user exits the application.
From within a relational environment it is very difficult to create the same approach since it is possible a commit could be issued. Unless you mark the required tablespaces as read-only. In which case you could execute PL/SQL procedures to recalculate data. However, not sure how you would resolve the refresh of any related MVs
Hope this helps
Keith Laker
Product Manager
Oracle Business Intelligence Beans
Maybe you are looking for
-
Query Panel LOV Selecting first value
Hi all, I created a LOV to use for one of my VOs. I created it as an Input Text with List of Values. I updated the AF Table using this view to use the new list of values and it works correctly. However in the query panel for the table when you try an
-
R U PEOPLE REALLY SATISFIED WITH VIDEO QUALITY OF ...
the resolution could have been better in n8, it same as 5800. a video clip with dark region it appears grey with pixels in n8 where as if the same clip played in n8, it appears like hd...............................SO SICK N8
-
What is the major differences in the Ipad 2 and 3
What is the major differences between the ipad 2 and ipad3 ?
-
Hi All, I have added a row to the existing report pension account with GL Account 52540. saved the report and executed. but the row does not appear in the report when I run the report in GR55. I have checked all the settings. it appears okay to me. I
-
1) Second thread call to stateful session bean.
Hi Friend, I read your threads on otn and i compared your problem with us and i analysed that your application and my application is same, So Plese can you help me in some issues. Friend, Please help me in these issues, Thanks for this We have very b