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):
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;
}
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.(1) test, I tried the following:
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)
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.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!
Newman
Hello
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
Tags: Java
Similar Questions
-
User_Scheduler_Jobs query returns no row in the version 2.1.0.63
Using the 2.1.0.63 version, "select * from user_scheduler_jobs;" returns no rows. It works fine in version 1.5.5.
Published by: User65423 on February 8, 2010 09:24Refer to this topic, when the cause seems to be due to SQL Developer manages not null interval data types.
bug? F9 gives no output dba_scheduler_jobs, version: 2.1.0.63.73
As mentioned in this thread, you can use to_char on the columns of the interval as a workaround...
SELECT source, destination, comments, flags, job_name, job_creator, client_id, global_uid, program_owner, program_name, job_type, job_action, number_of_arguments, schedule_owner, schedule_name, start_date, repeat_interval, end_date, job_class, enabled, auto_drop, restartable, state, job_priority, run_count, max_runs, failure_count, max_failures, retry_count, last_start_date, TO_CHAR(last_run_duration), next_run_date, TO_CHAR(schedule_limit), TO_CHAR(max_run_duration), logging_level, stop_on_window_close, instance_stickiness, system, job_weight, nls_env FROM user_scheduler_jobs a;
-
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}
-
Best place to initialize the View object query where clause or params
Where is the best place to initialize the View object 'where' clause before the page is initially rendered? Or how should it be done?
Specifically, I can't set these values in the entity or view objects because I need information from the user or information Session
the user has entered before you navigate to the page. I want to prepare the View object so that the results of the query appears something reasonable
the first time before using chooses search.
Note: The view object must exist and I need to access managed beans to define the query.
Is there an event hook (java code) that can be called before the page is rendered?
Also, there are hooks that can be called when the user navigates to another tab or page?
Published by: Greateful Sep 6, 2012 19:48Hello
Check out this blog: https://blogs.oracle.com/aramamoo/entry/an_epic_question_how_to
Arun-
-
SQL query returns no row vs. multiple lines
Hello
I am trying to get the result of a simple sql query,
If there is no row returned, he would have "No. ROWS" in the result set.
Other wise all the rows containing data is necessary.
Let me know how this could be achieved. Under query works for the latter and not first case as mentioned below
OUTPUT
+ (box 1) when we use B_ID = 123456 +.
IDS
-----
'NO LINE '.
+ (box 2) when we use B_ID = 12345 +.
IDS
-----
1 11112345
2 22212345
create table TEMP_AAA ( A_ID VARCHAR2(10), B_ID VARCHAR2(10) ) INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('111','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('222','12345'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('333','12000'); INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('444','10000');
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID=12345 ), MATCH_ROW_COUNT AS ( SELECT COUNT(1) AS COUNTS FROM MATCH_ROWS ), PROCESSED_ROWS AS ( SELECT CASE WHEN COUNTS = 0 THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID=12345),'NO ROWS') IDS FROM DUAL) ELSE MATCH_ROWS.IDS END IDS FROM MATCH_ROWS,MATCH_ROW_COUNT ) SELECT * FROM PROCESSED_ROWS;
Hello
I think you want to put this on a report or something. I have what would be easier to do this logic there. But if you want that this is possible.
Like thiswith temp_aaa as (select '111' a_id ,'12345' b_id from dual union all select '222' ,'12345' from dual union all select '333' ,'12000' from dual union all select '444' ,'10000' from dual ) , wanted_rows as ( select '123456' B_ID from dual) select temp_aaa.A_ID || temp_aaa.B_ID IDS from temp_aaa ,wanted_rows where temp_aaa.b_id = wanted_rows.b_id union all select 'NO ROWS' FROM DUAL WHERE (SELECT COUNT(*) FROM TEMP_AAA, wanted_rows WHERE TEMP_AAA.B_ID = wanted_rows.B_ID) = 0
In addition, you mix var and number of always use the same type or convert explicitly (to_number or to_char)
WITH MATCH_ROWS AS ( SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID =12345 -- varchar2(10) number ), ...
And again in the
THEN (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID =12345),'NO ROWS') IDS FROM DUAL) -- varchar2(10) number
Kind regards
Peter
-
Oracle Text multi column index based query returns no rows
Hello
I have a MAH_KERESES_MV table with 3 columns OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2. I create the following Oracle multi column text index:
ctx_ddl.create_preference exec ('MAH_SEARCH', 'MULTI_COLUMN_DATASTORE');
ctx_ddl.set_attribute exec ('MAH_SEARCH', 'COLUMNS', 'OBJEKTUM_NEV, KERESES_SZOVEG_1, KERESES_SZOVEG_2');
create index MAX_KERES_CTX on MAH_KERESES_MV (OBJEKTUM_NEV)
indexType is ctxsys.context
parameters ("DATASTORE MAH_SEARCH");
But the query returns no rows, although if I make the query with the 'like' operator, and then I get the results as expected:
SELECT id, OBJEKTUM_NEV
OF MAH_KERESES_MV
WHERE CONTAINS (OBJEKTUM_NEV, "C") > 0;
Can some body please help? TIA,
TamasYou can do it in Oracle Text, well it is not necessarily desirable.
You can search the
WHERE CONTAINS(OBJEKTUM_NEV, '%C%')>0;
And it will probably work in a simple test. However, using a leader like this wildcard prevents them the index on the table "list of words" used, so such a request can be very slow on a large system.
You can improve this by using SUBSTRING_INDEX, but making your much bigger index. And you could always hit the 'expansions too' problem if %C % expansion is more than about 15,000 words (depending on version and different settings).Also be aware of differences in case - %C % will match 'fact' or 'FACT', as part of a CONTAINS, but not part of a TYPE.
-
subquery returns no row in the main query, but hard returns the value of the master query
Oracle 11g, Solaris SPARC 64-bit:
This is the master query: its not to return all the lines
Select count (*) in the sadmin.usr_mods where to_char (ts_id) in ((select to_char (rtrim (ltrim(TS_MODULES,','), ',')) in the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3));
COUNT (*)
----------
0
But wherever if I use subquery only returns he lines:
SQL > select rtrim (ltrim(TS_MODULES,','), ',') from the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3;
RTRIM (LTRIM(TS_MODULES,','), ',')
--------------------------------------------------------------------------------
49,54
If I use these values as hardcoded to a select master it will return 2 rows:
SQL > select count (*) in the sadmin.usr_mods where to_char (ts_id) in ('49 ', ' 54');
COUNT (*)
----------
2
TS_MODULES datatype is CLOB
TS_ID datatype is set to number
Help, please
with
usr_rfc as
(select 3 ts_projectid, 123 ts_kintana_package_number, to_clob(',49,54,') ts_modules
of the double
),
usr_mods as
(select ts_id 49 Union double all the)
Select 50 in all double union
Select double 54
)
Select count (*)
of usr_mods
where to_char (ts_id) in (select regexp_substr (to_char (rtrim (ltrim(TS_MODULES,','), ',')),'[^,] +', 1, level))
of usr_rfc
where TS_KINTANA_PACKAGE_NUMBER = '123'
and ts_projectid = 3
connect by level<= regexp_count(to_char(rtrim(ltrim(ts_modules,','),',')),',')="" +="">=>
)
COUNT (*) 2 Concerning
Etbin
Select count (*)
of usr_mods
where instr ((select ',' | to_char (rtrim (ltrim(TS_MODULES,','), ',')) |)) ','
of usr_rfc
where TS_KINTANA_PACKAGE_NUMBER = '123'
and ts_projectid = 3
),
',' || TO_CHAR (TS_ID) | ','
) > 0
-
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 ;-)
-
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
-
SQL query returning no rows, please help!
I have a table that contains the user checks for a specific procedures alongwith the date stamp. Now, I want the list of all procedures that are not accessible by users in the last 6 months. Or, all of the procedures that have not been used/accessible during the last 6 months.
That's what I'm trying, but is does not return all rows:
SELECT DISTINCT proc_name,
TRUNC (entry_date)
OF log_web
WHERE NOT IN (SELECT proc_name proc_name
OF log_web
WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180))
ORDER BY DESC 2
Please notify.
Thank you in advance.Hello
NOT IN never returns TRUE if the subquery returns NULL values. If proc_name doesn't have a NOT NULL constraint, change the subquery to
WHERE proc_name NOT IN ( SELECT proc_name FROM log_web WHERE entry_date > TRUNC (SYSDATE - 180) AND proc_name IS NOT NULL )
I don't see any other suspect.
Post a small example of data (CREATE TABLE and INSERT statements) where the query produces results worng. -
single line sub query returns multiple rows
Hi, please help me to solve this, working with oracle 11g.
Update t1 set t1.twyindex = twypoly (select twyindex from twyinfo where t1.id = t2.id t2);
the error message is:
*
ERROR on line 1:
ORA-01427: einreihig subquery returns multiple rows
Thank youdon123 wrote:
Hi paul, thanks...duplicate existing due to the business logic data.
can I use the SQL mentioned above for all cases?
is it mandatory to remove duplicates?
Please provide your suggestions...
If the company says duplicates are allowed, you have to ask the person who wants what, of the different twyindexes, that they want to use
updating twyinfo table...I use the SQL proposed until they tell you that twyindex to use.
-
Interactive report that returns 0 rows on the initial screen of forcing
How can I get the initial display of my interactive to have 0 rows (and quickly) reports on the initial display, so that the user can determine the lines they want without having to wait for the report view without much in the way of the filters?
My reports many lines of 50-100 k with several joins of tables: so they are slow and the initial default result set is not useful for them, until they start of construction interactive filters themselves.
I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning the default #of ranks backward, THEN that wraps like a subselect and applies to the i / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...
I'm experimenting also with a flag of pxx_firsttime, intiall value, and according to my report SQL NVL(:Pxx_FIRSTTIME,'Y') = n and (rest of joins of tables)...
the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?
Thank youHello
I tried to add a default I / filter R which is never true, return 0 rows, but if I have good corrrectly, APEX will execute the sql 1, returning back by default #of lines, THEN that wraps like a subselect and applies the > I / R filters. So, I still have to wait for the report of 'run' before its filtered to 0 rows...
Yes, you are right.
I assume that you already have using the paging Type as line from X to Y.
the problem I have with this is, how can I get this option the value N as the user begins to use the interactive report filters, etc., which seem NOT to resubmit the page?
Whenever the user do something with 'Actions', APEX IR will get updated. Thus, to create a dynamic Action that will be triggered before the refreshment of your IR, update the session state from P1_FIRSTTIME_FLAG to "n".
Kind regards
Hari -
Can't understand why this query returns multiple lines with the same data
Hi all
I am a relative novice and self-taught when it comes to SQL. I wrote a query to our reporting tool that returns multiple rows, and I can't understand why. I know that I can use the SELECT DISTINCT option, but it really slows the execution when I do. I'd really rather understand if I can change the code to avoid the multiples. This is the query. I've included a few statements in italics to help explain the break. Any ideas?
SELECT MATSITE, MATPONUM, FIRSTRECPTDATE
Of
Subquery that concludes the first date on which purchase orders have been implemented with ACK State
(SELECT ACKSTAT. PONUM AS 'ACKPONUM', (MIN (ACKSTAT. CHANGEDATE)) AS 'FIRSTACKDATE '.
OF PZMAX. POSTATUS ACKSTAT
WHERE (ACKSTAT. STATE = 'ACK') AND (ACKSTAT.ORGID ='CGSALTUS)
GROUP OF ACKSTAT. PONUM),
Subquery that concludes the first reception against a purchase order transaction for purposes of comparison
(SELECT TRANS. PONUM AS "MATPONUM", TRANS. SITEID AS 'MATSITE', (MIN (TRANS. TRANSDATE)) AS 'FIRSTRECPTDATE '.
OF PZMAX. MATRECTRANS TRANS
WHERE (TRANS.ORGID ='CGSALTUS) AND (TRANS. HOUR > =: startDate and TRANS. TRANSDATE < =: endDate)
TRANS GROUP. SITEID, TRANS. PONUM)
WHERE
(ACKPONUM = MATPONUM AND FIRSTRECPTDATE < FIRSTACKDATE) OR (NOT EXISTS (SELECT 1 FROM PZMAX. POSTATUS ACKSTAT2 WHERE (ACKSTAT2. PONUM = MATPONUM) AND (ACKSTAT2. STATE = 'ACK') AND (ACKSTAT2.ORGID ='CGSALTUS)))
The where the instruction is intended to find when one of two conditions exists. ((1) received happened before the command either in ACK or 2) a reception that's happened, but the purchase order is never in ACK State. It seems that this second condition that creates multiple lines.
Any thoughts will be appreciated geratly.
Dave Teece
-
Rows in the table LT until merger of all workspaces
Database 11.2.0.4
In our environment, we ran a few important updates in the workspaces and then merged these live workspaces. Up to 25% of the data has been updated in those workspaces. When these update batch workspaces have been created, previous workspaces exist who are not yet ready for the merger.
I noticed that the underlying tables of the LT now have about 25% more lines than the live view. We have now discovered that dbms_wm.refreshWorkspace works really poor. This statement is used to take seconds or minutes to the maximum, but can now take half an hour or more.
We recorded a support with Oracle request and provided details of the plan to see if we can get some resolution/advice explaining.
In the meantime, I have a question for the forum help my understanding of the works of the Manager of the workspace.
In the example below, I have table "wm_test_table", "test_workspace1" and "test_workspace2". In "test_workspace1", I update all rows in the table - the table LT now has 2 rows for each record. I merge 'test_workspace1' live and LT still has 2 rows for each record. The other lines are not removed until "test_workspace2" is merged and removed.
SQL> -- Create a test table SQL> create table wm_test_table ( 2 id integer primary key, 3 name varchar2(100)); Table created. SQL> -- Insert 1,000 rows SQL> insert into wm_test_table ( 2 select rownum, 'before' 3 from dual 4 connect by level <= 1000); 1000 rows created. SQL> commit; Commit complete. SQL> -- Version enable it SQL> execute dbms_wm.enableVersioning('wm_test_table'); PL/SQL procedure successfully completed. SQL> -- Create two workspaces SQL> execute dbms_wm.createWorkspace('test_workspace1'); PL/SQL procedure successfully completed. SQL> execute dbms_wm.createWorkspace('test_workspace2'); PL/SQL procedure successfully completed. SQL> -- Go to test_workspace1 and update all the rows SQL> execute dbms_wm.goToWorkspace('test_workspace1'); PL/SQL procedure successfully completed. SQL> update wm_test_table set name = 'after'; 1000 rows updated. SQL> commit; Commit complete. SQL> -- Check how many rows in wm_test_table_lt - we expect 2,000 as we haven't merged yet SQL> select count(*) from wm_test_table_lt; COUNT(*) ---------- 2000 SQL> -- Merge and remove test_workspace1 SQL> execute dbms_wm.goToWorkspace('LIVE'); PL/SQL procedure successfully completed. SQL> execute dbms_wm.mergeWorkspace('test_workspace1', remove_workspace=>true); PL/SQL procedure successfully completed. SQL> -- Check how many rows in wm_test_table_lt SQL> -- I'd hope there'd only be 1,000 but there is 2,000 SQL> select count(*) from wm_test_table_lt; COUNT(*) ---------- 2000 SQL> -- Let's see if compressWorkspace will get rid of them SQL> execute dbms_wm.compressWorkspace( - > workspace => 'LIVE', - > auto_commit => true, - > remove_latest_deleted_rows => true); PL/SQL procedure successfully completed. SQL> -- They're still there SQL> select count(*) from wm_test_table_lt; COUNT(*) ---------- 2000 SQL> -- Now merge test_workspace2 SQL> execute dbms_wm.mergeWorkspace('test_workspace2', remove_workspace=>true); PL/SQL procedure successfully completed. SQL> -- and the additional 1,000 rows are removed SQL> select count(*) from wm_test_table_lt; COUNT(*) ---------- 1000
Is it possible to safely remove the extra lines in LT without waiting until we merged the workspaces that existed before the update batch has been done? I hope that it will so improve the performance of refreshWorkspace.
I thought that something like this can do, but it does not remove the other ranks, is:
execute dbms_wm.PurgeTable( table_id => 'test.wm_test_table', archive_table => null, where_clause => 'id not in (select id from test.wm_test_table)', instant=>null, workspace => 'LIVE', purgeAfter => false);
This question is similar to
Lines left in the table LT after removal of the direct workspace and the removal of all workspaces
and
but I'm still not sure.
Thank you
John
Hello
This behavior is expected and it is due to the test_workspace2 workspace. A compression operation will not allow compressed range to include a backup implicit point that is created for a child workspace. This is done to preserve the integrity of this workspace. The initial 1000 lines are all lines that are visible from test_workspace2. Removal of these lines would leave test_workspace2 will 0 lines in there. Lines 1000 updates are the lines that do not appear on LIVE. So, given that the two sets of lines are needed, none of the lines can be deleted physically. A compression operation will never change the view of data for any workspace. It only removes the unnecessary records. The two options in order to be able to compress these lines is to either delete (as you did) or refresh test_workspace2. The refresh operation would move the implicit savepoint for the workspace to a version that isn't after all 2000 lines in the table _LT and allow the dressing to remove first half of them because they are no longer needed by any child workspace.
With respect to the performance of RefreshWorkspace, I would need to see a trace of the transaction file. But who should rather get through the SR you filed.
Kind regards
Ben
-
Rows from the outer Table shows only not all data.
Hello
I have a line to 80 characters that I import in an external table.
80% imports fine line data, but some lines are cut.
The bytes in the file are as follows.
ABCABC2334 0000001000010000001000000001 000000 00001C A002
Bytes in an external table.
ABCABC2334 0000001000010000001000000001 000000 A002
The bytes in the row of the outer table stop somewhere at the end of 000000 and the 00001C is cut.
What build be the cause of this?
I am able to read the characters at the beginning and towards the end of the record of 80-character line.
The external file below performs the following operations.
ABCABC2334 0000001000010000001000000001 000000 01B A002
I can even make a definition of the external table (c1 char (1), c2 char (1),... c80 (1) tank and all the characters see fine in the specified columns.)
Here is the last definition of the external table. The "middle" column still shows this behavior. Basically, it is in the file and can be seen with every character in the definined line, but not as a group of characters.
DB CHARACTERSET WEBISO8859P1
CREATE TABLE EXT_PROJ_1
(
Field1 tank (6 BYTES),
Field2 float (4 BYTES),
medium (67 BYTES)
field3 tank (3 bytes),
CR tank (2 bytes)
)
EXTERNAL ORGANIZATION
(TYPE ORACLE_LOADER
THE DEFAULT DIRECTORY EXP_DIR
ACCESS SETTINGS
(
RECORDS delimited by '\r\n '.
FIELDS (field1, position(1:6),
position(7:10) Field2.
average position(11:77)
field3 position(78:80).
CR position(81:82)
)
)
LOCATION (EXP_DIR: 'ext_proj_1.txt')
)
REJECT THE LIMIT 1
noPARALLEL
NOMONITORING;
Published by: 917320 on March 13, 2012 09:07Looking at your table definition:
field1 char(6 BYTE), field2 char(4 BYTE), middle char(67 BYTE), field3 char(3 byte), cr char(2 byte)
column in which you will store a string of 80 bytes?
BTW: You said "import into an external table." You import FROM an external table or EXPORT to an external table?
Maybe you are looking for
-
For these past few days, whenever I open Firefox, I get "well, this is awkward!" Firefox has struggle to recover your windows and tabs. I'm on version 20.0 on an IMac with Mountain Lion. I don't want back windows or tabs. I still have to close everyt
-
No CD/DVD drive after upgrade of Windows 8 on Satellite Pro S300L
The cd Rom drive no longer works after upgrade to Windows 8.The drive is not displayed in the Solution Explorer, either. It is mentioned: error in the register. I can not change the right driver in Device Manager - probably it was deleted.Is the driv
-
Vertical lines on the Qosmio G10
My Qosmio G10 have vertical lines on the screen even on monitor external it show the same problems, tried to reformat using the supplied media center disc have the same problem also, system hangs when installing the video driver, try Booting to CD bo
-
Should what development environment I use?
Environment: 32-bit Windows 7, latest development environment Sun's Java, Visual Studio 8 most recent plugin beta BlackBerry 9700 Simulator works very well in the white list remote .NET/ASP/SQL Server 2008 to use as remote as possibly .asp page direc
-
C310 Cougar driver - Missing the Photo Tray printing Option?
I have used my C310 on my previous Mac using OS x v10.5 and had the photo of the photo tray printing option. I bought a new iMac with OSX v10.8 Mountain Lion. The CD that accompanies the C310 supports only OSX 10.5 and 10.6. So I was on the web and d