Nested to decode
Hi All-I have a requirement where I need to convert a nested in a case statement decode statement here's the scenario
CASE WHEN CD_FAM_01 = "Y" THEN ' N
WHEN CD_FAM_02 = 'Y', AND THEN 'Y '.
WHEN CD_FAM_03 = 'Y', AND THEN 'Y '.
WHEN CD_FAM_04 = 'Y', AND THEN 'Y '.
WHEN CD_FAM_05 = 'Y', AND THEN 'Y '.
WHEN CD_FAM_01 IS SET TO NULL, AND CD_FAM_02 IS SET TO NULL AND CD_FAM_03 IS SET TO NULL AND CD_FAM_04 IS SET TO NULL AND CD_FAM_05 IS NULL THEN 'N.'
WHEN CD_FAM_01 = ' no AND CD_FAM_02 = ' no AND CD_FAM_03 = 'N AND CD_FAM_04 =' N AND CD_FAM_05 = 'No THEN' don't END
I am facing a moment torrid in the conversion of this instruction can help me here
SQL> create table ca_test (cd_fam_01 VARCHAR2(1),cd_fam_02 VARCHAR2(1),cd_fam_03 VARCHAR2(1),cd_fam_04 VARCHAR2(1),cd_fam_05 VARCHAR2(1));
Table created.
Elapsed: 00:00:00.02
SQL>
SQL> insert into ca_test VALUES ('Y','Y','Y','Y','Y');
1 row created.
Elapsed: 00:00:00.02
SQL> insert into ca_test VALUES ('N','Y','Y','Y','Y');
1 row created.
Elapsed: 00:00:00.02
SQL> insert into ca_test VALUES ('N','N','Y','Y','Y');
1 row created.
Elapsed: 00:00:00.02
SQL> insert into ca_test VALUES ('N','N','N','Y','Y');
1 row created.
Elapsed: 00:00:00.02
SQL> insert into ca_test VALUES ('N','N','N','N','Y');
1 row created.
Elapsed: 00:00:00.01
SQL> insert into ca_test VALUES ('N','N','N','N','N');
1 row created.
Elapsed: 00:00:00.01
SQL> insert into ca_test VALUES (null,null,null,null,null);
1 row created.
Elapsed: 00:00:00.00
SQL> insert into ca_test VALUES ('N','N','N',null,null);
1 row created.
Elapsed: 00:00:00.00
SQL>
SQL> SELECT
2 cd_fam_01
3 ,cd_fam_02
4 ,cd_fam_03
5 ,cd_fam_04
6 ,cd_fam_05
7 ,DECODE
8 (CD_FAM_01,'Y','N'
9 ,DECODE
10 (CD_FAM_02,'Y','Y'
11 ,DECODE
12 (CD_FAM_03,'Y','Y'
13 ,DECODE
14 (CD_FAM_04,'Y','Y'
15 ,DECODE
16 (CD_FAM_05,'Y','Y'
17 ,DECODE
18 (COALESCE
19 (CD_FAM_01
20 ,CD_FAM_02
21 ,CD_FAM_03
22 ,CD_FAM_04
23 ,CD_FAM_05),NULL,'N'
24 ,DECODE
25 (GREATEST(CD_FAM_01
26 ,CD_FAM_02
27 ,CD_FAM_03
28 ,CD_FAM_04
29 ,CD_FAM_05),LEAST(CD_FAM_01
30 ,CD_FAM_02
31 ,CD_FAM_03
32 ,CD_FAM_04
33 ,CD_FAM_05),DECODE(GREATEST
34 (CD_FAM_01
35 ,CD_FAM_02
36 ,CD_FAM_03
37 ,CD_FAM_04
38 ,CD_FAM_05),'N','N'))))))))
39 FROM ca_test
40 /
C C C C C D
_ _ _ _ _ _
Y Y Y Y Y N
N Y Y Y Y Y
N N Y Y Y Y
N N N Y Y Y
N N N N Y Y
N N N N N N
N
N N N
8 rows selected.
Elapsed: 00:00:00.02
Sounds good? Furthermore, why are you doing this? The case statement is surely preferable.
Tags: Database
Similar Questions
-
Nesting help DECODE statements
Hello. I'm writing a sql script to generate the data for payments report. I need to integrate specific to the field of ADDRESS VACUUM lines to REMOVE conditions. I'm using Address_Line1, Address_Line2, Address_Line3, most CITY, STATE, ZIP as Address_Line4. If all fields are empty, I need to remove the blank line and back up the other lines.
Here is my if, THEN, ELSE conditions. There are 9 possible scenarios that I have identified. Can you please help me write this in SQL with the DECODE function?
IF CITY||STATE||ZIP IS NULL THEN AD1='12115 Rainbow Road', AD2='Hartford Heights, MO 60226' ELSE IF ADDRESS_LINE1 IS NULL IF ADDRESS_LINE2 IS NULL IF ADDRESS_LINE3 IS NULL THEN USE HOME ADDRESS ELSE vAD1=ADDRESS_LINE3, vAD2=CITY||STATE||ZIP ENDIF ELSE IF ADDRESS_LINE3 IS NULL THEN vAD1=ADDRESS_LINE2, vAD2 = CITY||STATE||ZIP ELSE vAD1=ADDRESS_LINE2, vAD2=ADDRESS_LINE3, vAD3=CITY||STATE||ZIP ENDIF ENDIF ELSE IF ADDRESS_LINE2 IS NULL IF ADDRESS_LINE3 IS NULL THEN vAD1=ADDRESS_LINE1, vAD2=CITY||STATE||ZIP ELSE vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE3, vAD3=CITY||STATE||ZIP ENDIF ELSE IF ADDRESS_LINE3 IS NULL THEN vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE2, vAD3=CITY||STATE||ZIP ELSE vAD1=ADDRESS_LINE1, vAD2=ADDRESS_LINE2, vAD3=ADDRESS_LINE3, vAD4=CITY||STATE||ZIP ENDIF ENDIF ENDIF ENDIF
This what I've got so far... DECLARE vADR1 vADR2 vADR3 vADR4 BEGIN SELECT DECODE( END; /
Hello
Interplay says:
...
Here's the script:WITH got_delimited_list AS ( SELECT address_line1 || ' +' || address_line2 || ' +' || address_line3 || ' +' || ...
This is equivalent to
SELECT (address_line1 || ' ') || '+' || (address_line2 || ' ') || '+' || (address_line3 || ' ') || '+' || ...
You are guaranteeing to all areas will result in a space, and therefore may not be NULL.
Lose the spaces before the signs +:SELECT address_line1 || '+' || address_line2 || '+' || address_line3 || '+' || ...
Published by: Frank Kulash on Feb 3, 2010 10:04
Sorry, my fault. My original post had this error. -
A consolidated using nested decode question
Hi Experts,
I have a requiement as I am trying to solve by nested to decode, but it gives bad result for certain values. I will be grateful for pointers on it. Here's the whole upward for a test case:create table test (emp_id varchar2 (20), name varchar2 (20), e-mail varchar2 (100));
insert into test values ('1 ', 'a',' [email protected]');
insert into test values ('2 ', null,' [email protected]');
Insert test values ('3 ', null, null);
commit;
The requirement is to print the name if it is not null. If it is null then print email. If the email is also null then print emp_id.
Here is what I tried:
select decode(decode(name,null,nvl(email,'xxx')),'xxx',emp_id) from test where emp_id='3';
But this gives a null value for emp_id ' 2 'and ' 1'. I don't know where I am going wrong. Please suggest.
Thank you
Hello
If you want to know why the phrase DECODE you posted does not work, it helps to format your code.
Select decode (decoding (name
null
nvl (email, "xxx")
)
, "xxx."
emp_id
)
of the test
where emp_id = '3'
;
This makes it easy to see that the outward expression of DECODE has only 3 arguments. This means that it will always return NULL or 3rd argument (emp_id). Clearly, this isn't what you want: you want an expression that sometimes will return name and email, sometimes too.
As mentioned above, COALESCE seems to be the best way to do what you want.
Nested NVLs would be another (but of course lower) way.
CASE is also better than DECODE.
The following query shows how to get the same results in all these ways:
SELECT NVL (name
NVL (e-mail
emp_id
)
) AS n
CASE
WHEN the name IS NOT NULL, THEN name
WHEN an email IS NOT NULL THEN an email
Emp_id ELSE
END AS c
DECODE (name,
, NULL, DECODE (e-mail
NULL, emp_id
E-mail
)
name
) AS d
OF the test
;
Again, I recommend COALESCE for this work.
-
Reg: filtering table nested
Hi Experts,
I have a table_week, whose structure is:
create table table_week)
filter_no,
d_mon char (1),
d_tue char (1),
d_wed char (1),
d_thu char (1),
d_fri char (1),
d_sat char (1),
d_sun char (1)
);
"For every FILTER_NO, it stores a 'Y' or ' n ', in the rest of the columns i.e. D_ * D_MON, D_TUE, etc.
Now, I need to fill out another nested table that contains just a few days that were marked as 'Y '.
Let's say, for FILTER_NO = 99, table record looks like: 99 O N O N O N N
Output - A nested table whose value ('Monday', 'Wednesday', 'Friday')
declare
V_1 varchar2 (20);
V_2 varchar2 (20);
V_3 varchar2 (20);
v_4 varchar2 (20);
VARCHAR2 (20) v_5.
v_6 varchar2 (20);
v_7 varchar2 (20);
type nt_type is table of the varchar2 (20);
NT nt_type;
NT1 nt_type: = nt_type();
Start
Select
Decode (d_mon, 'Y', 'Monday', 'x'),
Decode (d_tue, 'Y', 'Tuesday', 'x'),
Decode (d_wed, 'Y', 'Wednesday', 'x'),
Decode (d_thu, 'Y', 'Thursday', 'x'),
Decode (d_fri, 'Y', 'Friday', 'x'),
Decode (d_sat, 'Y', 'Saturday', 'x'),
Decode (d_sun, 'Y', 'Sunday', 'x')
in v_1, v_2, v_3, v_4, v_5, v_6, v_7
of table_week
where filter_no = 99; -/ / Some filter no.
NT: = nt_type (v_1, v_2, v_3, v_4, v_5, v_6, v_7);
because me in 1.nt.count
loop
. . .
end loop;
end;
Thank you and best regards,
-Nordine
(on Oracle 11.2.0.4.0)
SQL> declare 2 3 type nt_type is table of varchar2(20); 4 my_nt nt_type; 5 6 begin 7 8 select day_name 9 bulk collect into my_nt 10 from table_week 11 unpivot ( 12 day_flag for day_name in ( 13 d_mon as 'Monday' 14 , d_tue as 'Tuesday' 15 , d_wed as 'Wednesday' 16 , d_thu as 'Thursday' 17 , d_fri as 'Friday' 18 , d_sat as 'Saturday' 19 , d_sun as 'Sunday' 20 ) 21 ) 22 where filter_no = 99 23 and day_flag = 'Y'; 24 25 for i in 1 .. my_nt.count loop 26 dbms_output.put_line(my_nt(i)); 27 end loop; 28 29 end; 30 / Monday Wednesday Friday PL/SQL procedure successfully completed.
-
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
-
Hi all
Can I use function decode/inner carton of a decoding function?
{code}
SELECT TO_CHAR)
() EDMS_STRAGG_WC
DISTINCT DECODE)
EQS.attrib_code,
'PRODUCT_AUTHORIZATION', ' permission: '
|| CASE eqs.qual_value
WHEN "LIST".
THEN
(SELECT lookup_desc
OF edmsadm.edms_lookup
WHERE lookup_type =
'PARTNER_AUTHORIZATION '.
AND lookup_code =
EQLS.list_value)
ON THE OTHER
(SELECT lookup_desc
OF edmsadm.edms_lookup
WHERE lookup_type =
'PARTNER_AUTHORIZATION '.
AND lookup_code =
EQS.qual_value)
END,
'PRODUCT_CERTIFICATION', ' Certification: '
|| CASE eqs.qual_value
WHEN "LIST".
THEN
EQLS.list_value
ON THE OTHER
EQS.qual_value
END,
'PRODUCT_SPECIALIZATION', ' specialization: '
|| (SELECT lookup_desc
OF edmsadm.edms_lookup
WHERE lookup_type =
'PARTNER_SPECIALIZATION '.
AND lookup_code =
CASE eqs.qual_value
WHEN "LIST".
THEN
EQLS.list_value
ON THE OTHER
EQS.qual_value
END)))
program_value
Of edms_qual_stg EQS edms_qual_list_stg eqls
WHERE 1 = 1
AND eqs.qual_id = eqls.qual_id (+)
AND eqs.req_id = 192647
AND eqs.disc_line_id = 598631
AND IN eqs.attrib_code
("PRODUCT_CERTIFICATION",
"PRODUCT_AUTHORIZATION,"
"PRODUCT_SPECIALIZATION");
{code}
Edms_qual_stg:
AND_OR_CONDITION
ATTRIBUTE_SOURCE
ATTRIB_CODE
CREATED_BY
CREATED_DT
DISC_LINE_ID
END_DT
EXCLUDE_INCLUDE
GROUP_AND_OR_CONDITION
GROUP_CODE
MAX_VALUE
MIN_VALUE
MODIFIED_BY
MODIFIED_DT
QUAL_APPL_PRECEDENCE
QUAL_ID
QUAL_OPERATOR
QUAL_TYPE
QUAL_VALUE
REQ_ID
START_DT
Edms_qual_list_stg:
ATTRIBUTE_SOURCE
ATTRIB_CODE
CREATED_BY
CREATED_DT
END_DT
INCLUDE_AFFILIATES
INCLUDE_EXCLUDE
LIST_VALUE
MODIFIED_BY
MODIFIED_DT
PRIMARY_PARTY
QUAL_ID
QUAL_LIST_ID
REFERENCE_ID
START_DT
Edms_lookup:
CREATED_BY
CREATED_DT
DISPLAY_SEQ
EDMS_LOOKUP_ID
END_DATE
LOOKUP_CODE
LOOKUP_DESC
LOOKUP_REFERENCE
LOOKUP_TYPE
MODIFIED_BY
MODIFIED_DT
START_DATE
SELECT eqs.qual_id, eqs.disc_line_id, eqs.req_id, eqs.attrib_code, eqs.qual_value, eqls.list_value
Of edms_qual_stg EQS edms_qual_list_stg eqls
WHERE 1 = 1
AND eqs.qual_id = eqls.qual_id (+)
AND disc_line_id = 598631
AND req_id = 192647
AND IN eqs.attrib_code
("PRODUCT_CERTIFICATION",
"PRODUCT_AUTHORIZATION,"
"PRODUCT_SPECIALIZATION");
7509575 598631 192647 PRODUCT_CERTIFICATION LIST
7509575 598631 192647 PRODUCT_CERTIFICATION SILVER LIST
7509576 598631 192647 PRODUCT_AUTHORIZATION ATP - JOULEX ESCO PROVIDER LIST
7509576 598631 192647 PRODUCT_AUTHORIZATION ATP - JOULEX PROVIDER LIST IDENTIFY
7509577 598631 192647 PRODUCT_SPECIALIZATION LIST ADVANCED SECURITY
7509577 598631 192647 PRODUCT_SPECIALIZATION LIST EXPRESS FOUNDATION
Power required:
Certification: GOLD, SILVER, authorization: - JOULEX PROVIDER ESCO, ATP - ATP JOULEX PROVIDER IDENTIFIER, SPECIALIZATION: SECURITY ADVANCED, EXPRESS FOUNDATION.
THX
Rod.
Hello
Of course; an expression to DECODE or CASE that returns a NUMBER can be used anywhere a NUMBER is provided, including within another expression to DECODE or CASE. A DECODE or CASE expression that returns that a DATE can be used almost anywhere, a DATE is scheduled, including within another expression to DECODE or CASE. An expression to DECODE or CASE that returns that a VARCHAR2 can be used almost anywhere a VARCHAR2 is scheduled. (There are a few situations where it is absolutely a string literal).
There are not many situations where you really need to do this, however. It is generally simpler and more effective to use a simple CASE expression; nesting is seldom necessary.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.Simplify the problem as much as possible, so that it contains only enough to show the part you don't already know how.
If you really need a user-defined function to show the problem, and then include a CREATE FUNCTION statement to explain what the function. Yet once again, simplify: If the function is not what you do not understand, post a problem that does not use the service.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002
-
I would like to write a nested case, possible?
case case tool='icd 'then drop_trigger else ch_doc_id end case tool <> 'icd' then ch_doc_id else drop_trigger end end,
Something like this:
SQL> ed Wrote file afiedt.buf 1 with t as (select 'xxx' tool,1 first_field,2 second_field from dual 2 union select 'yyy',3,4 from dual) 3 SELECT (CASE DECODE(tool,'xxx',tool,'@@@') 4 WHEN 'xxx' 5 THEN first_field 6 WHEN '@@@' 7 THEN second_field 8 END) flds 9* from t SQL> / FLDS ---------- 1 4 SQL> SQL> ed Wrote file afiedt.buf 1 with t as (select 'xxx' tool,1 first_field,2 second_field from dual 2 union select 'yyy',3,4 from dual) 3 SELECT (CASE tool 4 WHEN 'xxx' 5 THEN first_field 6 ELSE 7 second_field 8 END) flds 9* from t SQL> / FLDS ---------- 1 4 SQL>
Published by: AP on November 17, 2010 03:22
-
Need help with JSON.decode
I get a query response JSON with about 4 deep layers of value of nested objects I need to pierce the. The JSON.decode examples that I find online are very simple and use it and the old syntax which is taken in charge in Flex 4.5.
I was hoping that someone here could give me a tip or two to extract the values of 'html_instructions' of a JSON result like this:
{
"status": "OK."
"routes": [{}
'Summary': ' US-97 S and S I-5.
"legs": [{}
'steps': [{}
"travel_mode": "En ROUTE."
'start_location': {}
"lat": 45.6692700,
"lng" :-118.8421500
},
'end_location': {}
"lat": 45.6697700,
"lng" :-118.8456500
},
'polyline': {}
"points": "{} wvuGljjtUJ'@DjBuBlP", "
'levels': ' B? B ".
},
'Time': {}
'value': 26,.
"text": "1 min".
},
"html_instructions': ' head \u003cb\u003esouthwest\u003c/b\u003e on \u003cb\u003eMcKennon Rd\u003c / b\u003e to \u003cb\u003eSW Bartsch Rd/Co 1304 Rd\u003c/b\u003e."
'distance': {}
'value': 284.
'text': '0.2 mi.
}
}, {
"travel_mode": "En ROUTE."
'start_location': {}
"lat": 45.6697700,
"lng" :-118.8456500
},
'end_location': {}
"lat": 45.6700400,
"lng" :-118.8466500
},
'polyline': {}
'points': ' a {vuGh'ktUWrAIjASf @ ',} ".
'levels': ' B? B ".
},
'Time': {}
'value': 10,.
"text": "1 min".
},
"html_instructions': ' go straight on \u003cb\u003eSW Bartsch Rd/Co 1304 Rd\u003c/b\u003e."
'distance': {}
'value': 85,.
"text": "279 ft.
}
}}
} ]
}Thanks a lot, a lot in advance!
Hello
As I'm not sure of what api that you use to decode json: once convert you the object info you are looking for is available as:
JSON.routes [0] .legs [0]. Steps [0] .html_instructions
or:
JSON.routes [N] .legs [N]. Steps [N] .html_instructions
Where N is the length of the data "json" and the table is loaded data object, the more
Kind regards
Peter
-
Partition pruning, nested loops
Hello
I'm having a problem with obtaining the size of partition in a query. I managed to dumb down the problem to the two tables and a minimum query (see below).
Basically I have a partitioned table "Made each year" and a table of assistance 'Current year' that contain always 1 row. The sole purpose of this line is to say which is the year curent, it was the previous year and that next year will be. (In the real problem, there is no standard timeperiods, so we can't calculate just previous and next by adding/subtraction 1 as would be possible in this example).
The following query is executed as I want.
It runs a scan on current_year and then nested loop on the facts. And the size of the partition that was happening.
The following query is where I have my problem.select sum(decode(a.year_key, b.curr_year, some_measure)) as curr_year_measure from yearly_fact_t a ,current_year b where a.year_key = b.curr_year; ------------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ------------------------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 39 | 4 (0)| 00:00:01 | | | | 1 | SORT AGGREGATE | | 1 | 39 | | | | | | 2 | NESTED LOOPS | | 1 | 39 | 4 (0)| 00:00:01 | | | | 3 | INDEX FAST FULL SCAN | SYS_C00247890 | 1 | 13 | 2 (0)| 00:00:01 | | | | 4 | PARTITION RANGE ITERATOR| | 1 | 26 | 2 (0)| 00:00:01 | KEY | KEY | |* 5 | TABLE ACCESS FULL | YEARLY_FACT_T | 1 | 26 | 2 (0)| 00:00:01 | KEY | KEY | ------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 5 - filter("A"."YEAR_KEY"="B"."CURR_YEAR")
The xplan base is the same, but for some reason any cbo abandoned and decide to analyze all the partitions, which was not highly scalable data on production :)
I would have thought that the plan would be the same.
select sum(decode(a.year_key, b.curr_year, some_measure)) as curr_year_measure ,sum(decode(a.year_key, b.prev_year, some_measure)) as prev_year_measure from yearly_fact_t a ,current_year b where a.year_key = b.curr_year or a.year_key = b.prev_year; ------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 52 | 13 (0)| 00:00:01 | | | | 1 | SORT AGGREGATE | | 1 | 52 | | | | | | 2 | NESTED LOOPS | | 4 | 208 | 13 (0)| 00:00:01 | | | | 3 | TABLE ACCESS FULL | CURRENT_YEAR | 1 | 26 | 4 (0)| 00:00:01 | | | | 4 | PARTITION RANGE ALL| | 4 | 104 | 9 (0)| 00:00:01 | 1 | 6 | |* 5 | TABLE ACCESS FULL | YEARLY_FACT_T | 4 | 104 | 9 (0)| 00:00:01 | 1 | 6 | ------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 5 - filter("A"."YEAR_KEY"="B"."CURR_YEAR" OR "A"."YEAR_KEY"="B"."PREV_YEAR")
What can I do to get the size of partition that you want to occur in the second query?-- drop table yearly_fact_t purge; -- drop table current_year purge; create table current_year( curr_year number(4) not null ,prev_year number(4) not null ,next_year number(4) not null ,primary key(curr_year) ,unique(prev_year) ,unique(next_year) ); insert into current_year(curr_year, prev_year, next_year) values(2010, 2009, 2011); commit; create table yearly_fact_t( year_key number(4) not null ,some_dim_key number not null ,some_measure number not null ) partition by range(year_key)( partition p2007 values less than(2008) ,partition p2008 values less than(2009) ,partition p2009 values less than(2010) ,partition p2010 values less than(2011) ,partition p2011 values less than(2012) ,partition pmax values less than(maxvalue) ); insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2007,1, 10); insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2008,1, 20); insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2009,1, 30); insert into yearly_fact_t(year_key, some_dim_key, some_measure) values(2010,1, 40); commit;
Or better yet, what is it in my query that prevents it from happening?
We do not have Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit.
Best regards
RonnieI think that the decision of condition influenced gold optimizer. You can rewrite your query to use UNION ALL to see if it helps.
select sum(decode(year_key, curr_year, some_measure)) as curr_year_measure ,sum(decode(year_key, prev_year, some_measure)) as prev_year_measure from (select a.year_key, b.curr_year, some_measure from yearly_fact_t a ,current_year b where a.year_key = b.curr_year UNION ALL select a.year_key, b.curr_year, some_measure from yearly_fact_t a ,current_year b where a.year_key = b.prev_year);
Published by: user503699 on February 17, 2010 14:59
-
Decode the statement inside the box
Can we use Decode statement inside a CASE statement as below - show
It gives an error - the better to write with any error
create or replace
test run (a varchar2) RETURN VARCHAR2
is
m varchar2 (20);
Start
m : =
CASE
WHEN a (IN)
'1009 '-(soon obsolete)
"1010"
, ' 1019 "
'1051'
, "XGP.
"XSC")
(SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') in the of THE DOUBLE m)
(-) THEN '01' - UNITED STATES
WHEN a (IN)
' 1069' - South Africa
, "SAO" - South Africa
, 'HIS' - South Africa
) THEN '26' - South Africa
ANOTHER NULL
END;
return m;
end;Hello
user575932 wrote:
Thanks for your reply... I would be happy if my problem is completely resolvedIn the code below in the ELSE part... (When the value NULL is written) I have check for more condition using IF/ELSE or DECODE...
SQL > l
1 DECLARE
v_var1 2 VARCHAR2 (20);
3 model VARCHAR2 (20): = 'X '.
4 BEGIN
v_var1 5: = dummy BOX WHEN ('X', 'y')
6 THEN CASE model WHEN = 'X' THEN 'HELLO WORLD '.
7. OTHER SIDE (_ NULL);
8 DBMS_OUTPUT. Put_line (v_var1);
9 END;
10.Sorry, it's impossible. You cannot place the executable statements in PL/SQL (as IF...) ELSE or SELECT... INTO) in the middle of the CASE expression.
You can get some desired using the results
(1) IF... Else constantly, instead of CASE (this would allow you to do a SELECT... If you really want to use DECODE INTO), or
(2) nested CASE expressions, as I showed above, or by
(3) reformulating the expression BOX so it shouldn't be a nested DECODE or CASE, as I showed earlier -
DECODE statement and the argument limits
No one knows the number of arguments that the DECODE statement allows you to enter. I currently have 863 and it gives me an error message when I try to run the query.
Database - ORA-00939 error: too many arguments for the function.
Thank you
ChrisHello
You still have too many parameters your decodes, the limit is 250 so you can enter only 124 values and decoded. I would like to nest decodes by doing:
DECODE (point, "c1", "v1", "c2", "v2", "c3", "v3",..., DECODE (point, 'c4', 'v4', 'c5', 'v5', 'c6', 'v6',..., DECODE (...)))
Alternatively, you can for example use case
WHEN BOX point IN (
END) Rod West
-
DECODE is changing the explain plan
I have a statement with a decoding function in the where clause like this:
When I have a package-1 as parameter for cropgroup the filter would result by ' AND '-1' = '-1', and the statement is executed in less than 2 seconds.»»» When I leave this where clause it takes almost 18 seconds. The result is the same so I don't understand why the explain plan command is so different and why not use index scans in the statement without decoding.AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
Below plans to explain and tkprofs to 1 (no decode) and 2 (decode).
* explain 1 *.
{code}
SQL statement that produced these data:
Select * from table (dbms_xplan.display)
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU).
---------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | 7080 | 2413K | 43611 (2) |
| 1. SORT ORDER BY | 7080 | 2413K | 5224K | 43611 (2) |
|* 2 | FILTER |
|* 3 | HASH JOIN | 7156. 2 438 K | 43075 (2) |
| 4. TABLE ACCESS FULL | DWH_ABS_DETERMINATION | 17745. 363KO | 83 (0) |
|* 5 | OUTER HASH JOIN | 7156. 2292K | 42991 (2) |
|* 6 | HASH JOIN | 7156. 1355K | 42907 (2) |
|* 7 | HASH JOIN | 6987. 1187K | 19170 (2) |
|* 8 | HASH JOIN | 6947 | 963K | 10376 (1) |
|* 9 | TABLE ACCESS BY INDEX ROWID | ALIQUOT | 3. 144. 3 (0) |
| 10. NESTED LOOPS | 6907. 897K | 8577 (1) |
| * 11 | HASH JOIN | 2264 | 187K | 1782 (2) |
| 12. TABLE ACCESS BY INDEX ROWID | SAMPLE | 190. 4370. 17 (0) |
| 13. NESTED LOOPS | 2264 | 152K | 107 (1) |
| 14. NESTED LOOPS | 12. 552. 25 (0) |
| * 15 | TABLE ACCESS FULL | SDG_USER | 12. 288. 13 (0) |
| 16. TABLE ACCESS BY INDEX ROWID | SDG | 1. 22. 1 (0) |
| * 17. INDEX UNIQUE SCAN | PK_SDG | 1 | | | 0 (0) |
| * 18. INDEX RANGE SCAN | FK_SAMPLE_SDG | 597. 2 (0) |
| 19. TABLE ACCESS FULL | SAMPLE_USER | 1078K | 16 M | 1669 (1) |
| * 20. INDEX RANGE SCAN | FK_ALIQUOT_SAMPLE | 3 | | | 2 (0) |
| 21. TABLE ACCESS FULL | ALIQUOT_USER | 3403K | 29 M | 1781 (3) |
| 22. TABLE ACCESS FULL | TEST | 3423K | 104 M | 8775 (2) |
| * 23. TABLE ACCESS FULL | RESULT | 3435K | 65 M | 23718 (2) |
| 24. VIEW | PLATE | 21787 | 2851K | 84 (2).
| * 25. FILTER |
| 26. TABLE ACCESS FULL | PLATE | 21787 | 574K | 84 (2).
| * 27. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
| * 28. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
| * 29. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
| * 30 | INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
| * 31. INDEX UNIQUE SCAN | PK_OPERATOR_GROUP | 1. 7 | | 0 (0) |
---------------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
2. ((«GROUP_ID» EST NULL ou EXISTE (SELECT / * + * / 0 DE "AGIL".) filter)) "OPERATOR_GROUP"
"OPERATOR_GROUP' WHERE ' OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "GROUP_ID" =:B1)) AND ('GROUP_ID' IS NULL) "'". "
OR EXISTS (SELECT / * + * / 0 "LIMS".) ' ' OPERATOR_GROUP ' 'OPERATOR_GROUP' WHERE
"OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "GROUP_ID" =:B2)) AND ('GROUP_ID' IS NULL OR EXISTS (SELECT / * +)) "" "."
* / 0 "LIMS". "' OPERATOR_GROUP ' 'OPERATOR_GROUP' WHERE ' OPERATOR_ID"="LIMS$ OPERATOR_ID" () AND "."
(('GROUP_ID' =: B3)) AND ('GROUP_ID' IS NULL OR EXISTS (SELECT / * + * / 0 "LIMS".)) "" OPERATOR_GROUP ".
'OPERATOR_GROUP' WHERE ' OPERATOR_ID "=" LIMS$ OPERATOR_ID "() AND"GROUP_ID "=:B4)))".
3 - access ("U_ABS_DETERMINATION" ="DETERMINATION_ASSIGNMENT")
5 - access("PLT".") PLATE_ID"(+) ="PLATE_ID")
6 - access ("TEST_ID" ="TEST_ID")
7 - access ("ALIQUOT_ID" ="ALIQUOT_ID")
8 - access ("ALIQUOT_ID" ="ALIQUOT_ID")
9 - filter("STATUS"='C' OR "STATUS"='P' OR "STATUS"='V')
11 - access ("SAMPLE_ID" ="SAMPLE_ID")
15 - filter ("U_ABS_DETERMINATION" IS NOT NULL AND "U_CLIENT_TYPE" = 'QC' AND
"U_WEEK_OF_PROCESSING"= TO_NUMBER(:WEEK) AND "U_YEAR_OF_SAMPLE_DELIVERY' = TO_NUMBER (:YEAR)).
17 - access ("SDG_ID" ="SDG_ID")
18 - access ("SDG_ID" ="SDG_ID")
20 - access ("SAMPLE_ID" ="SAMPLE_ID")
23 - filter ('NAME' = 'End result')
25 - filter("GROUP_ID" IS NULL OR EXISTS (SELECT /*+ */ 0 FROM "LIMS".")) OPERATOR_GROUP ".
'OPERATOR_GROUP' WHERE ' OPERATOR_ID "=" LIMS$ OPERATOR_ID "() AND"GROUP_ID "=:B1))".
27 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
28 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
29 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
30 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
31 - access ("GROUP_ID" =: B1 AND "OPERATOR_ID"="LIMS$ OPERATOR_ID" ())
Note
-----
-"PLAN_TABLE' is old version
{code}
* tkprof 1 *.
{code}
TKPROF: Release 10.2.0.3.0 - Production on Tue Jan 13 13:21:47 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Trace file: C:\oracle\product\10.2.0\admin\nautp02\udump\nautp02_ora_880.trc
Sorting options: by default
********************************************************************************
Count = number of times OIC procedure has been executed
CPU = time in seconds cpu execution
elapsed = elapsed time in seconds the execution
disc = number of physical reads from disk buffers
Query = number of buffers for a consistent reading
current = number of buffers in current mode (usually for the update)
rows = number of rows processed by extracting or execute the call
********************************************************************************
SELECT sdu.u_crop_group,
SD. Name as sdg_name,
ad.variety_name,
ad.batch_number,
B.SID as aliquot_name,
Sau.u_box_code as box_code,
Sau.u_box_position as box_position,
t.Nom as test_name,
r.original_result,
PLT. Name as plate_name,
Concat (chr (a.plate_row + 64), a.plate_column) as plate_position,
au.u_replicate_number as replicate_number
OF lims_sys.sdg sd,.
lims_sys.sdg_user STO,
lims_sys. Sample his.
lims_sys.sample_user sau,
lims_sys.aliquot has,
to the lims_sys.aliquot_user,.
lims_sys.test t,
lims_sys. Result r,
PLT lims_sys.plate,
Ad lims_sys.abs_determination
WHERE sd.sdg_id = sdu.sdg_id
AND sd.sdg_id = sa.sdg_id
AND sa.sample_id = sau.sample_id
AND sau.sample_id = a.sample_id
AND a.aliquot_id = au.aliquot_id
AND au.aliquot_id = t.aliquot_id
AND t.test_id = r.test_id
AND plt.plate_id (+) = a.plate_id
AND sdu.u_abs_determination = ad.determination_assignment
AND a.status IN ('V', 'P', 'C')
AND r.name = 'result '.
AND sdu.u_client_type = "QC".
AND sdu.u_year_of_sample_delivery = (: year)
AND sdu.u_week_of_processing = (: week)
- AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
ORDER BY box_code, box_position, replicate_number
call the query of disc elapsed to cpu count current lines
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Run 1 1.15 1.16 0 0 0 0
Fetch 1 8.53 16.10 227649 241266 0 500
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Total 3 9.68 17,27 227649 241266 0 500
Chess in the library during parsing cache: 1
Lack in the library during execution cache: 1
Optimizer mode: ALL_ROWS
The analysis of the user id: 97
Rows Row Source operation
------- ---------------------------------------------------
SORT ORDER BY 500 (cr = 241266 pr = 227649 pw = time 0 = 16104631 en)
FILTER 21311 (cr = 241266 pr = 227649 pw = time 0 = 16246749 en)
21311 HASH JOIN (cr = 241266 pr = 227649 pw = time 0 = 16225434 en)
17745 TABLE ACCESS FULL DWH_ABS_DETERMINATION (cr = 374 pr = 0 pw = time 0 = 69 fr)
21311 HASH JOIN RIGHT OUTER (cr = 240892 pr = 227649 pw = time 0 = 16170607 en)
21895 VIEW PLATE (cr = 316 pr = 0 pw = time 0 = 43825 US)
21895 FILTER (cr = 316 pr = 0 pw = time 0 = 43823 US)
21895 TRAY FULL ACCESS (cr = 316 pr = 0 pw = time 0 = 31 US)
0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
21311 HASH JOIN (cr = 240576 pr = 227649 pw = time 0 = 16106174 en)
21311 HASH JOIN (cr = 133559 pr 121596 pw = time = 0 = 9594130 en)
21311 HASH JOIN (cr = 94323 pr = 83281 pw = time 0 = 6917067 en)
21311 HASH JOIN (cr = 86383 pr 75547 pw = time = 0 = 5509672 en)
JOIN by HASH 7776 (cr = 8134 pr = 0 pw = time 0 = 285364 en)
TABLE ACCESS BY INDEX ROWID SAMPLE 7776 (cr = 572 pr = 0 pw = time 0 = 27152 US)
7876 NESTED LOOPS (cr = 377 pr = 0 pw = time 0 = 488287 en)
JOIN by HASH 99 (cr = 160 pr = 0 pw = time 0 = US 4168)
99 TABLE ACCESS FULL SDG_USER (cr = 53 pr = 0 pw = time 0 = US 1209)
5719 TABLE ACCESS FULL SDG (cr = 107 pr = 0 pw = time 0 = 17 US)
7776 INDEX RANGE SCAN FK_SAMPLE_SDG (cr = 217 pr = 0 pw = time 0 = 623 en)(object id 45990)
1079741 TABLE ACCESS FULL SAMPLE_USER (cr = 7562 pr = 0 pw = time 0 = 24 US)
3307948 TABLE ALIQUOT FULL ACCESS (cr = 78249 pr = pw 75547 time = 0 = 3331129 en)
3406836 TABLE ACCESS FULL ALIQUOT_USER (cr = 7940 pr 7734 pw = time = 0 = 556 en)
3406832 TABLE TEST FULL ACCESS (cr = 39236 pr 38315 pw = time = 0 = 3413192 en)
3406832 TABLE ACCESS FULL RESULTS (cr = 107017 pr = 106053 pw = time 0 = 6848487 en)
0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
0 INDEX UNIQUE SCAN PK_OPERATOR_GROUP (cr = 0 pr = 0 pw = time 0 = 0 US)(object id 45769)
********************************************************************************
Select 'x '.
Of
Double
call the query of disc elapsed to cpu count current lines
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Run 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Total 3 0.00 0.00 0 0 0 1
Chess in the library during parsing cache: 0
Optimizer mode: ALL_ROWS
The analysis of the user id: 97
Rows Row Source operation
------- ---------------------------------------------------
1 DOUBLE QUICK (cr = 0 pr = 0 pw = time 0 = 3 US)
********************************************************************************
Start: id: = sys.dbms_transaction.local_transaction_id; end;
call the query of disc elapsed to cpu count current lines
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Run 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Total 2 0.00 0.00 0 0 0 1
Chess in the library during parsing cache: 0
Optimizer mode: ALL_ROWS
The analysis of the user id: 97
********************************************************************************
TOTALS FOR ALL NON RECURSIVE INSTRUCTIONS
call the query of disc elapsed to cpu count current lines
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 3 0.00 0.00 0 0 0 0
Run 3 1.15 1.16 0 0 0 1
Pick 2 8.53 16.10 227649 241266 0 501
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Total 8 9.68 17,27 227649 241266 0 502
Chess in the library during parsing cache: 1
Lack in the library during execution cache: 1
TOTALS FOR ALL RECURSIVE INSTRUCTIONS
call the query of disc elapsed to cpu count current lines
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 30 0.00 0.00 0 0 0 0
Run 30 0.00 0.00 0 0 0 0
Get 30 0.00 0.00 0 40 0 10
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Total 90 0.00 0.00 0 40 0 10
Chess in the library during parsing cache: 0
3 the session user SQL statements.
30 internal to SQL statements in session.
33 SQL statements in session.
********************************************************************************
Trace file: C:\oracle\product\10.2.0\admin\nautp02\udump\nautp02_ora_880.trc
Compatibility of trace files: 10.01.00
Sorting options: by default
8 sessions in the trace file.
3 SQL statements of the user in the trace file.
30 internal SQL instructions in the trace file.
33 SQL statements in the trace file.
6 unique SQL statements in the trace file.
633 lines in the trace file.
23 seconds in the trace file.
{code}ZI wrote:
I have a statement with a decoding function in the where clause like this:AND decode(:cropcode,-1,'-1',sdu.u_crop_group) = decode(:cropcode,-1,'-1',:cropcode)
When I have a package-1 as parameter for cropgroup the filter would result by ' AND '-1' = '-1', and the statement is executed in less than 2 seconds.»»» When I leave this where clause it takes almost 18 seconds. The result is the same so I don't understand why the explain plan command is so different and why not use index scans in the statement without decoding.
I would interpret the results displayed differently.
Execution which took 17 s according to the 241 266 coherent block played tkprof output gets but in order to do so he read 227 649 the disk blocks. Note that most of the table addressed by this query blocks were read through scanning of complete table that can take advantage of multiple blocks readings, for example if you unset the db_file_multiblock_read_count 10.2 (recommended) it usually try to read 1 MB with a read request, which are 128 blocks in case of standard block size 8 k. Due to several reasons not always the full size can be requested with each read request, lets say about 200 000 blocks could have been read by about 2,000 blocks multiple readings. Each read request would turn into a physical read, could you get an estimate approximate 25 MS per read times 2,000 applications-online 50 seconds (your system is running obviously better that the average assumed by ost g 10 base optimizer without collected statistics system workload, can be that some additional file caching system is involved).
On the other hand, the execution plan that finished within 2 seconds completed 221 420 coherent block gets but did No physical reads at all. Note that most of the table blocks should be processed using one-piece random searches (ACCESS BY ROWID of the TABLE), according to the grouping of the indices factor, it could have been as many blocks that the lines have been returned to the range index scans. So you could have done with lets say more than 60,000 randomly accessed table blocks => until 60 000 monobloc required reading. So in the worst case, this may take 60 000 requests time 10ms by read-online 600 seconds, even if in reality at least some of the blocks will be stored in the buffer cache, so it should be less.
It would be interesting to know how these two declarations with a cold buffer cache, so that both had to physical reads. I suppose the first is actually faster. Of course, if the second corresponds more to your typical situation that most of the blocks is in the buffer anyway, then it could be faster, because the blocks read by random access are more likely to stay in memory blocks read by complete sweep of the table, but in a true perspective of I/O the first is expected to be higher.
Moreover, the change in the plan is probably caused by the fact that the additional predicate (DECODING) lowers the cardinality of the table of SDG_USER conduct so that LOOP IMBRIQUEE approach seems to be cheaper to the optimizer that the hash join/full scan table approach. Apparently the estimate is way off (by two orders of magnitude, in fact 100 instead of 1), then the plan is not really cheap, because it seems like the optimizer.
By the way: two actual execution plans displayed in the output from tkprof are actually different from the displayed output of EXPLAIN the PLAN, so the statement has executed a little differently provided the facility to EXPLAIN the PLAN.
Your PLAN_TABLE is old, since you are on 10g you should drop any PLAN_TABLEs that are in non - SYS diagrams, since 10 g already provides a global temporary Table as part of the default dictionary (SYS. Plan_table$ presentations via public synonym PLAN_TABLE).
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
Cam nest excluded Homekit?
I can only assume, because of the competitive relationship between Apple and Google, but I'm really disappointed to see that the family of nest products is excluded from Homekit.
Stupid decision, because I do not know that I am not alone to already incorporate the nest in my house and using the app to nest on my phone. I guess they wanted to be sure that homekit was completely irrelevant for me...
Google and nest products are in direct competition with Apple and their proprietary Home Kit. Google paid $3 .2b for nest laboratories and has used to launch Google home. Completely secure communication protocols different use of two technologies, so are not inherently compatible and nest will be redesigned specifically to be. Google doesn't want you to use the nest with home kit - they want to you use the nest with their system. Time will tell which competitor wins in the end.
-
That seems to happen all the time after upgrades. What is the decoder of the RFP, it is necessary and why it ends?
It is not an application OS X. very probably part of third party software that you have installed. Where is it located? Of error messages when it closes? You use it for something? Hard to be a help with so little information from you. Please see written an effective communities of Apple Support question.
-
Can someone decode this for me kernel panic error message please?
I had some problems recently with my 13 "MacBook Pro, Early 2011. I was able to resolve most of them between the forums and the Genius Bar, but there is still a persistent that even the Genius Bar can't seem to understand. Often, my computer freezes and restarts itself, and recently I had the window "your computer restarted due to a problem". I know kernel panic can be software or hardware related. I just wiped my hard drive (third-party SSD), reinstalled the OS X and restored from a Time Machine backup (but doesn't not restore any network or personal settings, as I was told by the Genius Bar help ensure no bugs/corruptions that affected my machine were installed). A complete hardware and software diagnostic was managed by Apple, where the only problem they found was that they could not read my hard drive and I have recommended replacing the hard drive slick, that I had let them. However, my problem: I have yet to have another random reboot with the new cable, but I am always starting gel, delay and slow speeds. I understood the message of the most recent kernel panic error, but I have little idea how do make sense. If someone could decode it for me and let me know what you think caused the kernel panic, I would be grateful!
Quick notes (it may or may not be useful): I also installed new third-party RAM me, updated 4-8 GB. I also have problems taking videos on Photo Booth. When I do, app causes my computer to lag, and the video does not correctly record (late of video development, multicolor screen during playback, not only audio video, etc.). Check the video card came back clean well.
Anonymous UUID: 52761E71-2C6C-A4F0-6320-518D613A8E30
Game Aug 11 23:05:12 2016
Panic report *.
panic (cpu 0 0xffffff802a3ce6fa appellant): Kernel trap at 0xffffff802a10e2f6, type 14 = page fault, registers:
CR0: 0 X 0000000080010033, CR2: 0XFFFFFF8511DEB5C0 CR3: 0X000000013ABE4067 CR4: 0X00000000000626E0
RAX: 0X00000000BA769D69, RBX: 0XFFFFFF80FB4FF400 RCX: 0XFFFFFF80FB4FF408 RDX: 0 X 0100000000000201
RER: 0XFFFFFF8133CD39F0, RBP: 0XFFFFFF8133CD3A60, IHR: 0XFFFFFF80FB4FF000, RDI: 0XFFFFFF822804401C
R8: 0XFFFFFF8511DEB5C0, R9: 0XFFFFFF8526E83F60, R10: 0XFFFFFF8228044128 R11: 0X0F0F0F0F0F0F0F0F
R12: 0XFFFFFEB29124F000, R13: 0XFFFFFF80FB4FF000, R14: 0X0000000000000F64 R15: 0 X 0000000000000001
RFL: 0 X 0000000000010206, RIP: 0XFFFFFF802A10E2F6, CS: 0000000000000008, SS 0 X: 0 X 0000000000000010
Lack of CR2: 0xffffff8511deb5c0, error code: 0 x 0000000000000000, CPU error: 0x0, PL: 1
Backtrace (CPU 0), frame: return address
0xffffff8133cd3680: 0xffffff802a2dab52
0xffffff8133cd3700: 0xffffff802a3ce6fa
0xffffff8133cd38e0: 0xffffff802a3ec563
0xffffff8133cd3900: 0xffffff802a10e2f6
0xffffff8133cd3a60: 0xffffff802a3425af
0xffffff8133cd3ac0: 0xffffff802a340f47
0xffffff8133cd3b00: 0xffffff802a3435eb
0xffffff8133cd3b30: 0xffffff802a348057
0xffffff8133cd3d00: 0xffffff802a34debe
0xffffff8133cd3f20: 0xffffff802a3cecef
0xffffff8133cd3fb0: 0xffffff802a3ec475
Corresponding to the current thread BSD process name: Google Chrome
Mac OS version:
15G 31
Kernel version:
15.6.0 Darwin kernel version: Thu Jun 23 18:25:34 PDT 2016; root:XNU-3248.60.10~1/RELEASE_X86_64
Kernel UUID: B5AA8E3E-65B6-3D0E-867B-8DCCF81E536C
Slide kernel: 0x000000002a000000
Text of core base: 0xffffff802a200000
Text __HIB base: 0xffffff802a100000
Name of system model: MacBookPro8, 1 (Mac-94245B3640C91C81)
Availability of the system in nanoseconds: 82778692404226
last load kext to 18326096476143: com.apple.driver.AppleXsanScheme 3 (addr 0xffffff7facfbd000 size 32768)
Finally unloaded kext to 18501757170760: com.apple.driver.AppleXsanScheme 3 (addr 0xffffff7facfbd000 size 32768)
kexts responsible:
com Sophos.kext.SAV 9.4.52
com Sophos.nke.SWI 9.4.52
com.rim.driver.BlackBerryUSBDriverInt 0.0.68
com Apple.filesystems.smbfs 3.0.1
com.apple.driver.AudioAUUC 1.70
com Apple.filesystems.autofs 3.0
com.apple.driver.AppleHWSensor 1.9.5d0
com.apple.driver.AGPM 110.22.0
com.apple.driver.AppleOSXWatchdog 1
com.apple.driver.AppleMikeyHIDDriver 124
3.12.8 com.apple.driver.ApplePolicyControl
com Apple.Driver.pmtelemetry 1
com.apple.driver.AppleHDA 274.12
com.apple.driver.AppleUpstreamUserClient 3.6.1
com.apple.driver.AppleMikeyDriver 274.12
com.apple.iokit.IOUserEthernet 1.0.1
com.apple.iokit.IOBluetoothSerialManager 4.4.6f1
com.apple.Dont_Steal_Mac_OS_X 7.0.0
com.apple.driver.AppleIntelHD3000Graphics 10.0.0
com.apple.driver.AppleBacklight 170.8.9
com.apple.driver.AppleHV 1
com.apple.driver.AppleSMCPDRC 1.0.0
com.apple.driver.AppleMCCSControl 1.2.13
com.apple.driver.SMCMotionSensor 3.0.4d1
com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport 4.4.6f1
com.apple.driver.ACPI_SMC_PlatformPlugin 1.0.0
com.apple.driver.AppleLPC 3.1
com.apple.driver.AppleIntelSNBGraphicsFB 10.0.0
com.apple.driver.AppleIntelSlowAdaptiveClocking 4.0.0
com.apple.driver.AppleSMCLMU 208
com.apple.driver.AppleThunderboltIP 3.0.8
com.apple.driver.AppleUSBTCButtons 245,4
com.apple.driver.AppleUSBTCKeyboard 245,4
com.apple.driver.AppleIRController 327,6
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0
com.apple.BootCache 38
com.apple.iokit.SCSITaskUserClient 3.7.7
2.8.5 com.apple.iokit.IOAHCIBlockStorage
com.apple.driver.AirPort.Brcm4331 800.20.24
com.apple.driver.AppleSDXC 1.7.0
com.apple.iokit.AppleBCM5701Ethernet 10.2.0
com.apple.driver.AppleFWOHCI 5.5.4
com.apple.driver.AppleAHCIPort 3.1.8
com.apple.driver.usb.AppleUSBEHCIPCI 1.0.1
com.apple.driver.AppleRTC 2.0
com.apple.driver.AppleSmartBatteryManager 161.0.0
com.apple.driver.AppleACPIButtons 4.0
com.apple.driver.AppleHPET 1.8
com.apple.driver.AppleSMBIOS 2.1
com.apple.driver.AppleACPIEC 4.0
com.apple.driver.AppleAPIC 1.7
com.apple.driver.AppleIntelCPUPowerManagementClient 218.0.0
com Apple.NKE.applicationfirewall 163
com Apple.Security.Quarantine 3
com.apple.security.TMSafetyNet 8
com.apple.driver.AppleIntelCPUPowerManagement 218.0.0
com Apple.kext.Triggers 1.0
3.12.8 com.apple.AppleGraphicsDeviceControl
com.apple.driver.DspFuncLib 274.12
com.apple.kext.OSvKernDSPLib 525
com.apple.iokit.IOSurface 108.2.3
com.apple.iokit.IOSerialFamily 11
com.apple.driver.CoreCaptureResponder 1
com.apple.iokit.IOFireWireIP 2.2.6
com.apple.driver.AppleSMBusController 1.0.14d1
com.apple.iokit.IOBluetoothHostControllerUSBTransport 4.4.6f1
com.apple.iokit.IOBluetoothFamily 4.4.6f1
com.apple.driver.AppleHDAController 274.12
com.apple.iokit.IOHDAFamily 274.12
com.apple.iokit.IOAudio!
System profile:
Airport: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 (5.106.98.100.24)
Bluetooth: Version 4.4.6f1 17910, 3 services, 27 aircraft, 1 incoming serial ports
Bus crush: MacBook Pro, Apple Inc., 22.1
Memory module: DIMM0/0 BANK, 4 GB DDR3, 1333 MHz, 0x859B, 0x435434473353313333394D2E4D3136464B44
Memory module: DIMM0/1 BANK, 4 GB DDR3, 1333 MHz, 0x859B, 0x435434473353313333394D2E4D3136464B44
USB device: USB 2.0 Bus
USB device: FaceTime HD camera (built-in)
USB device: Hub
USB device: Apple keyboard / Trackpad
USB device: Hub BRCM2070
USB Device: USB Bluetooth host controller
USB device: USB 2.0 Bus
USB device: Hub
USB Device: IR receiver
Serial ATA Device: Crucial_CT480M500SSD1, 480,1 GB
Serial ATA Device: MATSHITADVD-R UJ - 8à8
Model: MacBookPro8, 1, MBP81.0047.B2A of BootROM, 2 processors, Intel Core i5, 2.3 GHz, 8 GB, MSC 1.68f99
Network service: Wi - Fi, AirPort, en1
Graphics card: integrated Intel HD Graphics 3000, Intel HD Graphics 3000,
Model: MacBookPro8, 1, MBP81.0047.B2A of BootROM, 2 processors, Intel Core i5, 2.3 GHz, 8 GB, MSC 1.68f99
Graphics card: integrated Intel HD Graphics 3000, Intel HD Graphics 3000,
Memory module: DIMM0/0 BANK, 4 GB DDR3, 1333 MHz, 0x859B, 0x435434473353313333394D2E4D3136464B44
Memory module: DIMM0/1 BANK, 4 GB DDR3, 1333 MHz, 0x859B, 0x435434473353313333394D2E4D3136464B44
Airport: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 (5.106.98.100.24)
Bluetooth: Version 4.4.6f1 17910, 3 services, 27 aircraft, 1 incoming serial ports
Network service: Wi - Fi, AirPort, en1
Serial ATA Device: Crucial_CT480M500SSD1, 480,1 GB
Serial ATA Device: MATSHITADVD-R UJ - 8à8
USB device: USB 2.0 Bus
USB device: FaceTime HD camera (built-in)
USB device: Hub
USB device: Apple keyboard / Trackpad
USB device: Hub BRCM2070
USB Device: USB Bluetooth host controller
USB device: USB 2.0 Bus
USB device: Hub
USB Device: IR receiver
Bus crush: MacBook Pro, Apple Inc., 22.1
I'm not sure regarding the panic itself 100%, but the symptoms you describe, I'll try to put first the original RAM if you, as a test. Also try a SMC reset: reset the management system (SCM) controller on your Mac - Apple Support.
Maybe you are looking for
-
Problems connecting MacBook Pro to the television screen.
I'm trying to connect my MacBook Pro (retina, 15 inches, end 2013) to an external TV monitor (KONKA). I bought the cord VGA and HDMI adapter. When I connect to the monitor, he doesn't always says "no signal". The screen of my MacBook, but flashes bla
-
My wife and I just watches from Apple. We each have our opinion the value "mirror iphone." Because I wear mine to work, I need to silence the noise during meetings. On the iPhone, I just flip the switch on the side to reduce to silence the notificati
-
If a particular port is open, how close this same port?Thank you
-
Question about the license of Windows Vista
Hello. I didn't know where I should post this. I have Windows Vista, I purchased an upgrade. My question is, "I am allowed to install the software on a friends computer. Because I don't need the software, can I sell the software. I know that Microsof
-
Photosmart 5520 print wireless
I just bought a Photosmart 5520 and I can't print wireless. My Mac OSX 10.8 computer he straightens and the printer is recongising the IP address of my computer, but when I feel goes into the printer icon in my dock and just said "Ready to print" and