XMLTable query returns one line per element multiple
Hello
Using Oracle 11 g Release 2, I have a XML file that is stored in the following table:
CREATE TABLE XML_FILES
(
FILENAME VARCHAR2 (1000).
FILECONTENT XMLTYPE
);
The sample XML file:
< includedClaimProcessingResult >
< ClaimRecordIdentifier > 1000 < / ClaimRecordIdentifier >
< ClaimIdentifier > 0x1ABC2D123456789 < / ClaimIdentifier >
< classifyingProcessingStatusType >
< statusCode > R < / statusCode >
< / classifyingProcessingStatusType >
< recordedError >
Pharmacy claim < name > < / name >
< value > < / value >
< > 1.2.3 ErrorCode < / ErrorCode >
< > < ErrorCode > 4.5.6 ErrorCode
< ErrorMessage > claim rejected because the claimIdentifier already exist in the database < / ErrorMessage >
input < ErrorMessage > claim must match a claim < / ErrorMessage >
< ErrorDetail > identifier request already exists in the DB < / ErrorDetail >
< ErrorDetail > < / ErrorDetail >
< / recordedError >
< / includedClaimProcessingResult >
All items have a frequency of 1, with the exception of the error code (1 or more), ErrorMessage (0 or more), & the ErrorDetail (0 or more).
Here's my query:
Select
r.REC_ID,
r.NAME,
r.VALUE,
EC. ERR_CODE,
Ed. ERR_DTL,
EM. ERR_MSG
of xml_files xf,.
XMLTable ('/ includedClaimProcessingResult' in passing xf.filecontent)
columns
Path of REC_ID NUMBER (10) "ClaimRecordIdentifier."
Path NAME VARCHAR2 (20) recordedError/name"."
Path of ELMNT_VAL VARCHAR2 (5) ' recordedError/value. '
IERRC xmltype path recordedError/ErrorCode"."
ierrd ' recordedError/ErrorDetail, xmltype path
r ierrm xmltype path "recordedError/ErrorMessage"),
XMLTable ('ErrorCode' adoption r.ierrc
columns
Path of ERR_CODE VARCHAR2 (15) '.') EC,
XMLTable ('ErrorDetail' adoption r.ierrd
columns
Path of ERR_DTL VARCHAR2 (100) '.') (+) ed,.
XMLTable ('ErrorMessage' adoption r.ierrm
columns
Path of ERR_MSG VARCHAR2 (100) '.') (+) em;
I try to return the item corresponding to the first occurrence of several elements in a row values, the second occurrence is in another line, etc. (the number of possible occurrences is not static):
REC_ID NAME VALUE ERR_CODE ERR_DTL ERR_MSG
---------------------- -------------------- --------- --------------- ----------------------------------- -----------------------------
1000 pharmacy claim 1.2.3 that request identifier already exists in the DB claim rejected because the claimIdentifier already exist in the database
1000 pharmacy claim 4.5.6 incoming claim must correspond to a claim
Thanks for any help!
It would be much easier if the person who designed the XML thought first about the consequences of their design...
We can do it, but it will not perform...
One option would be to apply an XSL to transform XML into something more logical...
The other would be to use XQUERY...
SQL > with MY_BAD_XML like
() 2
3. Select XMLTYPE)
4'
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 ') of the double OBJECT_VALUE
21)
22. Select c.
MY_BAD_XML 23,
24 XMLTABLE)
25 ' for $i in $XML / includedClaimProcessingResult
26 return result {} element
27 for $j to $pos in $ recordedError/i/ErrorCode
28 return element row {}
$i 29/ClaimRecordIdentifier,
$i 30/ClaimIdentifier,
$i 31/classifyingProcessingStatusType/statusCode,
$i 32/recordedError/Name,
$i 33/recordedError/value,
$i 34/recordedError/ErrorCode [$pos],
$i 35/recordedError/ErrorMessage [$pos],
$i 36/recordedError/ErrorDetail [$pos]
37 }
38} / row
39 '
40 from OBJECT_VALUE as 'XML '.
41 columns
42 path of the ClaimRecordIdentifier VARCHAR2 (32) "ClaimRecordIdentifier".
43, path of the ClaimIdentifier VARCHAR2 (32) "ClaimIdentifier".
44, path VARCHAR2 (32) statusCode 'statusCode '.
45, path name VARCHAR2 (32) 'name '.
46, path of VARCHAR2 value (32) 'value '.
47, path VARCHAR2 (32) error code "error Code".
48, path VARCHAR2 (32) ErrorMessage "ErrorMessage".
49, path of ErrorDetail VARCHAR2 (32) "ErrorDetail.
(50) c
51.
CLAIMRECORDIDENTIFIER CLAIMIDENTIFIER
-------------------------------- --------------------------------
STATUSCODE NAME
-------------------------------- --------------------------------
ERRORCODE VALUE
-------------------------------- --------------------------------
ERRORMESSAGE ERRORDETAIL
-------------------------------- --------------------------------
1000 0x1ABC2D123456789
Pharmacy claim R
1.2.3
Request rejected because claimIden request identifier already exists
CLAIMRECORDIDENTIFIER CLAIMIDENTIFIER
-------------------------------- --------------------------------
STATUSCODE NAME
-------------------------------- --------------------------------
ERRORCODE VALUE
-------------------------------- --------------------------------
ERRORMESSAGE ERRORDETAIL
-------------------------------- --------------------------------
1000 0x1ABC2D123456789
Pharmacy claim R
4.5.6
Incoming claim must correspond to a claim
SQL >
Tags: Database
Similar Questions
-
One record per person, either the min year or year max
Asked to show one record per person according to the following criteria: the number of years between the startyear and the courseyear is less than 4 use of the first year of course if if the number of years between the startyear and the courseyear is greater than 4 use the last (most recent) courseyear. The other problem with the data over time, the courseno has changed, but is still considered as the same course. Here are examples of data (with declaration) and the SQL code that I started to build.
This is the expected result.with firstlast as ( select '12345' as id, 2005 as startyear, 2006 as courseyear, 'SCI221' as courseno from dual union select '12345' as id, 2005 as startyear, 2007 as courseyear, 'SCI221' as courseno from dual union select '23456' as id, 2008 as startyear, 2009 as courseyear, 'SCI221' as courseno from dual union select '23456' as id, 2008 as startyear, 2013 as courseyear, 'SCI226' as courseno from dual union select '34567' as id, 2010 as startyear, 2011 as courseyear, 'SCI221' as courseno from dual union select '34567' as id, 2010 as startyear, 2012 as courseyear, 'SCI221' as courseno from dual ) select id, startyear, courseyear, min(courseyear) over (partition by id) as minterm, max(courseyear) over (partition by id) as maxterm, max(courseyear) over (partition by id) - courseyear as lagterm, CASE WHEN max(courseyear) over (partition by id) - (courseyear) > 2 THEN 3 ELSE 0 END as lagtermno, courseno from firstlast
-----------------------------------------------------------------------------ID STARTYEAR COURSEYEAR COURSENO 12345 2005 2006 SCI221 23456 2008 2013 SCI226 34567 2010 2011 SCI221
BANNER
Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE Production 11.2.0.2.0
AMT for Solaris: 11.2.0.2.0 - Production Version
NLSRTL Version 11.2.0.2.0 - ProductionHello
user1069723 wrote:
... For cases where there is more than one line per person:If the difference between the year of course and the start year is 3 or less choose all of the line which was the first year of classes.
If the difference between the year of course and the start year is greater than 3, then select the entire line that is the last year of course.
Oh, you want the first or last line.
This is an example of a Query of Top - N . Here's a way to do it:
WITH got_analytics AS ( SELECT f.* , ROW_NUMBER () OVER ( PARTITION BY id ORDER BY courseyear ) AS a_num , ROW_NUMBER () OVER ( PARTITION BY id ORDER BY courseyear DESC ) AS d_num , MAX (courseyear) OVER (PARTITION BY id) - MIN (startyear) OVER (PARTITION BY id) AS year_dif FROM firstlast f ) SELECT id, startyear, courseyear, courseno FROM got_analytics WHERE 1 = CASE WHEN year_dif > 3 THEN d_num ELSE a_num END ORDER BY id ;
The typical top - N query is to calculate ROW_NUMBER (in ascending or descending) in a subquery and then by using the WHERE clause of the main query to get only the rows where this number is<=>=>
This top - N query is somewhat different, because if we are ascending to descending order may vary the partition in the partition. In the above query, we calculate the ROW_NUMBER in both directions and then, in the main query, decide whether we will use the bottom line number or decreasing the number. -
If a view object query returns no rows, can the vacuum to be tested at all?
All those who know or have also experienced:
I guess that the answer should be Yes, but I tried anyway, I still didn't worked. Here is the code (it's a method behind a command button, a bean of support (I use JDeveloper 10.1.3.4).) In the code, LoggedInStudent is the name of a view object; ZBLCModule is the name of the application module):
When the view object query returns a line, the whole of the application works without error. When the query returns no rows, test (1) always bombs toward the top of the application, prompting a Houston-30003 error.public String commandButton1_action() { FacesContext fc = FacesContext.getCurrentInstance(); ValueBinding vb = fc.getApplication().createValueBinding("#{data}"); BindingContext bc = (BindingContext)vb.getValue(fc); DCDataControl dc = bc.findDataControl("ZBLCModuleDataControl"); ApplicationModule am = (ApplicationModule)dc.getDataProvider(); ZBLCModuleImpl zblcam = (ZBLCModuleImpl)am; LoggedInStudentImpl studentsFound = (LoggedInStudentImpl)zblcam.getLoggedInStudent(); String navCase = null; // Test (1): if the view cache is empty; always bombs up the application if it IS empty: if(studentsFound.getAllRowsInRange().length == 0) { navCase = "userNotFound"; // (2) The following three tests gets to run only when the cache is not empty; they work fine. } else if (((Number)studentsFound.first().getAttribute("HoursAttm")).floatValue() == 0.0) { navCase = "noHours"; } else if (((Number)studentsFound.first().getAttribute("Balance")).floatValue() > 0.0) { navCase = "notZero"; } else if (!(studentsFound.first().getAttribute("Validated").equals(" "))) { navCase = "validated"; } else { navCase = "zeroBal"; } return navCase; }
(1) test, I tried the following:
With each of these events, I got an error of Houston-30003. It does not matter what looks like the conditional test; It is important only when the objects from view cache is empty. If the view cache is not empty, everything, including the test (1), works very well. And when the cache is empty is not because of the failure of the connection to the database, but because the student is not in the data table and line are for the student.if (studentsFound.getAllRowsInRange().length == 0) if (studentsFound.first() == null) if (studentsFound.getEstimatedRowCount() == 0) if (studentsFound.isDead()) //I do not know what isDead() does; just tried desperately. if (studentsFound.equals(null)) if (studentsFound.getCurrentRow() == null)
It is a requirement of the company to do something when the view object query returns no rows. Can it be tested at all? How?
Or is there something wrong in the first lines in the method before the {color: green} String navCase = null; {color} line?
Thank you very much for your help!
NewmanHello
What you have done, is to get a handle to the object that CAN execute queries to the database.
However, you do not query the database.Just add:
LoggedInStudentImpl studentsFound = (LoggedInStudentImpl)zblcam.getLoggedInStudent(); //New line studentsFound.executeQuery();
The code that Shay has given you is when you do not have a request for all module, but since you are talking about a command etc button I guess that the module of the application is already active.
The line I gave you should be enough to make it work.I'd be careful with the
studentsFound.hasNext();
I suggest to use estimatedRowCount();
-Anton
-
single-line subquery returns moret one line han
UPDATE T74
SET LORRYOWNERNAME = 'BELLA. "
OWNERFATHERNAME = "GHANIMIYA"
AND
(SELECT T74 INVOICEDATE, T74A WHERE T74.) REFERENCENO = T74A. REFERENCENO AND T74. "LORRYNO ="KA05AA4916"AND INVOICEDATE > = February 25, 2011")= February 25, 2011 "
my inner query returns 5 rows ihave to update only the data that are greater than 25 February 2011"
not below when I use > = any it updates all rows, if I removed everything he is in error:
single-line subquery returns moret one line han
could you please correct the query
Published by: 848525 on Sep 7, 2011 12:18 AMTry
UPDATE T74 SET LORRYOWNERNAME='BASHA', OWNERFATHERNAME='GHANIMIYA', PANNO='AGNPD4113G' WHERE LORRYNO='KA05AA4916' AND exists (SELECT INVOICEDATE FROM T74A WHERE T74.REFERENCENO=T74A.REFERENCENO AND INVOICEDATE>='25-FEB-2011')
do not duplicate the post please
Published by: Alexandr Sep 6, 2011 23:52
-
Single - row subquery returns more than one line.
Hi Experts
I am faced with error
ORA-01427: single - row subquery returns more than one line.
MyQuery is:
select TO_CHAR(T.MR_REG_DATE,'DD') "DATE" ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END age ,count(T.Mr_Code) No_of_Patient ,( SELECT count(x.mr_code) mr_code FROM HMIS_MRINFO X where X.mr_reg_date between &FRM_DATE AND &TO_DATE and X.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y WHERE Y.mr_reg_date between &FRM_DATE AND &TO_DATE ) GROUP BY CASE WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ) Missing_MR from hmis_mrinfo T,hmis_pat_add_dis_detail M where T.mr_code = M.mr_code(+) and T.mr_reg_date between &FRM_DATE AND &TO_DATE &AGE_GRP GROUP BY T.MR_REG_DATE ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ORDER BY T.MR_REG_DATE;
Please give some advice / solution.
I think this might do it for you
Select
TO_CHAR (T.MR_REG_DATE, 'DD') "DATE."
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
Age of the END
count (T.Mr_Code) No_of_Patient
, count (case when t.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y))
WHERE Y.mr_reg_date between & FRM_DATE AND & TO_DATE)
then t.mr_code
(end) Missing_MR
of hmis_mrinfo T, hmis_pat_add_dis_detail M
where T.mr_code = M.mr_code (+)
and between T.mr_reg_date & FRM_DATE AND & TO_DATE
& AGE_GRP
T.MR_REG_DATE GROUP
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
END
ORDER BY T.MR_REG_DATE;
-
How to know what sub query returns multiple rows
Hi all
Someone can give me hints, how to know what sub query returns many rows in the following query.
Kind regards/* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */ SELECT a.*, ROWNUM AS rnm FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org", prxm.mbr_idntfr AS "Beneficiary ID", md.last_name || ', ' || md.first_name AS "Beneficiary Name", pci.idntfr AS "Tracking No.", TO_CHAR (TRUNC (req.pa_rqst_date), 'MM/dd/yyyy' ) AS "Request Date", sts.status_name AS "Status", req.pa_rqst_sid AS "Request #", prxm.mbr_sid AS "Mbr_sid", TO_CHAR (TRUNC (req.pa_revision_date), 'MM/dd/yyyy' ) AS "Last Updated", TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE", prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID", pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View", DECODE ((SELECT DISTINCT pd.national_prvdr_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), 0, (SELECT prxplo.prvdr_lctn_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), NULL, (SELECT prxplo.prvdr_lctn_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), (SELECT DISTINCT pd.national_prvdr_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR') ) AS "NPI/ID", DECODE ((SELECT pd.org_bsns_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), NULL, (SELECT pd.last_name || ', ' || pd.first_name || ' ' || pd.middle_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), (SELECT pd.org_bsns_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR') ) AS "Prvdr Name", TO_CHAR (psd.from_date, 'MM/dd/yyyy' ) AS "Srvc From Date", TO_CHAR (req.validity_start_date, 'MM/DD/YYYY' ) AS "Due Date", (fn_get_busniess_days (TRUNC (req.validity_start_date)) ) AS "Days<br>Left", req.pa_mode_type_lkpcd AS "Source", TO_CHAR (TRUNC (wmdtl.rtng_date), 'MM/dd/yyyy' ) AS "Assigned On", NVL (wmdtl.assigned_to_user_name, 'Not Assigned' ) AS "Assigned To", req.org_unit_sid AS "OrgUnitSid", TO_CHAR (wmdtl.modified_date, 'MM/dd/yyyy hh24:mi:ss' ) AS "WTRD_MODIFIED_DATE", TO_CHAR (wmdtl.rtng_date, 'MM/dd/yyyy' ) AS "WTRD_RTNG_DATE", req.status_cid AS "PA_STATUS_CID", TO_CHAR (req.modified_date, 'MM/dd/yyyy' ) AS "PA_REQ_MODIFIED_DATE", prs.state_pa_srvc_type_code AS "STATE_PA_SRVC_TYPE_CODE", wmdtl.wm_pa_task_rtng_dtl_sid AS "WM_TASK_RTNG_DTL_SID", wmdtl.assigned_to_user_acct_sid AS "WTRD_Assigned_to_user_acct_sid", (fn_get_busniess_days (TRUNC (req.validity_start_date)) ) AS "Days<br>LeftSort", wmdtl.assigned_to_org_unit_sid AS "WTRD_Assigned_to_OrgUntSid", DECODE ((SELECT COUNT (*) FROM pa_request_status prs WHERE prs.pa_rqst_sid = req.pa_rqst_sid AND prs.status_cid = 5 AND prs.oprtnl_flag = 'I'), 0, 'N', 'Y' ) AS "SHOW_UTILIZATION" FROM pa_request req, pa_certification_identifier pci, status sts, pa_request_x_member prxm, wm_pa_task_routing_detail wmdtl, pa_service_date psd, org_unit ou, pa_request_service prs, pa_request_x_provider_location prxpl, provider_location pl, provider_detail pd, provider p, mbr_dmgrphc md WHERE req.oprtnl_flag = 'A' AND req.status_cid NOT IN (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101) AND req.org_unit_sid IN (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145, 3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149, 3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153, 3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157, 3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161, 3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165, 3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169, 3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173, 3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177, 3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181, 3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185, 3101, 3186, 3102, 3187, 3103, 3003, 75000104, 75000108, 2006, 75000103, 75000102, 75000113, 75000111, 75000109, 2001, 2009, 75000105, 75000107, 2004, 2010, 2013, 2014, 2005, 2011, 75000112, 2002, 1001, 2012, 75000106, 2007, 75000101, 2003, 75000110, 2008, 3001, 3002, 3019, 3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023, 3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027, 3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031, 3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035, 3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039, 3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043, 3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047, 3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051, 3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055, 3140, 3056, 3141) AND req.pa_rqst_sid = prs.pa_rqst_sid AND prs.oprtnl_flag = 'A' AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid AND psd.oprtnl_flag = 'A' AND req.pa_rqst_sid = pci.pa_rqst_sid AND pci.oprtnl_flag = 'A' AND req.pa_rqst_sid = prxm.pa_rqst_sid AND prxm.oprtnl_flag = 'A' AND md.oprtnl_flag = 'A' AND md.status_cid = 2 AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE AND prxm.mbr_sid = md.mbr_sid AND ou.org_unit_sid = req.org_unit_sid AND ou.oprtnl_flag = 'A' AND req.pa_rqst_sid = prxpl.pa_rqst_sid AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid AND pci.pa_rqst_sid = prxm.pa_rqst_sid AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid AND pci.pa_rqst_sid = prxpl.pa_rqst_sid AND prxpl.pa_prvdr_type_lkpcd = 'RR' AND prxpl.oprtnl_flag = 'A' AND req.status_cid = sts.status_cid AND sts.status_type_cid = 3 AND sts.oprtnl_flag = 'A' AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid AND p.prvdr_sid = pd.prvdr_sid AND p.prvdr_sid = pl.prvdr_sid AND pd.oprtnl_flag = 'A' AND pd.status_cid = 2 AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE AND wmdtl.subsystem_task_sid = req.pa_rqst_sid AND wmdtl.subsystem_lkpcd = 'PA' AND wmdtl.oprtnl_flag = 'A' AND req.pa_rqst_date > (SYSDATE - 365) ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC, "Beneficiary Name" ASC) a WHERE ROWNUM < 102;
Prakash P
Published by: BluShadow on May 17, 2011 15:01
addition of {noformat}{noformat} tags around the code
3360 wrote:
See point 9 of this section of the FAQ on how to format the code.I see that you did.
No, I did. It's pretty easy to change if the code seems formatted anyway below. It's when I go to edit the message and find no sense because it is not formatted in all cases, I despair. {noformat} :) {noformat}
-
XML not nested queries return no line plus
Hello
I have an urgent problem concerning the following:
I've migrated the XMLDB queries below 11.2.0.1 to 11.2.0.3I registered just the schema
() DBMS_XMLSCHEMA.registerSchema
SCHEMAURL = > ' http://www.mywebsite.com/XML/Impex/order/2006-10-31 ',
SCHEMADOC = > bfilename ('XMLDIR', 'order.xsd'),
local = > TRUE,
gentypes = > TRUE,
gentables = > TRUE,
CSID = > nls_charset_id ('AL32UTF8'));
COMMIT;
Some query works correctly and others not more are:
Queries that do not work are those referring to XML elements nested as in "QUERY 2" belowI think I missed a few steps of initialization for XMLDB.
Order.xsd is the same in both cases
SQLTypes and collections air well (they were created.
(Do not know gentables = > TRUE is necessary in creating schema)Please give some feedback soon.
Thank you very much in advance.In the following XML_FILE is XMLTYPE
QUERY 1
SELECT THIS WORKS PROPERLY--------------------------------
SELECT
ORDER_LEVEL1.order_no,
TO_TIMESTAMP (ORDER_LEVEL1.order_date, ' YYYY-MM-DD "T" HH24:MI:SS.ff3 "Z" "").
ORDER_LEVEL1.created_by, ORDER_LEVEL1.currency, ORDER_LEVEL1.customer_locale, ORDER_LEVEL1.order_status
Of
p (selection double XML_FILE),
XMLTable)
xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'),
' / orders/order "ADOPTION p.XML_FILE
COLUMNS
The "@order-no"order_no WAY,
ORDER_DATE PATH "order date"
created_by PATH "created by",
currency of access road "currency."
customer_locale "client-local," PATH
order_status PATH "order status/tracking".
) ORDER_LEVEL1;
-----------------------------------
QUERY 2
THIS SELECTION IS NOT WORKING NOW (returns the LINES No.)
--------------------------------
Select
order_no as order_no, STOREID as STOREID, SHIPPINGMETHOD as SHIPPINGMETHOD
Of
(
with mainq as
(
Select
ORDER_LEVEL1.order_no as ORDER_NO,
CUSTOMATT_LEVEL2.*
Of
p (selection double XML_FILE),XMLTable)
xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'),
' / orders/order "ADOPTION p.XML_FILE
COLUMNS
The "@order-no"order_no WAY,
custom_attribute PATH of XMLTYPE "custom-attributes/custom-attribute.
) ORDER_LEVEL1,.XMLTable (xmlnamespaces (default 'http://www.mywebsite.com/xml/impex/order/2006-10-31'), )
"/ custom attribute" ADOPTION ORDER_LEVEL1.custom_attribute
COLUMNS
attribute_id PATH ' @attribute-id ',
path value 'value '.
) CUSTOMATT_LEVEL2
)
Select
order_no,
STOREID, Max (decode(attribute_id,'storeId',TheValue)),
Max (decode(attribute_id,'shippingMethod',TheValue)) SHIPPINGMETHOD
of mainq
Order_no group
);ORDER FOR REFERENCE. XSD (only the rΘation segment to the elements in the query)
< xsd: element name = "orders" xdb:defaultTable = "ORDERS" >
< xsd: complexType mixed = "false" xdb:SQLType = "DMW_ORDERS" xdb:maintainDOM = "false" >
< xsd: SEQUENCE >
< xsd: element name = "command" type = "complexType.Order" xdb:SQLCollType = "DMW_ORDERS_COLL" minOccurs = "0" maxOccurs = "unbounded" > < / xsd: element > "
< / xsd: SEQUENCE >
< / xsd: complexType >
< / xsd: element >
< xsd: complexType name = "complexType.Order" xdb:SQLType = "DMW_ORDER" xdb:maintainDOM = "false" > "
< xsd: SEQUENCE >
< xsd: element name = "order date" type = "xsd: DateTime" minOccurs = "1" maxOccurs = "1" xdb:SQLType = "TIMESTAMP WITH TIME ZONE" >
< xsd: annotation >
< xsd: documentation > original date and time, the order was placed. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "created by" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "original-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "currency" type = "simpleType.Currency" maxOccurs = "1" minOccurs = "1" > < / xsd: element > "
< xsd: element name = "customer-local" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "source code" type = "complexType.SourceCode" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
< xsd: element name = "name-partner-affiliation" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "partner-affiliate-id" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "invoice-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "customer" type = "complexType.Customer" maxOccurs = "1" minOccurs = "0" > "
< xsd: annotation >
< xsd: documentation > information about the customer who placed the order. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "customer-order-reference" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "status" type = "complexType.OrderStatusSet" maxOccurs = "1" minOccurs = "0" > "
< xsd: annotation >
< xsd: documentation > Order status information. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "replace-code" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "description to replace" type = "simpleType.Generic.String.4000" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "replacement-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "replaced-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "current-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "cancel-code" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "cancel-description" type = "simpleType.Generic.String.4000" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "LineItem-product" type = "complexType.ProductLineItems" maxOccurs = "1" minOccurs = "0" > "
< xsd: annotation >
< xsd: documentation > product line items of the order. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "LineItem-giftcertificate" type = "complexType.GiftCertificateLineItems" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
< xsd: element name = "transport-LineItem" type = "complexType.ShippingLineItems" maxOccurs = "1" minOccurs = '0' > < / xsd: element > "
< xsd: element name = "expeditions" type = "complexType.Shipments" maxOccurs = "1" minOccurs = "0" > "
< xsd: annotation >
< xsd: documentation > shipments of the command. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "totals" type = "complexType.OrderTotals" maxOccurs = "1" minOccurs = "0" > "
< xsd: annotation >
< xsd: documentation > order total. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "payments" minOccurs = "0" maxOccurs = "1" type = "complexType.Payments" >
< xsd: annotation >
< xsd: documentation > payments used for the order. < / xsd: documentation >
< / xsd: annotation >
< / xsd: element >
< xsd: element name = "remoteHost" type = "simpleType.Generic.String.40" minOccurs = "0" maxOccurs = "1" / > "
< xsd: element name = "notes" type = "complexType.Notes" minOccurs = "0" maxOccurs = "1" / > "
< xsd: element name = "external-order-no" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "external-order tracking" type = "simpleType.Generic.String.256" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "external-order-text" type = "simpleType.Generic.String" minOccurs = "0" maxOccurs = "1" > < / xsd: element > "
< xsd: element name = "custom attributes" type = "sharedType.CustomAttributes" minOccurs = "0" maxOccurs = "1" / > "
< / xsd: SEQUENCE >
< xsd: attribute name = "order-no" type = "simpleType.Generic.String.256" use = "required" / > "
< / xsd: complexType >.......................
< xsd: complexType name = "sharedType.CustomAttributes" mixed = "false" xdb:SQLType = "DMW_CUSTOMATTRIBUTES" xdb:maintainDOM = "false" > "
< xsd: SEQUENCE >
< xsd: element name = "custom, the attribute" type = "sharedType.CustomAttribute" minOccurs = "0" xdb:SQLCollType = "DMW_CUSTOMATTRIBUTES_COLL" maxOccurs = "unbounded" / > "
< / xsd: SEQUENCE >
< / xsd: complexType >.......................
< xsd: complexType name = "sharedType.CustomAttribute" mixed = "true" xdb:SQLType = "DMW_CUSTOMATTRIBUTE" xdb:maintainDOM = "false" > "
< xsd: SEQUENCE >
< xsd: element name = "value" type = "simpleType.Generic.String" minOccurs = "0" maxOccurs = "unbounded" / > "
< / xsd: SEQUENCE >
< xsd: attribute name = "id attribute" type = "simpleType.Generic.NonEmptyString.256" use = "required" / > "
< xsd: attribute ref = "XML: lang" / >
< / xsd: complexType >-XML (partial segment) example
<? XML version = "1.0" encoding = "UTF-8"? "> < ordered xmlns ="http://www.mywebsite.com/xml/impex/order/2006-10-31">."
< order order-no = "BLY0000001605" >
< - > 2014 order date - 02-25T 11: 00:30.959Z < / date of order >
ECOMMERCE < created-by > < / created by >
BLY0000001605 < original-order - No. > < / original-order-not >
< currency > $ < / currency >
<>client-local en_US < / customer-local >
< status >
Placed > order tracking < < / order >
< / status >
< custom attributes - >
< attribute custom attribute id = "storeId" > < value > < / value > < / custom attribute >
< attribute custom attribute id = "shippingMethod" > < value > SAMEDAY_DLV < / value > < / custom attribute >
< / custom attributes >
< / order >
< / order >I can't believe it. You are right.
Removed the external selection and it worked! Mysteries of the Oracle :-)
Thank you so much Odie
(just a question: is 63 your favorite number or your birth year? you can answer me separately if you like...)
GP_63
-
Attributes XML makes my query returns no rows
Hi all
I have a strange problem.
I ask an XML, but the attributes in one of the tags my query will return no rows. If I delete the attributes, the query works as expected.
The XML code is below; This is the Report tag attributes that cause problems:
My query is:<result errorCode="0"> <return> <Report xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&rs%3AFormat=xml&rc%3ASchema=True" Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Items_x0020_status_x0020_information"> <Tablix1> <Details_Collection> <Details ItemId="914P7" Username="test" user_role="IT" first_name="Barry" last_name="Donovan" organisation="" content_format="On_Screen" modified_date="26/05/2011 13:16:49" item_status="Draft" status_date="" component_name="" demand="" /> </Details_Collection> </Tablix1> </Report> </return> </result>
I tried to strip the attributes to the tag, which works, but some XML I look back are large enough (number of records), so that cause problems in itself. I would rather deal with it and don't mess with the XML itself if possible.select a.item_id ,a.username ,a.user_role ,a.first_name ,a.last_name ,a.supplier_id ,a.format ,a.modified_date ,a.item_status ,a.completion_date ,a.component_code from dual ,xmltable ('/result/return/Report/Tablix1/Details_Collection/Details' passing p_xml columns item_id varchar2(1000) path '@ItemId' ,username varchar2(1000) path '@Username' ,user_role varchar2(1000) path '@user_role' ,first_name varchar2(1000) path '@first_name' ,last_name varchar2(1000) path '@last_name' ,supplier_id varchar2(1000) path '@organisation' ,format varchar2(1000) path '@content_format' ,modified_date varchar2(1000) path '@modified_date' ,item_status varchar2(1000) path '@item_status' ,completion_date varchar2(1000) path '@status_date' ,component_code varchar2(1000) path '@demand' ) a;
Any help would be much appreciated!
Thank you much in advance.
Robin
Published by: User_resU on April 12, 2012 14:50The element of report and its children belong to a default namespace.
You have stated that in the request too:xmltable ( xmlnamespaces('Items_x0020_status_x0020_information' as "ns0"), '/result/return/ns0:Report/ns0:Tablix1/ns0:Details_Collection/ns0:Details' passing
-
Hello
I'm trying to achieve the following objectives:
1. in table A, select rows based on the values in column 2. something like SELECT * FROM TABLE A WHERE (COLUMN2 = 'X' or Column2 IS NULL)
2 and these values selected, I want to update Column3 from Table A if TableA.column1 = TableB.column1, but only if there is exactly one game. If there are multiple matches, column 3 of the table article updated.
That's what I've tried so far.
UPDATE TABLE_A
SET
TABLE_A.COLUMN3 = (SELECT COLUMN3 OF TABLE_B
WHERE ((TABLE_B.COLUMN1 = TABLE_A.COLUMN1) AND ( TABLE_B.COLUMN1 IN (SELECT Column1 FROM TABLE_B GROUP BY COLUMN1 , HAVING COUNT (*) = 1)))
WHERE EXISTS (SELECT * FROM TABLE_A)
WHERE ((TABLE_A.COLUMN2 = 'X' OU TABLE_A.COLUMN2 = 'Y') AND (TABLE_A.COLUMN4 IS NULL OR TABLE_A.COLUMN4 = ' ')));
More details on my DB environment:
Version Info:
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
PL/SQL Release 11.2.0.4.0 - Production
Toad, but, depending on whether the query updated all lines. I would really appreciate if someone could tell me how to fix my request.
Thanks in advance.
Exists it predicate in the block of update will be set to true if there is at least one row in table_a where column2 is X or Y and column4 is null or a space. You need to correlate exists it with the outer query query (I'm guessing on column1) to get the result I think you want. However, who would update all rows in table_a who meets the criteria, there is a corresponding row in table_b, affecting Column3 lines form null not matched or not. (Again), I'm guessing that's not your intention. If you only want to update the lines in table_a which have a corresponding line in table_b and meet the other predicate, then I think you want something more like:
Update table_a
Set table_a.column3 = (select column3 of table_b
where table_b.column1 = table_a.column1 and
Table_B.Column1 in (select column1 from table_b
Group by column1, having count (*) = 1))
where ((table_a.column2 = 'X' ou))
table_a.Column2 = 'Y') and
(table_a.column4 is null or)
table_a.column4 = ' ')) and
table_a.Column1 in (select column1 from table_b
Group by column1, having count (*) = 1)
John
-
Add a string when the query returns all records
DB version: 11.2
create table t (empname varchar2 (25), salary number, varchar2 (20) months, number of over_time);
insert into values t ('JOHN', 2000, "NOVEMBER2014", 0);
insert into values t ('KATE', 2000, "NOVEMBER2014", 300);
insert into values t ('HANS', 5000, "NOVEMBER2014", 100);
insert into values t ("KRISHNA", 2500, "NOVEMBER2014", 0);
insert into values t ("SIEW", 3000, "NOVEMBER2014", 0);
commit;
SQL > select * from t;
EMPNAME MONTHS SALARY OVER_TIME
------------------------- ---------- -------------------- ----------
JOHN 2000 NOVEMBER2014 0
KATE 2000 NOVEMBER2014 300
HANS 5000 NOVEMBER2014 100
KRISHNA 2500 NOVEMBER2014 0
SIEW 3000 NOVEMBER2014 0
SQL > select * from t where MONTH = 'NOVEMBER2014' and OVER_TIME! = 0 ;
EMPNAME MONTHS SALARY OVER_TIME
------------------------- ---------- -------------------- ----------
KATE 2000 NOVEMBER2014 300
HANS 5000 NOVEMBER2014 100
What I need is:
If the query above returns at least one record, it should display the line ' Yes. We have one or more employees who worked overtime in November2014'
before the documents are printed
Thus, the expected production is
Yes. We have one or more employees who worked overtime at the November2014
EMPNAME MONTHS SALARY OVER_TIME
------------------------- ---------- -------------------- ----------
KATE 2000 NOVEMBER2014 300
HANS 5000 NOVEMBER2014 100
If the query returns no records then usual 'no rows selected' isn't enough
Lothar G.f. says:
In fact, sql * more is no good tool for use considered.
Really? It may be a good reporting tool if you learn to use it as such...
for example
SQL > ttitle left 'Yes. We have one or more employees who worked overtime in November2014.
SQL > select * from emp where empno = 1234;no selected line
SQL > select * from emp where empno = 7788;
Yes. We have one or more employees who worked overtime at the November2014
EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20This is just a basic example. It is possible to get SQL * more to ask for the required criteria and that the title could adjust according to this criterion, as well as the query building on it also.
However, the OP did not specify SQL * as the reporting tool, so there is little interest providing a complete solution which, until they specify what user interface that they are actually using.
-
Problem with insertChildXML, deleteXML, XMLTable query
Hello
I'm working on a
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With partitioning, Real Application Clusters, Automatic Storage Management, OLAP,.
Options of Data Mining and Real Application Testing
POWER SUPPLY 11.2.0.3.10
I have a table with an XMLTYPE field.
In this area, I insert an object XMLType in this way:
INSERT INTO t_schedule_alert (id_schedule_alert, id_schedule, i_type_alarm_schedule, id_lang_type_alarm_schedule, id_user, x_alert_type, i_status_schedule_alert, id_lang_status_schedule_alert)
VALUES (sq_id_schedule_alert.nextval, in_id_schedule, in_i_type_alarm_schedule, 1, id_user_, xml_, ln_schedule_st_alert_waiting, 1)
RETURN id_schedule_alert INTO id_;
Where xml_ = XMLtype ("< alert_types >" | ") alert_type_config_ | ("< / alert_types > ') and alert_type_config_ = ' < type > email < / Type > < sms type > < / type > ';
The insert does not work correctly, infact him select query:
SELECT MAX (s.id_schedule_alert) id_schedule_alert, s.id_schedule, s.id_user, s.i_type_alarm_schedule, Max (s.type_alarm_schedule) type_alarm_schedule, Max (s.i_status_schedule_alert) i_status_schedule_alert, Max (s.status_schedule_alert) status_schedule_alert, Max (s.id_data) id_data, Max (decode (his. TYPE_, 'sms', 1, 0)) sms,. Email Max (decode (his. TYPE_, 'email', 1, 0)) Max (decode (his. TYPE_, 'event', 1, 0)) event. Expedition Max (decode (his. TYPE_, 'dispatch', 1, 0)) OF v_schedule_alert s. XMLTable ('/ alert_types/type ') in passing s.x_alert_type path of varchar2 (10) columns type_ "text()". ) its WHERE s.id_schedule =: b1 AND s.id_user =: b2 GROUP OF s.id_schedule, s.id_user, s.i_type_alarm_schedule; Works very well in showing me the email = 1 sms = 1, event = 0, = 0 shipping.
Then, using this function to manipulate the XML:
-function update_alert
FUNCTION update_alert)
in_id_schedule in NUMBERS
in_i_type_alarm_schedule in NUMBERS
iv_alert_type IN VARCHAR2,
in_id_user in NUMBERS
in_action in NUMBERS
) RETURN NUMBER
IS
id_user_ NUMBER;
alm_exists_ NUMBER;
XMLType count_;
BEGIN
IF in_id_schedule IS NULL or in_i_type_alarm_schedule IS NULL or iv_alert_type IS NULL or in_action IS NULL THEN
raise_application_error (pk_global.not_enough_param, pk_global.not_enough_param_text);
END IF;
id_user_: = in_id_user;
IF id_user_ IS NULL THEN
id_user_: = pk_security.who_am_i;
END IF;
-update of configuration for the user, add / or remove
IF in_action = 0 THEN
-delete if this is the last of them
XMLQuery ('SELECT count($XML/alert_types/descendant::*)'
by passing s.x_alert_type as 'XML' content of return)
IN count_
OF s t_schedule_alert
WHERE s.id_schedule = in_id_schedule
AND s.id_user = id_user_
and i_type_alarm_schedule = in_i_type_alarm_schedule;
IF to_number (count_.getstringval ()) > 1 THEN
UPDATE t_schedule_alert
SET x_alert_type = deleteXML)
x_alert_type,
' / alert_types/type [text () =' ' | iv_alert_type |] » »] »
)
WHERE id_schedule = in_id_schedule
AND i_type_alarm_schedule = in_i_type_alarm_schedule
AND id_user = id_user_;
END IF;
ELSIF in_action = 1 THEN
-Add if not exists
SELECT CASE WHEN XMLExists (' $ alert_types/XML/type [text () = $ALM]' from x_alert_type as 'XML', iv_alert_type as 'ALM')
THEN 1 ELSE 0 END exists_
IN alm_exists_
OF v_schedule_alert
WHERE id_schedule = in_id_schedule
AND id_user = id_user_
AND i_type_alarm_schedule = in_i_type_alarm_schedule;
IF alm_exists_ = 0 THEN
UPDATE t_schedule_alert
SET x_alert_type = insertChildXML)
x_alert_type,
' / alert_types', 'type ',.
"< type >" | iv_alert_type | ' < / type > '
)
WHERE id_schedule = in_id_schedule
AND id_user = id_user_
AND i_type_alarm_schedule = in_i_type_alarm_schedule;
END IF;
END IF;
RETURN THE NUMBER OF ROWS SQL %;
END;
As soon as I delete the sms type:
declare
ID_ number;
Start
ID_: = pk_schedule_alert.update_alert (: b1,: b2, "sms",: b3, 0);
end;
The select above does not return anything and the simpler query:
Select *.
FROM xmltable ('/ alert_types/type ')
from (select x_alert_type in the t_schedule_alert where id_schedule =: = b1 and i_type_alarm_schedule: b2)
"path of columns type_ varchar2 (10) ' / text()".
) sa;
0 records returned.
Although the field of XMLtype:
"< alert_types >".
Email from < type > < / type >
"< / alert_types >.
If I add more once the type of sms:
declare
ID_ number;
Start
ID_: = pk_schedule_alert.update_alert (28.2, "sms", 12034, 1);
end;
The main query returns 1 for sms and 0 for the event by e-mail if the xml field contains:
"< alert_types >".
Email from < type > < / type >
< type > text < / type >
"< / alert_types >.
and the query:
Select *.
FROM xmltable ('/ alert_types/type ')
from (select x_alert_type in the t_schedule_alert where id_schedule =: = b1 and i_type_alarm_schedule: b2)
"path of columns type_ varchar2 (10) ' / text()".
) sa;
reutrns 1 record, sms
It seems that the crux of e-mail will be damaged some how by the removal of the sms you.
If I build the XML with sms, event and email node and delete the node of sms I have sms = 0, email = 0, event = 1 even if the xml field contains:
"< alert_types >".
Email from < type > < / type >
event < type > < / type >
"< / alert_types >.
I can't find the cause.
Hope to be clear enough and that you can help me.
Thanks in advance,
Samuel
Thanks, now I can reproduce.
XQuery Update has the problem too:
SQL > select id, column_value
t_temp_xml 2,
3 xmltable ('/ alert_types/type ' from config)
4 where id = 1;
ID COLUMN_VALUE
---------- --------------------------------------------------------------------------------
1
sms 1
e-mail SQL >
SQL > update t_temp_xml
2 set config = (xmlquery
3 'copy $d := . Edit)
4 remove the node $d/alert_types/type[.="sms"])
5 return $from
6 passage config
7 content of return
8 )
9 where id = 1;
1 line update
SQL >
SQL > select id, column_value
t_temp_xml 2,
3 xmltable ('/ alert_types/type ' from config)
4 where id = 1;
ID COLUMN_VALUE
---------- --------------------------------------------------------------------------------
Still another problem with the rewrite of XQuery I guess.
This works if you use the NO_XML_DML_REWRITE flag:
SQL > rollback;
Complete restoration
SQL >
SQL > UPDATE / * + no_xml_dml_rewrite * / t_temp_xml
2 SET config = deleteXML (config, ' / alert_types/type [. = "sms"]')
3 WHERE id = 1;
1 line update
SQL >
SQL > select id, column_value
t_temp_xml 2,
3 xmltable ('/ alert_types/type ' from config)
4 where id = 1;
ID COLUMN_VALUE
---------- --------------------------------------------------------------------------------
1
e-mail This should be reported to Oracle's Support.
Maybe it's already fixed in paragraph 12.1, can't check at the moment.
-
A row of Sub query returns more than 1 row!
I'm trying to update the values in one table from another table and get the error: void line query returns More Than 1 row.
I want to PRV_NAME B chart updated in the table A PRV_NAME where A.PRVID = B.PRVID where B.PRV_TYPE = M"
The two paintings were all unique PRVID, however, table B has PRVID that have the same name. So the data in table B can look like this:
PRVID PRV_NAME
1234 PHOENIX MED
1235 MED BAG
1236 MED BAG
1237 OVERLAND
etc...
So, as you can see are the unique PRVID, but not the PRV_NAME. Is this the reason why I get this error?
I do not build the tables and have no control over what is put in them. If this is the reason for the error, is there a way to fix this?
For reference, here's the request. Maybe there's something wrong with that?
Update msb_prv_source ps
Set ps.prv_name =
(select prv00.prv00_prv_name
of prv00_prv prv00
Join msb_prv_source ps
On prv00.prv00_prv_id = ps.prvid
where prv00.prv00_prv_type = am')
Published by: user12296489 on April 19, 2013 10:46/* Formatted on 4/19/2013 2:00:43 PM (QP5 v5.185.11230.41888) */ MERGE INTO msb_prv_source a USING (SELECT * FROM prv00_prv WHERE prv00_prv_type = 'M') b ON (a.prv00_prv_id = b.prvi) WHEN MATCHED THEN UPDATE SET a.prv_name = prv00_prv_name
-
Stupid old backpacker (me) cannot understand why this query returns 1 row
Hi all
In reference to {: identifier of the thread = 2456973}, why do
only 1 rank and not 1 for each task? In fact, I had to test it myself to believe.select sum(count(decode(job, 'CLERK', 1, null))) CLERKS , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS from emp group by job;
It returns the data as if the query were
Using only a single aggregate (count or sum) returns 1 row per job, as expectedselect sum(CLERKS), sum(SALESMANS) from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS from emp group by job)
John Stegeman wrote:
It returns the data as if the query wereselect sum(CLERKS), sum(SALESMANS) from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS from emp group by job)
Exactly the point ;-)
It seems that Oracle actually do, a group of 'double' in the same operation.
Attend plans to explain in this example:SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS 2 , count(decode(job, 'SALESMAN', 1, null)) SALESMANS 3 from scott.emp group by job; CLERKS SALESMANS ---------- ---------- 0 0 0 0 0 0 0 4 4 0 Execution Plan ---------------------------------------------------------- Plan hash value: 1697595674 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 5 | 40 | 4 (25)| 00:00:01 | | 1 | HASH GROUP BY | | 5 | 40 | 4 (25)| 00:00:01 | | 2 | TABLE ACCESS FULL| EMP | 14 | 112 | 3 (0)| 00:00:01 | ---------------------------------------------------------------------------
And compare it to the one with the double aggregates:
SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS 2 , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS 3 from scott.emp group by job; CLERKS SALESMANS ---------- ---------- 4 4 Execution Plan ---------------------------------------------------------- Plan hash value: 417468012 ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 4 (25)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 8 | 4 (25)| 00:00:01 | | 2 | HASH GROUP BY | | 1 | 8 | 4 (25)| 00:00:01 | | 3 | TABLE ACCESS FULL| EMP | 14 | 112 | 3 (0)| 00:00:01 | ----------------------------------------------------------------------------
There are GROUP BY hash and SORT GLOBAL times.
It is really unnecessary to an aggregate on an aggregate - if two aggregates are used "in the same group level.
Sum() aggregates are used on an already aggregated value, so it doesn't look like Oracle which actually cures like 'first do the internal aggregate using the group specified by and then do the external aggregation on the result with any group.'Look at this example where I combine aggregates "double" with "single" aggregates:
SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS 2 , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS 3 , count(decode(job, 'SALESMAN', 1, null)) SALESMANS2 4 , count(*) COUNTS 5 from scott.emp group by job; CLERKS SALESMANS SALESMANS2 COUNTS ---------- ---------- ---------- ---------- 4 4 1 5 Execution Plan ---------------------------------------------------------- Plan hash value: 417468012 ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 4 (25)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 8 | 4 (25)| 00:00:01 | | 2 | HASH GROUP BY | | 1 | 8 | 4 (25)| 00:00:01 | | 3 | TABLE ACCESS FULL| EMP | 14 | 112 | 3 (0)| 00:00:01 | ----------------------------------------------------------------------------
When you mix "doubles" and "single" aggregates, Oracle decides that unique aggregates belong to the 'outer' aggregation
SALESMAN2 did a count on the aggregated work column which is the result of the 'internal' group by - so only 1.
The count (*) is also the result of the aggregation of the 'internal '.I don't know if it's documented or if it is an 'effect' of internal code used for GROUPING SETS or the internal code used to enable the analytical functions like this:
SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS 2 , count(decode(job, 'SALESMAN', 1, null)) SALESMANS 3 , sum(count(decode(job, 'CLERK', 1, null))) over () CLERKS2 4 , sum(count(decode(job, 'SALESMAN', 1, null))) over () SALESMANS2 5 from scott.emp group by job; CLERKS SALESMANS CLERKS2 SALESMANS2 ---------- ---------- ---------- ---------- 0 0 4 4 4 0 4 4 0 0 4 4 0 0 4 4 0 4 4 4 Execution Plan ---------------------------------------------------------- Plan hash value: 4115955660 ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 5 | 40 | 4 (25)| 00:00:01 | | 1 | WINDOW BUFFER | | 5 | 40 | 4 (25)| 00:00:01 | | 2 | SORT GROUP BY | | 5 | 40 | 4 (25)| 00:00:01 | | 3 | TABLE ACCESS FULL| EMP | 14 | 112 | 3 (0)| 00:00:01 | ----------------------------------------------------------------------------
Personally, I think that I would have preferred if Oracle has raised an error on this "double aggregation" and therefore require me to write this way (if it's the result I wanted):
select sum(CLERKS), sum(SALESMANS) from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS from emp group by job)
I don't really see a good use case for aggregations of 'double'-, but rather that he could give you undetected bugs in your code, if you happen to do double aggregation without noticing.
Interesting thing to know ;-)
-
01427 00000 - "einreihig subquery returns several lines.
Hi all
How can I solve it
This code gives me this errorSELECT v.code ,v.bar_code ,v.arb_name ,v.eng_name ,v.branch_no ,(SELECT sum(quantity) FROM viw_whs_items_movement GROUP BY branch_no) FROM viw_whs_items_movement V
01427 00000 - "einreihig subquery returns several lines.
I know that I have more value, but I need this value
Result group
SELECT sum(v.quantity) FROM viw_whs_items_movement v GROUP BY v.branch_no ########################## SUM(V.QUANTITY) --------------- 114453 2501 8137 13270 15230 120626 22536 2926 12848 37509 20911 7503 6248 17221 462 24 15041 10307 12524 526627 10564 8230 13204 2840 80769 1418238 215694 15238 5063 104187 913 147079 11293 12678 18855 35 rows selected
Must be scalar subqueries. You demonstrate your subquery returns more than one line. Where the error.
A solution would be to establish a correlation between the results of the subquery by joining the branch_id with branch_id of the outer query. However, as the two queries use the same table, you can simply use an analytical SUM():
SELECT v.code ,v.bar_code ,v.arb_name ,v.eng_name ,v.branch_no ,sum(quantity) over (partition by branch_no) as branch_tot FROM viw_whs_items_movement V
Cheers, APC
-
result of the default configuration of single page, 999 lines per page
Hello!
IM using 10g with windows server 2003.
whenever I start isqlplus, the default setting is to display the result of a query select on several pages of 24 lines per page. I wish I had my results on a single page. I can change it in the preference but every time I disconnect and connect again, it goes back to several pages. I searched the config file but cannot find the setting to have the default value as a single page.
is it possible to set the default value to a single page?
THX.You must create a login.sql file in c:\orant\BIN
then add the line
define 999 pages
fixed lines 2000 (if you want to set line size too)set... (all variables set can be defined here only)
then call sql * more via plus33w etc.
your changes will be made
If not then
Open sql * more
SQL >
host type
SQL > home
C:\>Windows >
If the guest comes with c:\windows then you must copy the login.sql file in this folder.It depends on this directory
This is the working directory for the shottcut you used to open the plus33w
You can write these lines in glogin.sql in the folder of your oracle_home directory sqlplus
Ad c:\orant\plus33 or c:\orant\sqlplusthen he wil do overall.
Just try
If the problem exists then returnGood luck.
Maybe you are looking for
-
How to prevent a 404 on missing css
Hello Firefox is mea 404 error on css missing files. He didn't use to do this. - How can I fix this.
-
Qosmio G50-129 no sound with HDMI connection
Hello. I have a Quosmio G50-129. Recently, I tried plugging it into my Sony Bravia LCD TV via the HDMI connection.I have video output but there is no sound on the TV. I tried to set the HDMI as audio device as default and the sound level meter in the
-
USB key shows in 'remove hardware safely', but not under the heading of discs
The first time I used this USB flash drive, I transferred my library iTunes from my old computer to my new laptop and it worked, but now when I plug the flash drive, nothing comes up on my laptop. The flash drive will appear on the taskbar under 're
-
Force me to upgrade to Windows 10
Hello again guys! I'm trying to fix d3dx9_39.dll error in League of Legends, and I got this link from the forum LoL: http://www.microsoft.com/en-us/download/details.aspx?id=35 the only thing it does is that it takes me to the download for Windows 10