Formatting of query returning multiple xml elements using xmlattributes
Hi, i've been tasked with producing output, based on an XSD, with repeating elements defined using distinct attributes related to the element. I've managed to get this working, but would like to make the solutions code more elegant than it is at the moment, and was wondering if anyone may be able to give me a hand with this?
Firstly, database details
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS for IBM/AIX RISC System/6000: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionAn example of the output i'm expecting is as follows
<financials>
<depositDate INVITE_PACK="Current">2011-12-01</depositDate>
<depositDate INVITE_PACK="Alternate">2011-12-01</depositDate>
<deposit INVITE_PACK="Current">19.88</deposit>
<deposit INVITE_PACK="Alternate">20.65</deposit>
<basicPremium INVITE_PACK="Current">198.76</basicPremium>
<basicPremium INVITE_PACK="Alternate">206.49</basicPremium>
</financials>This data is held in a relational database table and i'm currently gernerating the data from this relational table using something similar to the following:
SELECT xmlagg
(xmlelement("financials",
(select xmlagg(xmlelement("depositDate",
xmlattributes(fi1.quote),
fi1.DEPOSIT_DATE
)) as "depDt_det"
FROM (select distinct f1.fulfilment_queue_key,
f1.fq_policy,
f1.quote,
f1.deposit_date
from staging.fulfilment_xml_finance_inv1 f1) fi1
WHERE fi1.fulfilment_queue_key = fi.fulfilment_queue_key),
(select xmlagg(xmlelement("deposit",
xmlattributes(fi1.quote),
fi1.PPD_DEPOSIT)) as "dep_det"
FROM (select distinct f1.fulfilment_queue_key,
f1.fq_policy,
f1.quote,
f1.PPD_DEPOSIT
from staging.fulfilment_xml_finance_inv1 f1) fi1
WHERE fi1.fulfilment_queue_key = fi.fulfilment_queue_key),
(select xmlagg(xmlelement("basicPremium",
xmlattributes(fi1.quote),
fi1.BASIC_PREM)) as "bprem_det"
FROM (select distinct f1.fulfilment_queue_key,
f1.fq_policy,
f1.quote,
f1.basic_prem
from staging.fulfilment_xml_finance_inv1 f1) fi1
WHERE fi1.fulfilment_queue_key = fi.fulfilment_queue_key)
FROM staging.fulfilment_xml_finance_inv1 fi
WHERE fi.fulfilment_queue_key = 2861
AND rownum = 1As can be seen, i'm replicating a number of calls to the fulfilment_xml_finance_inv1 table. I was wondering if there is a way to do the above in a more succinct, supportable and readable fashion? I have a tried a number of differnt methods to do this, but can't seem to get it to work for me. Any ideas would be greatly appreciated.
Thanks.
Hi again,
No problem, create table statement
-- Create table
create table FULFILMENT_XML_FINANCE_INV1
fulfilment_queue_key NUMBER(22),
fq_policy VARCHAR2(50),
riskversion NUMBER(28,7),
basic_prem NUMBER(10,2),
os_balance NUMBER(10,2),
ppd_deposit NUMBER(10,2),
ppd_plan_charge NUMBER(10,2),
ppd_charge_for_interest NUMBER(10,2),
ppd_apr_perc NUMBER(10,2),
ppd_interest NUMBER(22,6),
inst_freq VARCHAR2(1),
deposit_date DATE,
adj_premium NUMBER(19,2),
order1 NUMBER(38),
amountdue NUMBER(28,7),
collection_date DATE,
paymentduedate DATE,
scharges NUMBER(19,2),
ppd_plan_collection_reference VARCHAR2(20),
reapply_date DATE,
reapply_amount NUMBER(19,2),
last_inst_freq VARCHAR2(1),
quote VARCHAR2(10)
);example inserts
insert into fulfilment_xml_finance_inv1
(fulfilment_queue_key,
fq_policy,
riskversion,
basic_prem,
os_balance,
ppd_deposit,
ppd_plan_charge,
ppd_charge_for_interest,
ppd_apr_perc,
ppd_interest,
inst_freq,
deposit_date,
adj_premium,
order1,
amountdue,
collection_date,
paymentduedate,
scharges,
ppd_plan_collection_reference,
reapply_date,
reapply_amount,
last_inst_freq,
quote)
values
(2861,
'TEST1234',
3,
198.76,
123.45,
19.88,
0,
99.99,
99.99,
55.55,
'A',
to_date('01/12/2011','dd/mm/yyyy'),
null,
NULL,
NULL,
NULL,
null,
0.00,
'N/A',
NULL,
NULL,
'A',
'Current')
insert into fulfilment_xml_finance_inv1
(fulfilment_queue_key,
fq_policy,
riskversion,
basic_prem,
os_balance,
ppd_deposit,
ppd_plan_charge,
ppd_charge_for_interest,
ppd_apr_perc,
ppd_interest,
inst_freq,
deposit_date,
adj_premium,
order1,
amountdue,
collection_date,
paymentduedate,
scharges,
ppd_plan_collection_reference,
reapply_date,
reapply_amount,
last_inst_freq,
quote)
values
(2861,
'TEST1234',
3,
206.49,
123.45,
20.65,
0,
99.99,
99.99,
55.55,
'A',
to_date('01/12/2011','dd/mm/yyyy'),
null,
NULL,
NULL,
NULL,
null,
0.00,
'N/A',
NULL,
NULL,
'A',
'Alternate') Hope this is what you were after, please let me know if you need anything else.
Thanks again.
Similar Messages
-
Single query return multiple value
Hi ALL,
I have a sql query as below :
select order_number,
(select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id) Email
FROM oe_order_headers_all h
WHERE h.order_number='102'
Actually the problem i am facing is the inner select query is returning multiple row , so my main query is erroring out, i need to capture the multiple row.
in the above example the inner decode statement returning two mail address, i need to capture that, but while executing the whole query it is erroring out as saying single query returns multiple values.
please help me on this to capture multiple values
Thanks>
select order_number,
(select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id
/* a join is missing here that points to table oe_order_headers_all h*/) Email
FROM oe_order_headers_all h
WHERE h.order_number='102'
>
I can see a join missing in your select sub query.
However, if you you are still getting the single query return multiple value error then you need to replace the sql sub query
select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id)by decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
and join the two tables in you main query..
Regards
Biju
ED: Provide test script and your expected output to get what you want exacly!
Edited by: biju2012 on Sep 7, 2012 12:06 AM -
Hi
I am following below link to hide/show my columns dynamically. See "Column Formatting"
http://docs.oracle.com/cd/E12844_01/doc/bip.1013/e12187.pdf
As per doc, element can be made private/public.
<items type="PUBLIC">
<item>
<name>Plasma TV</name>
<quantity>10</quantity>
<price>4000</price>
</item>
<item>
And same can be used to hide the column using condition
<?if@column:/items/@type="PUBLIC"?>
MY QUESTION IS HOW TO DO THIS IN MY XML BELOW?
Below is part of my XML code which I am using in Data Definition for RTF.
<group name="GH3" source="QH3">
<element name="COLUMN_HEAD3" value="COLUMN_NAME" />
</group>
<group name="GH4" source="QH4">
<element name="COLUMN_HEAD4" value="COLUMN_NAME" />
</group>
I am getting output like this.
<LIST_GH3>
<GH3>
<COLUMN_HEAD3>REBILL_TO_OTHER_BUSINESS_UNIT</COLUMN_HEAD3>
</GH3>
</LIST_GH3>
<LIST_GH4>
<GH4>
<COLUMN_HEAD4>XYZ</COLUMN_HEAD4>
</GH4>
</LIST_GH4>
In order to use logic as per oracle document I want output like this.
<LIST_GH3 type="PUBLIC">
<GH3>
<COLUMN_HEAD3>REBILL_TO_OTHER_BUSINESS_UNIT</COLUMN_HEAD3>
</GH3>
</LIST_GH3>
<LIST_GH4 type="PRIVATE">
<GH4>
<COLUMN_HEAD4>BLANK</COLUMN_HEAD4>
</GH4>
</LIST_GH4>
What changes I need to make in my XML code to get the runtime output as above? Please help. Where do i need to make changes in the above xml? Group name? Element name?
I am planning to use below condition in RTF template to hide the column, but dont know how to set the type of column as PRIVATE/PUBLIC in the XML output used to populate data in the RTF at runtime.
<?if@column:/BTSPIEXP/LIST_GH3/@type=”PUBLIC”?>COLUMN_HEAD3<?end if?>
Regards,
Swapnil K.Hi,
Issue has been resolved. I used the value of the element to determine to display it or not.
Regards,
Swapnil K. -
Loading/breaking large files containing multiple XML documents using plsql
Hi I have a requirement where in the client sends the multiple xml payloads/documents in a single text file. I need to load that into the xmltype varialbe. How to do this?
I'm able to load the entire document into a clob object, here.. all the xml payloads are loaded into a single row. When I try to access this I get a error
ORA-31001: Invalid resource handle or path name "/MobileInventoryResponse.dtd"
ORA-06512: at "SYS.XMLTYPE", line 254
ORA-06512: at line 1
This error is due to the dtd present in the xml document : <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
But if I load the data into a clob after removing the doctype reference then I get the following error. Here to mulitple xml documents are loaded into a single clob row.
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00209: PI names starting with XML are reserved
Error at line 81
ORA-06512: at "SYS.XMLTYPE", line 254
ORA-06512: at line 1
When try to access this by using select xmltype(x) from t
where x is column type of clob.
Please let me know any method or type loading the multiple xml documents by using plsql. Only plsql method. There is a way by using SAX Loader. But can it be used in plsql or its a java method of loading.
Regards,
Naveen
Edited by: MAN on Oct 18, 2008 9:21 PMsorry for that...
There was enter character between some tags. From there I'm not receiving that particular error.
Now what I get is
ORA-31001: Invalid resource handle or path name "/MobileInventoryResponse.dtd"
ORA-06512: at "SYS.XMLTYPE", line 254
ORA-06512: at line 1
ORA-06512: at line 39
This is because there is a doctype at the start of the xml payload.
But if there is no <!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"> this statement then it works fine.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd">
<MobileInventoryResponse>
And this exercise I'm doing in my Windows xp loaded operating system with a local instance of oracle ... Do i need to do any other setting.
Along with that I followed your method mentioned @ Re: LPX-00209: PI names starting with XML are reserved
ignore:=dbms_xdb.createResource('/MobileInventoryResponse.dtd',bfilename('XML_DIR','MobileInventoryResponse.dtd'));
And I'm not getting how it will refer the this resource.
this above partilcular statement . should it be executed when ever we insert into the table ? But in the dtd there is no word saying "MobileInventoryResponse".
got this error.
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00104: Warning: element "MobileInventoryResponse" is not declared in the DTD
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 254
ORA-06512: at line 1
ORA-06512: at line 21
This is how I'm doing in the block
DECLARE
l_filehandle UTL_FILE.FILE_TYPE;
l_filename VARCHAR2(50):='test.xml';
l_rec_data VARCHAR2(500);
l_rec_trim_data VARCHAR2(500);
l_rec_trim_upper VARCHAR2(500);
l_rec_full_data CLOB;
ignore boolean;
BEGIN
l_filehandle := UTL_FILE.FOPEN('XML_DIR',l_filename,'R');
--dbms_xdb.deleteResource('/MobileInventoryResponse.dtd',dbms_xdb.DELETE_RESOURCE );
LOOP
ignore:=dbms_xdb.createResource('/MobileInventoryResponse.dtd',bfilename('XML_DIR','MobileInventoryResponse.dtd'));
commit;
UTL_FILE.GET_LINE(l_filehandle, l_rec_data);
--dbms_output.put_line('l_rec_data : '|| l_rec_data);
-- Trim the record to remove spaces
l_rec_trim_data := TRIM(l_rec_data);
l_rec_trim_upper := UPPER(l_rec_trim_data);
l_rec_full_data := l_rec_full_data||l_rec_data;
IF l_rec_trim_upper LIKE '</MOBILEINVENTORYRESPONSE>' THEN
dbms_output.put_line('l_rec_full_data : '||l_rec_full_data);
INSERT INTO library_xml VALUES(xmltype(l_rec_full_data));
l_rec_full_data:=NULL;
END IF;
dbms_xdb.deleteResource('/MobileInventoryResponse.dtd',dbms_xdb.DELETE_RESOURCE );
commit;
END LOOP;
UTL_FILE.FCLOSE(l_filehandle);
COMMIT;
--exception just for testing purpose
EXCEPTION
WHEN no_data_found THEN
NULL;
commit;
END;
Edited by: MAN on Oct 21, 2008 2:47 AM -
Counting xml elements using javascript
How can I count the number of certain xml elements inside the xml file that import.
Example xml:
<list>
<product>
<name>Product_01</name>
<detail>info here</detail>
</product>
<product>
<name>Product_02</name>
<detail>info here</detail>
</product>
<product>
<name>Product_03</name>
<detail>info here</detail>
</product>
</list>
I would like to count the number of product -elements in this example xml.
I'm using javascript for scripting.
Thanks.#target indesign
#include "/Applications/Adobe InDesign CS3/Scripts/Xml Rules/glue code.jsx"
var myDocument = app.activeDocument;
var myCounter = 0;
var myRuleSet = new Array (new ProcessProduct);
with(myDocument){
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
alert("Found " + myCounter + " product elements");
function ProcessProduct(){
this.name = "ProcessProduct";
this.xpath = "//product";
this.apply = function(myElement, myRuleProcessor){
with(myElement){
myCounter++;
return true; -
Remove xml element using JS[CS3]
Hi, I have an xml structure where i want to remove some paritcular element named "extlink".
I do have one script with me but it doesn't wipe out all specific xml element from structure.
var myDoc = app.activeDocument;
var foundtext = 0
Query_Remove (myDoc);
alert ("You have removed " + foundtext + " " +" Link !!")
exit (0);
function Query_Remove(elm)
try
for(var i=elm.xmlElements.length-1; i>=0; i--)
if((elm.xmlElements[i].markupTag.name == "extlink") && (elm.xmlElements[i].xmlElements[0].markupTag.name == "http"))
var Store_CitAttri = elm.xmlElements[i].xmlElements[0].xmlAttributes.item("c_style").value;
if(Store_CitAttri == "URL")
elm.xmlElements[i].remove();
foundtext = foundtext + 1;
Query_Remove(elm.xmlElements[i]);
catch (e){
Some time it skip the element from all figure captions and some time from body text and some time it works perfectly
Could any one figure it out why this script behaviour is not consistent as i am new to scripting and not getting any idea about this.
Thanks
MacOkay, after peering over your code and trying a few things out I see one immediate problem and one possible improvement.
The problem lies in this:
1. if condition is true, remove item
2. check recursively
The problem is .. if an item is removed, the following recursive check will always fail. However, the entire loop is wrapped into a try..catch, so InDesign will not alert you that it failed. Instead, it will continue with what's after the loop, exactly because the try..catch is around the entire loop!
Change the loop code to this
if((elm.xmlElements[i].markupTag.name == "http") && (elm.xmlElements[i].parent.markupTag.name == "extlink"))
var Store_CitAttri = elm.xmlElements[i].xmlAttributes.item("c_style").value;
if(Store_CitAttri == "URL")
elm.xmlElements[i].remove();
foundtext = foundtext + 1;
continue;
Query_Remove(elm.xmlElements[i]);
so the recursive checking is skipped. You can also remove the entire try..catch block, as this may hide additional errors ...
The improvement is: as I started reading this thread from the top again, shouldn't you be removing the "extlink" items, rather than just the "http" ones inside?
If so, remove the parent of the found item (which is always the "extlink"):
elm.xmlElements[i].parent.remove();
-- and, as this will break the loop (because you just removed the set of elements it was working in!), replace 'continue' with 'return'.
Hope this helps -
Stored procedure returning multiple records without using SYS_REFCURSOR
Hello,
I am new to oracle stored procedures, have done stored procs in SQL server in past. I am trying to write single stored proc which will return multiple records. I have the stored proc as below and that is compiled without any errors.
We don't want to use SYS_REFCURSOR as output param b'coz the place from which this proc is gonna call, that system doesn't support SYS_REFCURSOR param.
create or replace
PROCEDURE p_get5500DATA_MB (
IN_plan_ID IN T_5500DATA_QWP.Plan_ID%TYPE,
IN_plan_ID_col OUT T_5500DATA_QWP.Plan_ID%TYPE,
p_SEQNUM OUT T_5500DATA_QWP.SEQNUM%TYPE,
p_HEADER_CD OUT T_5500DATA_QWP.HEADER_CD%TYPE,
p_VALUE1 OUT T_5500DATA_QWP.VALUE1%TYPE,
p_VALUE2 OUT T_5500DATA_QWP.VALUE2%TYPE
) AS
BEGIN
SELECT
Plan_ID,
SEQNUM,
HEADER_CD,
VALUE1,
VALUE2
INTO
IN_plan_ID_col,
p_SEQNUM,
p_HEADER_CD,
p_VALUE1,
p_VALUE2
FROM TRS1DBO.T_5500DATA_QWP
WHERE Plan_ID = IN_plan_ID
ORDER BY SeqNum;
-- EXCEPTION
-- WHEN OTHERS THEN
-- RAISE_APPLICATION_ERROR(-210001, 'Error in fetching data from T_5500DATA_QWP....');
END;
Error:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "TRS1DBO.P_GET5500DATA_MB", line 10
ORA-06512: at line 11
My questions is:
- What would be the best practice for this type of simple stored procedures?
- Is there any alternate or is there anything i can fix in above stored proc which return multiple records?
Thank you,
VimalJust out of curiosity, what are you using for API or driver that doesn't support a ref cursor? Ref cursors are pretty much the defacto standard for passing multiple records out of an Oracle procedure. Oracle's ODP.NET, OLEDB, ODBC, JDBC, OCI, all support ref cursors. Chances are that if the driver you're using doesn't support something as basic/fundamental as a ref cursor, it's probably also not going to support something else either.
You'll most likely want to check with the driver/api vendor on their recommended approach. -
How to iterate xml elements using PL/SQL
Hello,
Let's say I have the following xml:
<A>
<B name="b1">
</B>
<B name="b2">
</B>
</A>
I would like to iterate over the B and sub-B elements using PL/SQL?
Any help will be appreciated.Hi,
You can use 'PL/SQL DOM API for XMLType (DBMS_XMLDOM)'
to work with XML. You can check the example present at
http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96620/xdb08pls.htm#1041419
to check how it does.
The API for the package DBMS_XMLDOM is given on the same page(http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96620/xdb08pls.htm#1040676)
You can use them for your requirement.
Regards,
Anupama -
Delete Power Query queries' custom XML data using VBA
I have Power Query queries in an Excel 2010 file and would like to delete these queries using VBA. so far I can achieve that manually with the following steps:
unload Power Query addin
run Document Inspector and click to delete Custom XML data
The Macro recorder record the following code for step 2.
Sub Makro1()
' Makro1 Makro
ActiveWorkbook.RemoveDocumentInformation (xlRDIPrinterPath)
ActiveWorkbook.RemoveDocumentInformation (xlRDIDocumentProperties)
ActiveWorkbook.RemoveDocumentInformation (xlRDIInactiveDataConnections)
End Sub
However, using this macro I do not achieve the same result (=PQ query code gone from the workbook).
Any ideas on how to achieve the PQ query codes to be removed using VBA?On some cases Macro Recording is not complete, and misses to record the full set of VBA to automate the actions you record. This is probably such a case.
We are looking into future ways to allow you automate Power Query cleanup.
For the time being, please see if the
Document Inspector interface can clean the custom XML data (which holds the Power Query data structures).
thx, Gil. -
How to modify the content of a xml element using java?
Hi all,
In my usecase I need to export some data from the database to the external file (Ms Word) using java.
The data which I get from the database will be in the form of a xml file. In that xml file
I got to modify the content of an attribute of a xml element in the java class. Kindly comeup with your help
to achieve this.
Thanks,
Phanindra.
Edited by: 887737 on Dec 5, 2011 5:52 AMWhy don't you try Xerces2?Why don't you tell him to use the javax.xml APIs that are already built in? And that use Xerces2 under the hood? Instead of throwing out a suggestion that might lead to him adding another copy of Xerces into his application?
@OP there are several techniques:
- string replacement as suggested by jschell
- XML parsing to a DOM and then use the DOM API
- XSLT
Which you should use depends on the complexity of your requirement. -
Running a Select query against multiple sql servers using SSIS script task.
Hi Guys,
I need to fetch data from multiple sql servers using SSIS scirpt task inside a foreach container.
is there anyway i can build dynamic sql connections using ssis variables inside SSIS script task in each loop
Please guide me or refer any blogs so that i will try..
Thanks in advance.Your only options is using .net code, then it will be no different than using a console app in a loop.
using (SqlConnection connection = new SqlConnection(connectionString))
connection.Open();
Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
Console.WriteLine("State: {0}", connection.State);
and so forth for each connection string
the connection string would come from the ForEach loop
Arthur My Blog -
Getting multiple XML elements with UCCX 4
I am trying to pick up multiple elements with identical tags from an XML file.
(Example)
<NAME1>
<PHONE>123-1234-3456</PHONE>
<PHONE>506-245-5566</PHONE>
</NAME1>
I am able to pick up the first PHONE, but when using a second Get XML step I get the same again. How do we traverse the file without actually numbering the tags?
(Thought I did this before, but maybe not...)
regards
JohnnyHi Johnny,
Did you ever find a solution? I'm running into the same scenario.
Thanks!
Mike -
ABAP Query output to XML file using Business connector
Hi All,
I would request your help on to know, how can I read the output of ABAP query executed in SAP system via Business connector and then generate a XML file.
Also the existing business connector system, generates the XML file in encoding iso-8859-1. Where as customer wants the output XML file in encoding windows-1252.
Please help with your valuable ideas.
Thanks,Hello,
possible solution:
1. create a remote function module (FM) in SAP which returns your needed data
2. create outbound map in BC for this FM
3. call this FM from BC in a flow
3. extract the result to XML (e.g. with service recordToDocument)
CSY -
Edit / Modify an XML Element using SAX.
My need is to read,update,delete elements from large (200-700MB) xml files. Because of large files I am using SAX parser. I am able to read the xml using events generated but the issue is how do I modify a perticular attribute or node value, add new node??
Apart from SAX is there any other better solution???
Any help wil be appreciated!!if you meant "in a simple and quick way that will only change the desired value in the text file" i fear no, you can't
-
I have a problem with a query that includes 5 tables!
Equipment ec, (ec.cost, ec.workid)
Material mc, (mc.cost, mc.workid)
Labor lc, (lc.cost, lc.workid)
Work wo, (wo.workid)
Entity en
The primary key is the work id
The columns I need to extract are all the same - "cost"
The problem is that I need to extract the costs from all the tables (equipment/labor/material) where the work "id" is equal to the work "id".
The work table has a unique wo.workid but the other three tables can have
multiple nn.workid ('s).
This is the query I am working from at this time...
SELECT distinct wo.workid, wo.description, wo.supervisor, wo.acctnum,
wo.shop, wo.woaddress, wo.initiatedate,
TO_NUMBER (TO_CHAR (wo.initiatedate, 'MM')) AS mnth,
TO_NUMBER (TO_CHAR (wo.initiatedate, 'YYYY')) AS yr,
wo.actualfinishdate, wo.assetgroup, wo.unitsaccompdesc,
wo.unitsaccomplished,
sum(decode (lc.cost, 0, null, lc.cost)) labour_cost,
lc.laborname AS labour_name,
SUM (decode(mc.COST, 0, null, mc.cost)) AS material_cost,
mc.description AS mat_desc,
SUM (decode(ec.COST, 0, null, ec.cost)) AS equipment_cost,
ec.description AS equip_desc, en.module
FROM work wo,
equipment ec,
material mc,
labor lc,
entity en
WHERE (lc.COST <> 0 AND mc.COST <> 0 AND ec.COST <> 0)
AND wo.applytoentity = en.code
AND mc.workid = wo.workid
AND ec.workid = wo.workid
AND lc.workid = wo.workid
GROUP BY wo.workid,
wo.description,
wo.supervisor,
wo.acctnum,
wo.shop,
wo.woaddress,
wo.initiatedate,
wo.actualfinishdate,
wo.assetgroup,
wo.unitsaccompdesc,
wo.unitsaccomplished,
lc.COST,
lc.laborname,
mc.COST,
mc.description,
ec.COST,
ec.description,
en.module
any help would be appreciated!Hi John...
I am still getting duplicate values.
When the query grabs a value from the labour table it also grabs the values from the other tables and puts them in the same row... There are many rows in the three costs
tables and only one in the work table.
I have a dump of the rows but I cannot find a way to save it here.
Here is a cut down version of the data I am retrieving.
ID DESCRIPTION LAB MAT EQUIP
345 General Building Interior Maintenance Activities 136.60 59.89 133.60
345 General Building Interior Maintenance Activities 64.38 59.89 133.60
345 General Building Interior Maintenance Activities 42.92 59.89 133.60
345 General Building Interior Maintenance Activities 91.28 59.89 133.60
345 General Building Interior Maintenance Activities 374.24 59.89 133.60
345 General Building Interior Maintenance Activities 182.56 59.89 133.60
345 General Building Interior Maintenance Activities 175.68 59.89 133.60
345 General Building Interior Maintenance Activities 48.80 59.89 58.80
345 General Building Interior Maintenance Activities 89.48 59.89 58.80
345 General Building Interior Maintenance Activities 79.80 59.89 58.80
345 General Building Interior Maintenance Activities 294.88 59.89 58.80
345 General Building Interior Maintenance Activities 24.92 59.89 58.80
345 General Building Interior Maintenance Activities 147.44 59.89 58.80
345 General Building Interior Maintenance Activities 182.56 59.89 58.80
345 General Building Interior Maintenance Activities 98.59 59.89 58.80
345 General Building Interior Maintenance Activities 126.84 59.89 58.80
345 General Building Interior Maintenance Activities 55.00 59.89 6,656.00
345 General Building Interior Maintenance Activities 182.56 59.89 6,656.00
345 General Building Interior Maintenance Activities 98.59 59.89 6,656.00
345 General Building Interior Maintenance Activities 191.36 59.89 6,656.00
345 General Building Interior Maintenance Activities 136.60 59.89 66.96
345 General Building Interior Maintenance Activities 55.00 59.89 66.96
345 General Building Interior Maintenance Activities 491.04 59.89 66.96
345 General Building Interior Maintenance Activities 24.92 59.89 66.96
345 General Building Interior Maintenance Activities 182.56 59.89 66.96
345 General Building Interior Maintenance Activities 110.00 59.89 66.96
345 General Building Interior Maintenance Activities 162.80 59.89 66.96
345 General Building Interior Maintenance Activities 85.84 59.89 66.96
345 General Building Interior Maintenance Activities 65.44 59.89 66.96
345 General Building Interior Maintenance Activities 64.38 59.89 736.00
345 General Building Interior Maintenance Activities 79.80 59.89 736.00
Maybe you are looking for
-
URGENT: passing more than one value at the same parameter
Hello friends at www.oracle.com, if I have a Forms program that sends some parameters to a Report, how can I send more than one value at the same parameter that is being sent? For example: the Reports parameter P_CODE should receive (from Forms) and
-
Ipod + itunes = blue screen of death & reboot - HELP PLEASE!
I'll try to make a long story as short as possible here. i've had a 40G ipod for over a year and a half now. back in the beginning things were working fine. with the size i hadn't done any syncing for a long long time. however, the ipod crapped out s
-
Hi ALL, Iam Creating BDC Program bu using ME21 for Uploading PO. Iam getting error at Income term2 in the Second Screen of ME21. Iam Passing this value through Excel Sheet But event then it is not picking. When i check in debugging the value of incom
-
Cannot install Flash Player ActiveX plugin
It's very interesting that I am able to install Flash Player for Mozilla but not for IE (ActiveX). As I'm a web site designer, I need to surf my design at different browsers to ensure compatibility. I tried many of solutions (such as uninstaller, res
-
Is there a way to change the color scheme on charts in IOS numbers?