Query for Relationships
Hi,
Are there system tables that store relationship info for tables in a database ?
1) Given a parent table, I need to find all of the child tables.
2) Given a child table, I need to find all of the parent tables.
Thanks,
Ned
Use dba_constraints and dba_cons_columns (or user_constraints and user_cons_columns/all_constraints and all_cons_columns. I use the following script to find FK information based on a given table_name. You can probably rewrite it to something that gives the output you want.
SELECT
rpad(fk.owner,5)||
rpad(fk.table_name,30)||
rpad(fk.constraint_name,30)||
rpad(fkc.column_name,30) owner_table_constraint_column,
--substr(fk.owner||' . '||fk.table_name||' . '||fkc.column_name,1,65) fk,
--substr(fk.table_name,1,30) fk_table,
--substr(fkc.column_name,1,30) fk_col,
'--->' arrow,
substr(pk.table_name,1,30)||'('||substr(pkc.column_name,1,30)||')' to_table_column
/*substr(pk.owner||' . '||pk.table_name||' . '||pkc.column_name,1,65) pk substr(pk.table_name,1,30) pk_table,
substr(pkc.column_name,1,30) pk_col*/
FROM
dba_constraints fk,
dba_constraints pk,
dba_cons_columns fkc,
dba_cons_columns pkc
WHERE
fk.r_constraint_name = pk.constraint_name
AND fk.constraint_type = 'R'
AND pk.constraint_type = 'P'
AND fk.r_owner = pk.owner
AND fk.constraint_name = fkc.constraint_name
AND pk.constraint_name = pkc.constraint_name
AND fk.owner = fkc.owner
AND pk.owner = pkc.owner
AND fk.table_name = '&table_name'
ORDER BY
fk.owner,
fk.table_name,
fk.constraint_name,
fkc.column_name
/Lennert
Similar Messages
-
I was told that it is possible to create a separate 'Date for Date Type' for each 'Date Type' in the selection criteria of an adhoc query for IT0041. Can somebody help me with this please?
Hi Sven
Thanks.
I created it with PCH , but very few fields are visible for IT1001
Hence if I want to find chief of Org unit A, then I cannot find it as 'Relationship type/relationship' field of IT1001 is missing here.
Basically I need all the fields which are displayed in IT1001 as shown below:
Need your help to find the way out. Thanks
KP -
Hierarchical + Analytical query for organizational unit parameters
Hello gurus,
I try for a couples of hour ago to make a query work as I would like.
Our application need to store some parameters for our organization units. These organization units are typically organized in in an hierarchy manner: one top unit with many level of child units. The parameters are stored into another table with 1:1 relationship.
For sake of visualisation, here is the data for the organization unit and parameter table in a more visual format:
SQL> select * from organization_unit;
UNIT_CODE UNIT_NAME PARENT_UNIT_CODE
00000 Top level
10 L2 unit #10 00000
10-01 L3 unit #10-01 10
10-02 L3 unit #10-02 10
20 L2 unit #20 00000
20-01 L3 unit #20-01 20
20-02 L3 unit #20-02 20
SQL> select * from org_unit_parameters;
UNIT_CODE PARAM1 PARAM2 PARAM3 PARAM4
00000 Default value Default value Default value {null}
10 {null} Value from 10 Value from 10 {null}
10-01 {null} {null} Value from 10-01 {null}
10-02 {null} {null} {null} Value from 10-02
20 Value from 20 Value from 20 Value from 20 {null}
20-01 {null} Value from 20-01 {null} {null}
20-02 {null} Value from 20-02 {null} {null}The application will query the parameter table to get a parameter value for a given unit.
The parameter resolution algorithm is rather simple: when querying a unit, the applicable parameter is the one defined at the requested level. If the parameter is not defined (null) at the requested level, the parameter value that must be returned is the next defined one in the parent hierarchy. In some rare cases, it can be null if a parameter is not defined anywhere from the requested level to top.
I've made a query that seems to work when querying for one unit at a time. It use hierarchical operators (start with + connect by) with a bit of analytical functions. Here is a test & raw output example:
SQL> WITH hierarchy
2 AS
3 (
4 SELECT ou.unit_code,
5 LEVEL AS lvl
6 FROM organization_unit ou
7 START WITH
8 ou.unit_code = '20-01'
9 CONNECT BY
10 ou.unit_code = PRIOR ou.parent_unit_code
11 )
12 SELECT h.*,
13 p.param1 AS param1_raw,
14 LAST_VALUE (p.param1 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param1_with_last,
15 FIRST_VALUE(p.param1 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param1_with_first,
16 p.param2 AS param2_raw,
17 LAST_VALUE (p.param2 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param2_with_last,
18 FIRST_VALUE(p.param2 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param2_with_first,
19 p.param3 AS param3_raw,
20 LAST_VALUE (p.param3 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param3_with_last,
21 FIRST_VALUE(p.param3 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param3_with_first,
22 p.param4 AS param4_raw,
23 LAST_VALUE (p.param4 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param4_with_last,
24 FIRST_VALUE(p.param4 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param4_with_first
25 FROM hierarchy h
26 LEFT JOIN org_unit_parameters p
27 ON h.unit_code = p.unit_code
28 ORDER BY h.lvl DESC;
UNIT_CODE LVL PARAM1_RAW PARAM1_WITH_LAST PARAM1_WITH_FIRST PARAM2_RAW PARAM2_WITH_LAST PARAM2_WITH_FIRST PARAM3_RAW PARAM3_WITH_LAST PARAM3_WITH_FIRST PARAM4_RAW PARAM4_WITH_LAST PARAM4_WITH_FIRST
00000 3 Default value Default value Value from 20 Default value Default value Value from 20-01 Default value Default value Value from 20 {null} {null} {null}
20 2 Value from 20 Value from 20 Value from 20 Value from 20 Value from 20 Value from 20-01 Value from 20 Value from 20 Value from 20 {null} {null} {null}
20-01 1 {null} Value from 20 {null} Value from 20-01 Value from 20-01 Value from 20-01 {null} Value from 20 {null} {null} {null} {null}Seems pretty good, the upper parameters are well «propagated» down with LAST_VALUE function. But, I don't understand why the use of FIRST_VALUE and oppposite ordering doesn't give the same result. A little more playing with the last query for getting the final result for a given unit code:
SQL> SELECT *
2 FROM
3 (
4 WITH hierarchy
5 AS
6 (
7 SELECT ou.unit_code,
8 LEVEL AS lvl
9 FROM organization_unit ou
10 START WITH
11 ou.unit_code = '20-01'
12 CONNECT BY
13 ou.unit_code = PRIOR ou.parent_unit_code
14 )
15 SELECT h.*,
16 LAST_VALUE (p.param1 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param1,
17 LAST_VALUE (p.param2 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param2,
18 LAST_VALUE (p.param3 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param3,
19 LAST_VALUE (p.param4 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param4
20 FROM hierarchy h
21 LEFT JOIN org_unit_parameters p
22 ON h.unit_code = p.unit_code
23 ORDER BY h.lvl
24 )
25 WHERE ROWNUM = 1;
UNIT_CODE LVL PARAM1 PARAM2 PARAM3 PARAM4
20-01 1 Value from 20 Value from 20-01 Value from 20 {null}Works well!
But, my ultimate goal is to create a view that resolve correctly all these parameters for each level of the organization with proper propagation rather then querying for each unit at a time. I played a bit, but without success. :( My current raw query is this one:
SQL> WITH hierarchy
2 AS
3 (
4 SELECT ou.unit_code,
5 LPAD(' ',2*(LEVEL-1)) || ou.unit_code AS tree,
6 LEVEL AS lvl
7 FROM organization_unit ou
8 START WITH
9 parent_unit_code IS NULL
10 CONNECT BY
11 PRIOR unit_code = parent_unit_code
12 )
13 SELECT h.*,
14 p.param1 AS param1_raw,
15 LAST_VALUE (p.param1 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param1_with_last,
16 FIRST_VALUE(p.param1 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param1_with_first,
17 p.param2 AS param2_raw,
18 LAST_VALUE (p.param2 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param2_with_last,
19 FIRST_VALUE(p.param2 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param2_with_first,
20 p.param3 AS param3_raw,
21 LAST_VALUE (p.param3 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param3_with_last,
22 FIRST_VALUE(p.param3 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param3_with_first,
23 p.param4 AS param4_raw,
24 LAST_VALUE (p.param4 IGNORE NULLS) OVER (ORDER BY h.lvl DESC) AS param4_with_last,
25 FIRST_VALUE(p.param4 IGNORE NULLS) OVER (ORDER BY h.lvl ASC) AS param4_with_first
26 FROM hierarchy h
27 LEFT JOIN org_unit_parameters p
28 ON h.unit_code = p.unit_code
29 ORDER BY h.unit_code;
UNIT_CODE TREE LVL PARAM1_RAW PARAM1_WITH_LAST PARAM1_WITH_FIRST PARAM2_RAW PARAM2_WITH_LAST PARAM2_WITH_FIRST PARAM3_RAW PARAM3_WITH_LAST PARAM3_WITH_FIRST PARAM4_RAW PARAM4_WITH_LAST PARAM4_WITH_FIRST
00000 00000 1 Default value Default value Default value Default value Default value Default value Default value Default value Default value {null} Value from 10-02 {null}
10 10 2 {null} Value from 20 Default value Value from 10 Value from 10 Default value Value from 10 Value from 10 Default value {null} Value from 10-02 {null}
10-01 10-01 3 {null} {null} Default value {null} Value from 20-02 Default value Value from 10-01 Value from 10-01 Default value {null} Value from 10-02 Value from 10-02
10-02 10-02 3 {null} {null} Default value {null} Value from 20-02 Default value {null} Value from 10-01 Default value Value from 10-02 Value from 10-02 Value from 10-02
20 20 2 Value from 20 Value from 20 Default value Value from 20 Value from 10 Default value Value from 20 Value from 10 Default value {null} Value from 10-02 {null}
20-01 20-01 3 {null} {null} Default value Value from 20-01 Value from 20-02 Default value {null} Value from 10-01 Default value {null} Value from 10-02 Value from 10-02
20-02 20-02 3 {null} {null} Default value Value from 20-02 Value from 20-02 Default value {null} Value from 10-01 Default value {null} Value from 10-02 Value from 10-02As you can see, it's not as I expected. I know there's something to do with a PARTITION BY clause, but don't know how.
Is anyone knows how to solve my problem?
Thanks
Bruno
For reproductibility purposes, here is the code to create sturcture and data:
Here is the format of my tables and some samble data:
CREATE TABLE organization_unit (
unit_code VARCHAR2(5 CHAR) NOT NULL PRIMARY KEY,
unit_name VARCHAR2(100 CHAR) NOT NULL,
parent_unit_code VARCHAR2(5 CHAR)
CREATE TABLE org_unit_parameters (
unit_code VARCHAR2(5 CHAR) NOT NULL PRIMARY KEY,
param1 VARCHAR2(100 CHAR),
param2 VARCHAR2(100 CHAR),
param3 VARCHAR2(100 CHAR),
param4 VARCHAR2(100 CHAR)
-- Inserting data
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('00000', 'Top level', NULL);
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('10', 'L2 unit #10', '00000');
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('10-01', 'L3 unit #10-01', '10');
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('10-02', 'L3 unit #10-02', '10');
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('20', 'L2 unit #20', '00000');
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('20-01', 'L3 unit #20-01', '20');
INSERT INTO organization_unit (unit_code, unit_name, parent_unit_code)
VALUES ('20-02', 'L3 unit #20-02', '20');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param1, param2, param3)
VALUES ('00000', 'Default value', 'Default value', 'Default value');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param2, param3)
VALUES ('10', 'Value from 10', 'Value from 10');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param3)
VALUES ('10-01', 'Value from 10-01');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param4)
VALUES ('10-02', 'Value from 10-02');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param1, param2, param3)
VALUES ('20', 'Value from 20', 'Value from 20', 'Value from 20');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param2)
VALUES ('20-01', 'Value from 20-01');
INSERT INTO ORG_UNIT_PARAMETERS (unit_code, param2)
VALUES ('20-02', 'Value from 20-02');
COMMIT;Now, I hoppe I got your reqs:
WITH hierarchy AS (
SELECT ou.unit_code,
LPAD(' ',2*(LEVEL-1)) || ou.unit_code AS tree,
LEVEL AS lvl,
param1 AS param1_raw,
param2 AS param2_raw,
param3 AS param3_raw,
param4 AS param4_raw,
SYS_CONNECT_BY_PATH(p.param1,'#') || '#' AS param1_path,
SYS_CONNECT_BY_PATH(p.param2,'#') || '#' AS param2_path,
SYS_CONNECT_BY_PATH(p.param3,'#') || '#' AS param3_path,
SYS_CONNECT_BY_PATH(p.param4,'#') || '#' AS param4_path
FROM organization_unit ou LEFT JOIN org_unit_parameters p
ON ou.unit_code = p.unit_code
START WITH parent_unit_code IS NULL
CONNECT BY PRIOR ou.unit_code = parent_unit_code
SELECT unit_code,
tree,
lvl,
param1_raw,
REGEXP_SUBSTR(param1_path,'[^#]+',1,GREATEST(1,REGEXP_COUNT(param1_path,'[^#]+'))) AS param1_with_last,
REGEXP_SUBSTR(param1_path,'[^#]+') AS param1_with_first,
param2_raw,
REGEXP_SUBSTR(param2_path,'[^#]+',1,GREATEST(1,REGEXP_COUNT(param2_path,'[^#]+'))) AS param2_with_last,
REGEXP_SUBSTR(param2_path,'[^#]+') AS param2_with_first,
param3_raw,
REGEXP_SUBSTR(param3_path,'[^#]+',1,GREATEST(1,REGEXP_COUNT(param3_path,'[^#]+'))) AS param3_with_last,
REGEXP_SUBSTR(param3_path,'[^#]+') AS param3_with_first,
param4_raw,
REGEXP_SUBSTR(param4_path,'[^#]+',1,GREATEST(1,REGEXP_COUNT(param4_path,'[^#]+'))) AS param4_with_last,
REGEXP_SUBSTR(param4_path,'[^#]+') AS param4_with_first
FROM hierarchy
ORDER BY unit_code
UNIT_ TREE LVL PARAM1_RAW PARAM1_WITH_LAST PARAM1_WITH_FIRS PARAM2_RAW PARAM2_WITH_LAST PARAM2_WITH_FIRS PARAM3_RAW PARAM3_WITH_LAST PARAM3_WITH_FIRS PARAM4_RAW PARAM4_WITH_LAST PARAM4_WITH_FIRS
00000 00000 1 Default value Default value Default value Default value Default value Default value Default value Default value Default value
10 10 2 Default value Default value Value from 10 Value from 10 Default value Value from 10 Value from 10 Default value
10-01 10-01 3 Default value Default value Value from 10 Default value Value from 10-01 Value from 10-01 Default value
10-02 10-02 3 Default value Default value Value from 10 Default value Value from 10 Default value Value from 10-02 Value from 10-02 Value from 10-02
20 20 2 Value from 20 Value from 20 Default value Value from 20 Value from 20 Default value Value from 20 Value from 20 Default value
20-01 20-01 3 Value from 20 Default value Value from 20-01 Value from 20-01 Default value Value from 20 Default value
20-02 20-02 3 Value from 20 Default value Value from 20-02 Value from 20-02 Default value Value from 20 Default value
7 rows selected.
SQL> SY.
Edited by: Solomon Yakobson on Nov 12, 2010 10:09 AM -
Data modeler: Having Maintainable Query for View Creation
Hi,
I am using SQL Developer 4 and the data modeler. I typically create a view in SQL developer (from a SQL select statement). I then drag and drop the view to the data modeler in order to have it stored for the next time I regererate the database schema from the data modeler. This works and I can see the query for my view when I click Properties on the view in the data modeler. However, the query I see there is logically equivalent (and very similar) but it is hard to read for a programmer as carrier returns are added, the various elements of my where clause are not in the same order as I programmed them, comments (starting with '--') where not transfered with the drag and drop.
I feel I cannot only rely on the version of the view stored in the data modeler to keep my DDL code that creates the view. Maintenance of that code would be too difficult. I feel I will need to keep a separate SQL script (in a separate version control tool) containing the select statement of my view. I would then always need to make my modifications in this select statement, update my view in the database and then drag and drop the result back in the data modeler. This is cumbersome.
Do you have any solution for me? Thanks!Hi Jeff would you be able to help me in creating a data model cause im really stuck with this one .Basically if been asked to create a survey application in oracle apex that use to excel based . So the info i was given was in a form of excel sheet which looks like this
USER'S VENDORS TOPICS
NAME
E-MAIL
TSSA
ORACLE
HP
IBM
MS
SAP
INTERGRAPH
CISCO
Relationship
Contracting
Performance
Architecture
Supplier Feedback
Comment
jjjjjnn Bixxxxxff
[email protected]
Yes
Yes
Yes
Yes
x
Added as requested by Sanet Mulder
itha CCCniah
[email protected]
Yes
Yes
Yes
x
x
Elliot dan
[email protected]
Yes
x
x
x
Ger que
[email protected]
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
x
x
x
isha Per
[email protected]
Yes
x
John Rato
[email protected]
Yes
x
x
So where it says yes thous are the vendors that people associated with them have to asses and where there's an X thous are the topics that the vendors have to be rated on . So if for example the first guy on the list jjjjjnn Bixxxxxff will asses TSSA , ORACLE , HP , IBM , MS , SAP on the topic of Architecture and if you look at the second user itha CCCniah he would rate TSSA , ORACLE , INTERGRAPH on the topics of Relationship and performance . Any idea how i could data model this to get my table structures right .so that features like completion status could be displayed to the user through APEX which can only be done by a correct data-model i have tried normalization but i did go anywhere becauce there are so many variations any idea on how you would go about data modeling this would be greatly appreciated thank you If you would like a better copy of the table my email is [email protected] -
How to use the same POWL query for multiple users
Hello,
I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
"Query 'ABC' is already open in another session."
where 'ABC' is the query name.
Can you please tell me how to use the same POWL query for multiple users ?
A fast reply would be highly appreciated.
Thanks and Regards,
SandhyaBatch processing usually involves using actions you have recorded. In Action you can insert Path that can be used during processing documents. Path have some size so you may want to only process document that have the same size. Look in the Actions Palette fly-out menu for insert path. It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..
-
Error while creating a query for my custom infotype
Hi,
I have created a custom infotype with fields currency amount and currency field .
While I am creating a query for it its giving an error
Message no. AQ_AD_HOC221 Error when generating the report(see long text )
I tried to execute the standard program RPUMS40CCI but still I am facing same error .
I have also maintained table T777i for my infotype but still problem exists.
Please help.
PHi
Check in PM01 -
Error while executing a sql query for select
HI All,
ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
1. I dont want to increase the temp space
2. I need to tune the query, please provide your recomendations.
insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
(REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
select
REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
carrier_item_type,carried_item_protection_type,'PACS'
from
(select distinct
c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
a.carrier_item_type,a.carried_item_protection_type,'PACS'
from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
AND a.carrier_items=b.mux
and c.REPORTNUMBER=(case
when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
else 20
end)
and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
where not exists
(select *
from CST_DSA.HIERARCHY_MISMATCHES B where
A.REPORTNUMBER=B.REPORT_NUM and
A.REPORTTYPE=B.REPORT_TYPE and
A.REPORTDESCRIPTION=B.REPORT_DESC and
A.CARRIED_ITEMS=B.CARRIED_ITEMS and
A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
A.CARRIER_ITEMS=B.CARRIER_ITEMS and
A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
AND B.SOURCE_SYSTEM='PACS'
Explain Plan
==========
Plan
INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1
20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES
19 PX COORDINATOR
18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1
15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1
4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621
3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621
14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448
11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448
8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002
7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2
6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2
5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448
13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1
12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1
16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1 -
Return Code - Query for Multiple Rows as XML
Hi,
I'm executing an MSSQL stored procedure through the "Query for Multiple Rows as XML" activity in LiveCycle ES. I do this through a call statement such as this:
{ call MyStoredProc(?) }
This works great, the stored procedure always returns a record set (with or without records). I use this activity rather than "Call Stored Procedure" because I can transform the record set into XML right away within this activity. Unfortunately any exception arising from invoking this stored procedure cannot be handled within the workflow as this activity does not have an exception handler (lightning bolt). In an attempt to handle at least some exceptions we have decided to use try/catches within the stored procedures and return different error codes. Now the problem I am faced with is that there is no way to retrieve the returned code within any of the SQL activities. We don't want to have to write an execute script for each of these SQL calls. Is there any way to do this? Seems like I'm 95% there.
Thanks
NicThanks for the offer, unfortunately we would need something certified by Adobe.
Nic -
Query for Sales Order Analysis
Dear Experts
I have written a Query for Sales Order Analysis and would like to have help on this.
The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum] ORDER BY T0.[DocNum]
where U_Total_GP is a UDF for storing the GP of each order.
After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. However, the query does not calculate column total for total amount and total GP. Although I know the total for each column can be displayed by pressing "Ctrl" + Click on the column title, it would have to be done from time to time.
Therefore, I would like to modify my query in order to calculate the column totals when executed. Are there any suggestions for this?
Thank you
Regards
EltonHi Elton,
Try this:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0]
ORDER BY T0.[DocNum]
Thanks,
Gordon -
Hello Experts,
I'm tryng to develop my first application for EP (v7 SP12) with NWDS (without NWDI).
This application has to read and write data in the EP DB (oracle v10).
I'm using:
<u>a Dictionary Project</u> (define the DB Tables)
<u>a Java Project</u> (define class as DAO, DBManager etc)
<u>a Library Project</u>
<u>an EJB Project</u>
<u>an EAR Project</u>
With these projects I can deploy a <u>webService</u> in my EP server.
BUT I have some problem with a query that I'm tryng to sent to my DB through a DAO Class called by my WebService.
The query is simple and correct but it does not work...
This is the error message returned (the query id in bold)
(column names: GIORNO, NOMEDITTA, NOMEAREA, NOMESETTORE)
<i>HTTP/1.1 500 Internal Server Error
Connection: close
Server: SAP J2EE Engine/7.00
Content-Type: text/xml; charset=UTF-8
Date: Fri, 21 Sep 2007 14:29:57 GMT
Set-Cookie: <value is hidden>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>java.sql.SQLException: com.sap.sql.log.OpenSQLException: The SQL statement <b>"SELECT NOMESETTORE, MIN(? - "GIORNO") AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE"</b> <u>contains the syntax error[s]: - 1:25 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</u></faultstring><detail><ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException xmlns:ns1='urn:GiorniSenzaInfortuniWSWsd/GiorniSenzaInfortuniWSVi'></ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope></i>
The variable '?' is the today date, the difference <b>"(?-GIORNO)"</b> is an int..
Moreover in my DAO class the query is <b>"SELECT NOMESETTORE, MIN(? - GIORNO) AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE</b>", instead in the error message is reported <b>MIN(? - "GIORNO")</b>...
We have tryed also with alternative query, for example we used <b>"MIN(SYSDATA - GIORNO)"</b> but <b>SYSDATA</b> was interpreted as column name and not found....
Any help???
Best RegardsHi, I found something about the Host Variable (http://help.sap.com/saphelp_nw70/helpdata/en/ed/dbf8b7823b084f80a6eb7ad43bdbb9/content.htm), there explain that if you want to use an host variable you have to put ':' as prefix..
My problem is that <u>I need to extract the minimum of the subtraction between two dates:</u>
Query <b>MIN(? - GIORNO)</b> --> <i>Error: the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
So I tried to use the ':' as indicated in the manual..
<b>MIN:(? - GIORNO)</b> --> - <i>SQL syntax error: the token ":" was not expected here
- expecting LPAREN, found ':'</i>
<b>MIN(:(? - GIORNO))</b> --> <i>- 1:25 - Open SQL syntax error: :PARAMETER not allowed
- 1:26 - SQL syntax error: the token "(" was not expected here
- 1:26 - expecting ID, found '('</i>
Then I tried to avoid the MIN() function and I tried to do just the subtraction:
<b>? - GIORNO</b> --><i> - 1:21 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
<b>:(? - GIORNO)</b> --> <i>- 1:21 - Open SQL syntax error: :PARAMETER not allowed
- 1:22 - SQL syntax error: the token "(" was not expected here
- 1:22 - expecting ID, found '('</i>
<b>'2007-09-24' - GIORNO</b> --> <i>- 1:34 - SQL syntax error: first argument of operator "-" must be a number, date/time or interval
- 1:43 - SQL syntax error: arguments of operator "-" do not have correct types
- 1:43 - SQL syntax error: derived columns in SELECT list with AS must be values</i>
<b>GIORNO - GIORNO</b> --> <i>- 1:21 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated
- 1:30 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated</i>
Why these parts of query are not accepted???
I don't understand why... I hope you can help me.
Best Regards
Alessandro -
TDS Amount on Vendor Advance Shows positive value in *QUERY* for TDS Report
Hi Everybody,
I have made a query for List of TDS Report with Vendor informations as required by my client. In which the value of TDS on Vendor Advance Payment appears as positive value instaead of negative value. Please suggest how to rectify.
Thanks,
PaulDear,
If you have cleared the advance in F-54, then this will reverse the tax amount. That could be the reason for tax amount in debit. -
Query for daily sales by warehouse
Hi
I need a query for Daily sales by warehouse. I am only new to this and struggling with generating.
ideally it will look like the below. With no selection criteria as I would like to schedule the report to email out at the end of each day.
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
Would someone mind helping
thanksthankyou , But i have multiple warehouse and i dont want to use a selection criteria.
to expand on the original example
Warehouse Revenue GP GP%
NSW $xxxx $xxx 35%
QLD $xxx $xx 32%
VIC $xxx $xx 32%
Also the results should only show figures for the day the query is executed
Any help is appreciated.
Similar layout to this,except using query and whs code. the below is generated using sales analysis and customer group. -
QUERY FOR CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE
Hi Friends,
I need query for CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE for selection criteria from date and to date.
I know the Trial Balance Report will sort out this issue... but i need routeday wise report
1. Business Partner Master Data - i created one UDF field called U_Routeday (MONDAY, TUESDAY, WEDNESDAY,THURSDAY,FRIDAY)
2. The query should be like selection criteria
- Routeday [%0]
- Posting Date [%1]
- Posting Date [%2]
CardCode
Debit
Credit
Balance
D10503
25031.50
24711.50
2962.00
D10641
5466.00
7460.00
285.00
D10642
2866.00
142.00
give any helpful query ASAP... Thanks in advanceHi,
Try this query:
Declare
@fromdate as datetime
Declare
@Todate as datetime
Declare
@Code as nvarchar(25)
set
@fromdate = ( select min(Ta.[RefDate]) from OJDT ta where
Ta.[RefDate] >= [%0])
set
@Todate = ( select max(Tb.[RefDate]) from OJDT tb where Tb.[RefDate]
<= [%1])
set
@code = (select max(Tc.[ShortName]) from JDT1 tC where Tc.[ShortName]
= [%2])
SELECT
[Name] as AcctName, [Jan]= sum([1]), [Feb]= sum([2]), [Mar]=
sum([3]), [Apr]= sum([4]), [May]= sum([5]), [June]= sum([6]),
[July]= sum([7]), [Aug]= sum([8]), [Sept]= sum([9]), [Oct]=
sum([10]), [Nov]= sum([11]), [Dec]= sum([12]), total = sum
(isnull([1],0)+ isnull([2],0) + isnull([3],0) + isnull([4],0) +
isnull([5],0) + isnull([6],0) + isnull([7],0) + isnull([8],0) +
isnull([9],0)+ isnull([10],0) + isnull([11],0) + isnull([12],0))
from
(SELECT
T0.[ShortName] as Name, sum(T0.[Debit]-T0.[Credit]) as T,
month(T2.[RefDate]) as month FROM JDT1 T0 INNER JOIN OACT T1 ON
T0.Account = T1.AcctCode INNER JOIN OJDT T2 ON T0.TransId =
T2.TransId WHERE T2.[RefDate] between @fromdate and @todate and
T0.[ShortName] = @code GROUP BY T0.[ShortName],T2.[RefDate] ) S
Pivot
(sum(T)
For Month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
group
by [Name],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]
Let me know your result.
Thanks & Regards,
Nagarajan -
Re:Query for Stock Statement for a particular item..!!!!
Dear SAP Experts,
I need a stock statement query for a particular item which contains:
1.ItemCode
2.Item Description
3.Item Price
4.Opening
5.Receipts
6.Issues
7.Closing
8. Value
The selection criteria are:
1.Warehouse code
2.Item Name
3.Posting Date
Plz give me a good solution for this issue.
With Regards,
RevathyCheck this
Declare @FromDate Datetime
Declare @ToDate Datetime
set @FromDate =
(Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
set @ToDate =
(Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
select * from
SELECT T0.itemcode,
min(T0.Dscription) as 'Item Description',
min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
(isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate ),0)-
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate),0)
) as [Opening Stock],
isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate
and O1.docdate<=@ToDate and O1.inqty>0
and O1.transtype in (20,18)),0
) as [Purchase Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate
and O1.outqty>0 and O1.transtype in (21,19)),0
) as [Purchase Return Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
and O1.transtype in (13,15)),0
) as [sale Quatity],
(isnull
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0)
) as [Closing Stock]
FROM OINM T0
INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod
INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
INNER JOIN OLCT C1 ON W1.Location=C1.Code
Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
) a
where (a.[Opening Stock]
+a.[Purchase Quantity]
+ a.[Purchase Return Quantity]
+a.[sale Quatity]+a.[Closing Stock]
) !=0
Regards,
Bala -
Hello Gurus-
I am trying to build a query for Aging report, and would like to include something like this:
Customer-Reference-Payment terms-Due date-Current-31-60days-61-90days-91-120days-over120days-toatal amount.
I have an infoset which includes BSID, KNA1, KNB1. I have maintained local fields:
Due Date = Baseline date + cash discount days
Statement Date = My input date.
Current = Condition (DUEDTE >= STATDTE - 30) formula (Amount)
31 - 60 Days = Condition (DUEDTE >= STATDTE - 60 AND DUEDTE < STATDTE - 30) formula (Amount)
61 - 90 Days = similar to above
91 - 120 Days = similar to above
Amount = - 1 * (If Debit credit indicator = "H" then "Amount in local currency") otherwise "Amt in Loc.Cur"
Over 120 Days = similar to above
When I enter a statement date of today it works hunky dory...it all looks good...my current column looks good and do the rest. When i want to run this query as of couple of months ago (if today is 12/19/08 and i wanted to run my aging report for 10/31/08) it should give me aging as of my statement date 10/31/08 but it does not. It calculates the total amount as of today. I know because of local field "Amount" where i gave amount in local currency, but how would I tell that it should pick up amount in local currency till the statement date?
Any input in this regards is highly helpful.
Thanks,
RNarayanHi Ram,
On your aging report you want to see invoices which are still not paid (or still open) as of a certain date. This date is "key date". You need to define a variable for key date (which is normally system date if you run today) but it could be a past date.
So key date is let us say Oct 31st (X) and the system date is Dec 19th. When you run the report as of Oct 31st all invoices that are posted prior to Oct 31st (posting date less than X) and are still in BSID will show on your report. There is no issue here.
Let us say an invoice was created on Oct 25th (Y) and was paid on Nov 15th (Z). The clearing date is Z. That means if you run the aging report today this invoice will not show.
But you want to run the report on Oct 31st. This means X is greater than Y but is less than Z.
Clearing date and posting date are part of BSAD. Report run date is the user input and is a variable.
With the above concept and with the help of an ABAP programmer you should be able to solve the problem.
Regards
Sharabh
Maybe you are looking for
-
BW7.3 SOURCE_PACKAGE and DATA_PACKAGE are incompatible in the Start Routine
Hi Gurus, a face a strange behavior with BW7.3 and the Inventory Cube 0IC_C03: the standard scenario works well when I activate the cube and its transformations ..bx, bf and um. Then I have modified the InfoCube 0IC_C03 and added some field like 0cus
-
Installation ABAP+Java(add-in) jlaunch.exe missing
Hi,all After finish installation ABAP and web AS java(add-in) My java engine only has processes msg_server.exe enserver.exe and process Dispatcher and server process (two jlaunch.exe) n Software Deployment Manager (SDM, jlaunch.exe) is not there. I
-
Problem with the new version of iTunes
Since I downloaded the last version of iTunes, I very offen experience af scratching and fuzz sound, when I play music. Somebody heeelp me please!
-
Transformer object- fix note problem
Hi, my first post! I'm using a transformer-object in the environment to transpose some incoming midi-notes in real time. This works so far, but somehow, all the notes that are played, 'hang' for some reason, like no 'note-off' command is been given.
-
Need some help clearing up the footage
ok, after 5 days straight of staying up all night and day to figure this program out (i dont have much prior experience with such a complicated program) i finally made my first dvd complete with a menu and all... only 1 problem, why is my video so ch