Which is Faster among DECODE & CASE Statment.
Can you please explain me the reason behind the fastest among DECODE & CASE statement?
user13483989 wrote:
Decode is have better performance.Because it is Oracle Inbuilt Function.So no neet to Specify Paraameters,It already contain Parameter.
So Performance is good With decode.Please prove it with evidence, rather than just making supposed factual statements.
From my tests, there's no clear difference one way or the other...
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_dummy number;
3 v_timestamp timestamp;
4 v_timestamp2 timestamp;
5 begin
6 v_timestamp := CURRENT_TIMESTAMP;
7 dbms_output.put_line(v_timestamp);
8 -- Test DECODE
9 select count(*)
10 into v_dummy
11 from (select rownum rn from dual connect by rownum <= 1000000)
12 where decode(mod(rn,19),0,1,0) = 1;
13 v_timestamp2 := CURRENT_TIMESTAMP;
14 dbms_output.put_line(v_timestamp2);
15 dbms_output.put_line('Decode Time Taken: '||(v_timestamp2 - v_timestamp) DAY TO SECOND);
16 v_timestamp := CURRENT_TIMESTAMP;
17 dbms_output.put_line(v_timestamp);
18 -- Test CASE
19 select count(*)
20 into v_dummy
21 from (select rownum rn from dual connect by rownum <= 1000000)
22 where case when mod(rn,19) = 0 then 1 else 0 end = 1;
23 v_timestamp2 := CURRENT_TIMESTAMP;
24 dbms_output.put_line(v_timestamp2);
25 dbms_output.put_line('Case Time Taken: '||(v_timestamp2 - v_timestamp) DAY TO SECOND);
26* end;
SQL> /
18-JAN-11 12.01.58.856000
18-JAN-11 12.02.00.653000
Decode Time Taken: +000000000 00:00:01.797000000
18-JAN-11 12.02.00.653000
18-JAN-11 12.02.02.309000
Case Time Taken: +000000000 00:00:01.656000000
PL/SQL procedure successfully completed.
SQL> /
18-JAN-11 12.02.03.668000
18-JAN-11 12.02.05.403000
Decode Time Taken: +000000000 00:00:01.735000000
18-JAN-11 12.02.05.403000
18-JAN-11 12.02.07.152000
Case Time Taken: +000000000 00:00:01.749000000
PL/SQL procedure successfully completed.
SQL> /
18-JAN-11 12.02.07.871000
18-JAN-11 12.02.09.777000
Decode Time Taken: +000000000 00:00:01.906000000
18-JAN-11 12.02.09.777000
18-JAN-11 12.02.11.684000
Case Time Taken: +000000000 00:00:01.907000000
PL/SQL procedure successfully completed.
SQL> /
18-JAN-11 12.02.15.324000
18-JAN-11 12.02.17.090000
Decode Time Taken: +000000000 00:00:01.766000000
18-JAN-11 12.02.17.090000
18-JAN-11 12.02.18.855000
Case Time Taken: +000000000 00:00:01.765000000
PL/SQL procedure successfully completed.
SQL>
Similar Messages
-
Which is faster while executing statment having Case or Decode.
Pls tell me which execute faster a case or decode.
ajallen wrote:
If you are really concerned about this, then you are being taken over by the tuning virus. You are out of control. You are tuning beyond reason. DECODE() is deprecated - not being enhanced. CASE is the new preferred approach. CASE is simpler and easier to code/follow.I can't find a link saying that DECODE() function is already deprecated. Can you give us a valid link?
Regards. -
Which is the best decode or case
Hi,
When you check performance wise which is the best one decode or case?
Thanks,> You mean CPU processor speed or oracle buffer(SGA).
Neither. CPU architecture. RISC vs CISC vs ..
On a PA-RISC1 CPU a DECODE is just a tad faster than a CASE. On an AMD64 CPU, the reverse is true.
> When I increase memory, The case and decode performance will increase?
No. A CASE and a DECODE does not need memory to work faster. It is a set of machine code instructions that needs to compare values to determine a result. It depends on just how fast the CPU can execute this set of machine code instructions.
A faster CPU will make a very significant difference. An AMD64 Opteron CPU is a couple of times faster than a PA-RISC1 CPU.
I had this exact same conversation back in 2006 on this forum - and posted [url
http://forums.oracle.com/forums/thread.jspa?messageID=1346165�]this benchmark to show that the decision of using CASE or DECODE is not a decision that should be based on raw performance. -
Issue with Case Statment Bit Urgent.
Hi Friends,
I am using a Case in my select statment but problem is i have used group by clause.
This is the main query.
SELECT papf.employee_number OHR,
papf.business_group_id,
(CASE
WHEN (paaf.effective_start_date = Min("paaf.effective_start_date" From Below Where condition))
THEN
TO_CHAR (
(SELECT ORIGINAL_DATE_OF_HIRE
FROM apps.per_all_people_f p1
WHERE p1.employee_number = papf.employee_number
AND p1.current_employee_flag = 'Y'),
'DD-MON-YYYY'
ELSE
TO_CHAR (MIN (paaf.effective_start_date), 'DD-MON-YYYY')
END) EFFECTIVE_START_DATE,
DECODE (TO_CHAR (MAX (paaf.effective_end_date), 'DD-MON-RRRR'),
'31-DEC-4712', NULL,
TO_CHAR (MAX (paaf.effective_end_date), 'DD-MON-RRRR')) EFFECTIVE_END_DATE,
FROM apps.per_all_people_f papf,
apps.per_all_assignments_f paaf,
apps.per_grades pg,
apps.per_jobs pj
WHERE papf.person_id = paaf.person_id
AND papf.employee_number = '2130'
AND papf.current_employee_flag = 'Y'
AND paaf.grade_id = pg.grade_id
AND paaf.job_id = pj.job_id
AND ( paaf.ass_attribute21 IS NOT NULL
OR paaf.ass_attribute22 IS NOT NULL
OR paaf.ass_attribute23 IS NOT NULL
OR paaf.ass_attribute24 IS NOT NULL
OR paaf.ass_attribute25 IS NOT NULL)
AND EXISTS
(SELECT pap.EMPLOYEE_NUMBER
FROM APPS.PER_ALL_PEOPLE_F PAP
WHERE TRUNC (SYSDATE) BETWEEN PAP.EFFECTIVE_START_DATE AND PAP.EFFECTIVE_END_DATE
AND PAP.CURRENT_EMPLOYEE_FLAG = 'Y'
AND PAP.EMPLOYEE_NUMBER = PAPF.EMPLOYEE_NUMBER)
AND PAAF.EFFECTIVE_START_DATE >
NVL (
(SELECT MAX (PAAFA.EFFECTIVE_START_DATE)
EFFECTIVE_START_DATE
FROM APPS.PER_ALL_ASSIGNMENTS_F PAAFA,
APPS.PER_PERIODS_OF_SERVICE PPOSA
WHERE PAAFA.PERIOD_OF_SERVICE_ID =
PPOSA.PERIOD_OF_SERVICE_ID
AND (UPPER (PPOSA.LEAVING_REASON) NOT LIKE
'%TRANSFER%')
AND PPOSA.ACTUAL_TERMINATION_DATE < SYSDATE
AND PAAFA.PERSON_ID IN
(SELECT DISTINCT PERSON_ID
FROM apps.per_all_people_f
WHERE employee_number =
PAPF.EMPLOYEE_NUMBER)),
TO_DATE ('01-JAN-1881')
GROUP BY papf.employee_number,
papf.person_id,
paaf.assignment_id,
fnd_date.canonical_to_date (papf.ATTRIBUTE29),
papf.business_group_id,
TRIM(SUBSTR (PAAF.ASS_ATTRIBUTE21,
INSTR (PAAF.ASS_ATTRIBUTE21, '-') + 1)),
TRIM(SUBSTR (PAAF.ASS_ATTRIBUTE22,
INSTR (PAAF.ASS_ATTRIBUTE22, '-') + 1)),
UPPER (paaf.ass_attribute23),
UPPER (paaf.ass_attribute24),
UPPER (paaf.ass_attribute25),
xx_ijp_get_loc (paaf.ass_attribute23),
pg.name,
pj.name
ORDER BY papf.employee_number, MIN (paaf.effective_start_date) DESC -----------------
Output of the query
EFFECTIVE_START_DATE EFFECTIVE_END_DATE
13-JAN-2010
15-DEC-2009 12-JAN-2010
09-JUN-2009 14-DEC-2009
05-JUN-2009 08-JUN-2009
22-SEP-2008 04-JUN-2009
21-APR-2008 21-SEP-2008
21-JAN-2008 20-APR-2008
01-JAN-2008 20-JAN-2008
04-APR-2007 31-DEC-2007While using when in case statment i want to put the condition from where condition of main query and pick the min value of EFFECTIVE_START_DATE column i.e 04-APR-2007 so i can replace this with employee Date of Joining through Case condtion.
Any solution for this.
Please suggest it's bit urgent.
Thanks
Bachan.Bachan wrote:
Please suggest it's bit urgent.Ok, I'll suggest it's a bit urgent...
"it's a bit urgent"
But only to you.
Everybody who posts a question would like it answering as soon as possible. Do you not think it's rude of you to expect that your question demands more immediate attention than someone elses? Is that fair on all the other people who've just asked their question and are patient enough to wait for answers? Or should they be happy that you're jumping up and down saying "me first! me first!"
What about everybody who's giving up their own time volunteering to answer questions? They have their own jobs to do as well. Do you not think it's rude to expect them to drop what they're doing to just help you because you think your question is "urgent".
Typically, you will find that less people will come to help you if you say your question is urgent because most people will ignore it as they consider it rude. The best way to ask you question is to give as much information as possible and ensure you state what your database version is, as well as providing table structures, example data and expected output, so that the most appropriate answer can be given.
Looking at your code, it's not clear what your problem is as we don't have the input data to try it ourselves.
One clear issue is:
TO_DATE ('01-JAN-1881')As you don't specify a format mask so it will rely on your NLS_DATE_FORMAT mask being set to DD-MON-YYYY which, if it's not, will cause the code to either give incorrect results or error. -
What is the difference betwee decode & case function
Hi
What is the difference betwee decode & case function
1.decode can't used in pl/sql 1) case can be user
2.in decode we can't use (>,<,>=) 2) we can use
any other do u have....
thanks in advance....DECODE works with expressions which are scalar values.
CASE can work with predicates and subqueries in searchable form.
There is one more Important difference between CASE and DECODE
DECODE can be used Only inside SQL statement....
But CASE can be used any where even as a parameter of a function/procedure
Eg:-
SQL> create or replace procedure pro_01(n number) is
2 begin
3 dbms_output.put_line(' The number = '||n);
4 End;
5 /
Procedure created.
SQL> set serverout on
SQL> var a varchar2(5);
SQL> Begin
2 :a := 'ONE';
3 End;
4 /
PL/SQL procedure successfully completed.
SQL> Begin
2 pro_01(Decode(:a,'ONE',1,0));
3 End;
4 /
pro_01(Decode(:a,'ONE',1,0));
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> Begin
2 pro_01(case :a when 'ONE' then 1 else 0 end);
3 End;
4 /
The number = 1
PL/SQL procedure successfully completed.Message was edited by:
Avi
Message was edited by:
Avi -
Decode/Case in Where clause
Hello,
We are experiencing an issue with a Select statement that uses Decode in the Where clause. Specifically, it seems to be ignoring a nested Decode and just returning the default value. We have another nested decode that works fine, though.
A member of our team mentioned that he believed there was an issue with using Decode and Case statements inside of a where clause within HTML DB...Is this correct? If it is, is there a workaround? Since the nested Decode works elsewhere in this statement, that doesn't seem right.
My select statement looks like:
SELECT
SUBSTR(OBOB.OBOB_CNAME, 0, 30) d,
OBOB.OBOB_UID r
FROM
ISR_OBOB_OBJECT OBOB,
ISR_OBAF_OBJECT_AFFILIATION OBAF,
ISR.ISR_OBSD_SDR OBSD
WHERE
OBOB.OBOB_UID = OBSD.OBOB_UID AND
OBOB.OBOB_UID = OBAF.OBOB_B_UID AND
/*If Personal radio button is selected, displays all SDRs associated with user.
If All is selected, displays all SDRs associated with IS group selected from drop down list
or every SDR.
OBAF.OBOB_A_UID = DECODE(:P1_DISPLAY_ALL,
'Personal', :F101_APP_USER_UID,
/*This is the decode statement that it seems to ignore. If ALL is selected, the query should see if a group has
has been selected from a drop down list that appears when the ALL button is chosen. If a group is selected
(the item isn't 0), only SDRs for that group should be shown. Otherwise, all SDRs for every group should display.
'ALL', DECODE(:P1_SEARCH_IS_SUPPORT_GROUP, 0, OBAF.OBOB_A_UID, :P1_SEARCH_IS_SUPPORT_GROUP),
OBAF.OBOB_A_UID) AND
/*If Personal radio button is selected, display SDRs where user is the Primary assignee.
OBAF.OBAT_UID = DECODE(:P1_DISPLAY_ALL, 'Personal', (select OBAT_UID from ISR_OBAT_OBJ_AFFIL_TYPE WHERE OBAT_APP_REF = 'SDR_PRIMARY'), OBAF.OBAT_UID) AND
/*If a SDR Status (open, completed, on hold, not started...) is selected, only display the SDRs with that status.
OBSD.KTTR_STATUS_UID = DECODE(:P1_ISR_STATUS_UID, 0, OBSD.KTTR_STATUS_UID, :P1_ISR_STATUS_UID) AND
/*If SDR_History textbox is Null, or Open, Not Started, or On Hold SDR status has been selected, then all SDRs with
a create date between today and 99999 months ago will display. Otherwise, only SDRs with a create date between
today and however many months are in the textbox will display (i.e. Completed SDRs created in the past 6 months.)
MONTHS_BETWEEN(sysdate, OBSD.OBSD_CREATE_DATE) <= DECODE(:P1_SDR_HISTORY, NULL, 99999, DECODE(:P1_ISR_STATUS_UID,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_OPEN'), 99999,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_NOT_STA'), 99999,
(select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_HOLD'), 99999,
:P1_SDR_HISTORY))
/*Alphabetical order
Order by
dWe originally wrote this as a PL/SQL statement that returned a query string since most of the where clause is dependent on items the user may or may not select, but we have moved the query into a multiselect list, which only seems to allow SQL Queries.
Any help or advice would be appreciated.
Thanks,
ScottScott: Did you try running that SQL statement in SQL Workshop in Apex? You can run it as it is, it will popup a window asking you to enter values for the bind variables.
JAC73: I don't think an IN clause doesn't work that way, you need a actual SQL sub-query, not an expression from a DECODE/CASE statement. Search this site for str2tbl and see Tom's excellent discussion at
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061 -
Hi Guys,
Just want to knw which is faster
java.lang.String.toLowerCase()
or
java.lang.String.toUpperCase()
Thanks,
TunikiA look into the source code tells me that
toUpperCasemay be slightly slower in rare cases when a single lower-case
letter needs to be converted to an array of upper-case double-bytes.
However, this depends somewhat on the frequency of conversions.
If you have frequently strings that are all-upper-case, use
toUpperCase()and -- vice versa -- if the strings are frequently all lower-case, then prefer
toLowerCaseboth methods first test whether a conversion has to be made at all. -
Which is fast either stored procedure or stored function in oracle 10g.
Thanks in advancei would say it depends on what you are trying to do in the body of the procedure or function. i don't think it's a matter of which is faster. it would be more of a question of did you want to return something (in which case use a function) or nothing (in which case you can use a procedure).
-
Missing Expression Error When Case Statment is used as field
I have tried to write an expression that will calculate how many days ago a request was submitted and return a user defined value if the calculation falls within the criteria in the case statment. The SQL View for the Query I am using is shown below:
SELECT A.F_POSN_REQUEST_ID, A.F_REQ_ECP_STATUS, TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>60 THEN '>60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI')) >30 AND <=60 THEN '30 - 60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>=15 AND <=30 THEN '15 - 30' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))<15 THEN 'Less Than 15' ELSE NULL END)END)END)END))
FROM PS_F_POSN_REQUEST A
WHERE A.F_REQ_ECP_STATUS IN ('I','O','P')
GROUP BY A.F_POSN_REQUEST_ID, A.F_REQ_ECP_STATUS, TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"')When I try to run the query I get Message=ORA-00936: missing expression (50,380)
Any suggestions you could provide to help me clear this error would be greatly appreciated.
Edited by: 992737 on Mar 8, 2013 9:07 AMHi,
Welcome to the forum!
I think you want something like this:
CASE
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 60 THEN '>60'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 30 THEN '30.1-60'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 15 THEN '15.1-30'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) THEN '15 or less'
ENDNested CASE expressions aren't needed very much. Each WHEN clause is evaluated only if all the ealier ones have failed. For example, when testing to see if a row is in the 301.-60 range above (that is, the 2nd WHEN clause), there's no need to see if the difference is greater than or equal to 60; it wouldn't be evaluating that clause if the 1st WHEN condition was TRUE.
This assumes that a.f_req_st_dt is a TIMESTAMP or DATE; either datatype can be compared with DATEs, such as SYSDATE-60, so there's no need to conevert them to strings, and then convert them back into DATEs.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Simplify the problem as much as possible. Show only the parts that you don't already know how to do.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002}
Never write, let alone post, unformatted code. Indent the code to show the exent and structure of clauses (SELECT, FROM, etc.), and complex expressions (such as CASE). The forum FAQ explains how to use \ tags when posting formatted text on this site. -
Which is faster - Member formula or Calculation script?
Hi,
I have a very basic question, though I am not sure if there is a definite right or wrong answer.
To keep the calculation scripts to a minimum, I have put all the calculations in member formula.
Which is faster - Member formula or calculation scripts? Because, if i am not mistaken, FIX cannot be used in member formulas, so I need to resort to the use of IF, which is not index driven!
Though in the calculation script,while aggregating members which have member formula, I have tried to FIX as many members as I can.
What is the best way to optimize member formulas?
I am using Hyperion Planning and Essbase 11.1.2.1.
Thanks.Re the mostly "free" comment -- if the block is in memory (qualification #1), and the formula is within the block (qualification #2), the the expensive bit was reading the block off of the disk and expanding it into memory. Once that is done, I typically think of the dynamic calcs as free as the amount of data being moved about is very, very, very small. That goes out the window if the formula pulls lots of blocks to value and they get cycled in and out of the cache. Then they are not free and are potentially slower. And yes, I have personally shot myself in the foot with this -- I wrote a calc that did @PRIORS against a bunch of years. It was a dream when I pulled 10 cells. And then I found out that the client had reports that pulled 5,000. Performance when right down the drain at that point. That one was 100% my fault for not forcing the client to show me what they were reporting.
I think your reference to stored formulas being 10-15% faster than calc script formulas deals with if the Formulas are executed from within the default calc. When the default Calc is used, it precompiles the formulas and handles many two pass calculations in a single pass. Perhaps that is what you are thinking of.^^^I guess that must be it. I think I remember you talking about this technique at one of your Kscope sessions and realizing that I had never tried that approach. Isn't there something funky about not being able to turn off the default calc if a user has calc access? I sort of thing so. I typically assing a ; to the default calc so it can't do anything.
Regards,
Cameron Lackpour -
Which is faster - Member formula or Calculation scripts?
Hi,
I have a very basic question, though I am not sure if there is a definite right or wrong answer.
To keep the calculation scripts to a minimum, I have put all the calculations in member formula.
Which is faster - Member formula or calculation scripts? Because, if i am not mistaken, FIX cannot be used in member formulas, so I need to resort to the use of IF, which is not index driven!
Though in the calculation script,while aggregating members which have member formula, I have tried to FIX as many members as I can.
What is the best way to optimize member formulas?
I am using Hyperion Planning and Essbase 11.1.2.1.
Thanks.The idea that you can't reference a member formula in a FIX is false. Here's an example:
- Assume you have an account that has a data storage of Stored or Never Share.
- This account is called Account_A and it has a member formula of Account_B * Account_C;.
- You would calculate this account within a FIX (inside of a business rule) something like this:
FIX(whatever . . . )
"Account_A";
ENDFIX
If you simply place the member named followed by a semi-colon within a business rule, the business rule will execute the code in the in that member's member formula.
Why would you want to do this instead of just putting ALL of the logic inside the business rule? Perhaps that logic gets referenced in a LOT of different business rules, and you want to centralize the code in the outline? This way, if the logic changes, you only need to update it in one location. The downside to this is that it can make debugging a bit harder. When something doesn't work, you can find yourself searching for the code a bit.
Most of my applications end up with a mix of member formulas and business rules. I find that performance isn't the main driving force behind where I put my code. (The performance difference is usually not that significant when you're talking about stored members.) What typically drives my decision is the organization of code and future maintenance. It's more art than science.
Hope this helps,
- Jake -
Java io and Java nio, which is faster to binary io?
Anybody can advise me about java io and java nio ?
I want to write the faster code to read and write binary files.
I'm going to read/write
- individual elements (int, double, etc)
- arraylists
- objects
Also I'm going (or I'd want) to use seek functions.
ThanksAnybody can advise me about java io and java nio ?
I want to write the faster code to read and write binary files.Which is "faster" depends on exactly how you're using them. For example, a MappedByteBuffer is usually faster for random access than a RandomAccessFile, unless your files are so large (and your accesses so random) than you're constantly loading from disk. And it's not at all faster for linear uni-directional access than a simple FileInputStream.
So, rather than expecting some random stranger telling you that one is faster than the other without knowing your project, perhaps you should tell us exactly how you plan to use IO, and why you think that one approach may be faster than the other. -
Hello All,
Can I use decode/case function within a decode function?
{code}
SELECT TO_CHAR (
EDMS_STRAGG_WC (
DISTINCT DECODE (
eqs.attrib_code,
'PRODUCT_AUTHORIZATION', 'Authorization: '
|| CASE eqs.qual_value
WHEN 'LIST'
THEN
(SELECT lookup_desc
FROM edmsadm.edms_lookup
WHERE lookup_type =
'PARTNER_AUTHORIZATION'
AND lookup_code =
eqls.list_value)
ELSE
(SELECT lookup_desc
FROM 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
ELSE
eqs.qual_value
END,
'PRODUCT_SPECIALIZATION', 'Specialization: '
|| (SELECT lookup_desc
FROM edmsadm.edms_lookup
WHERE lookup_type =
'PARTNER_SPECIALIZATION'
AND lookup_code =
CASE eqs.qual_value
WHEN 'LIST'
THEN
eqls.list_value
ELSE
eqs.qual_value
END))))
program_value
FROM 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 eqs.attrib_code IN
('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
FROM 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 eqs.attrib_code IN
('PRODUCT_CERTIFICATION',
'PRODUCT_AUTHORIZATION',
'PRODUCT_SPECIALIZATION');
7509575 598631 192647 PRODUCT_CERTIFICATION LIST GOLD
7509575 598631 192647 PRODUCT_CERTIFICATION LIST SILVER
7509576 598631 192647 PRODUCT_AUTHORIZATION LIST ATP - JOULEX PROVIDER ESCO
7509576 598631 192647 PRODUCT_AUTHORIZATION LIST ATP - JOULEX PROVIDER IDENTIFY
7509577 598631 192647 PRODUCT_SPECIALIZATION LIST ADVANCED SECURITY
7509577 598631 192647 PRODUCT_SPECIALIZATION LIST EXPRESS FOUNDATION
Required Output:
Certification: GOLD, SILVER, Authorization: ATP - JOULEX PROVIDER ESCO, ATP - JOULEX PROVIDER IDENTIFY, SPECIALIZATION: ADVANCED SECURITY, EXPRESS FOUNDATION.
Thx
Shank.Hi,
Sure; a DECODE or CASE expression that returns a NUMBER can be used any place a NUMBER is expected, including within another DECODE or CASE expression. A DECODE or CASE expression that returns a DATE can be used any place a DATE is expected, including within another DECODE or CASE expression. A DECODE or CASE expression that returns a VARCHAR2 can be used almost any place a VARCHAR2 is expected. (There a couple of special situations where a string literal is absolutely required.)
There are not many situations where you really need to do that, though. It's usually simpler and more efficient to use a single CASE expression; nesting is rarely needed.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Simplify the problem as much as possible, so that it contains only enough to show the part you don't already know how to do.
If you really need a user-defined function to show the problem, then include a CREATE FUNCTION statement, and explain what the function does. Again, simplify: if the function isn't what you don't understand, post a problem that doesn't use the function.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Hi All,
The Transformation Guide of OWB mentions that DECODE, CASE can be used. But I am unable to find either of these functions in the Expression Builder. Can you please tell me wher should I search for these functions, or if you could tell me if there is any other way of implementing IF THEN ELSE logic.
-ArnabHello Arnab,
Just type your CASE ... END expression directly in the expr. builder window.
Always press the Validate button for syntax verification when you have changed your expression.
Regards, Hans Henrik -
Which is fast / Smooth performing?
I have 10 circles on the stage, animated on the time line, simple animation like scale, rotation and size changes.
Which will give me best performance in terms of browser load and smoothness of animation?
Ellipse or Svg file
What if it is 100 objects, or even 1000 objects?Which is fast ? Select * from tableName or Select Column1,Column2 .... From tableName ? and Why ?
select * from Sales.[SalesOrderHeader]
select SalesOrderNumber,RevisionNumber,rowguid from Sales.[SalesOrderHeader]
As you can see both the query execution plan and subtree cost is same. So how selecting the particular columns optimize the query ?
Yes, selecting specific columns is always better than select *.
If you always need few columns in result, then just use SELECT col1, col2 FROM YourTable. If you SELECT * FROM YourTable; that is extra useless overhead.
If in future if someone adds Image/BLOB/Text type columns in your table, using SELECT * will worsen the performace for sure.
Let's say if you have SP and you use INSERT INTO DestTable SELECT * FROM TABLE which runs fine BUT again if someone adds few more columns then your SP will fail saying provided columns don't match.
-Vaibhav Chaudhari
Maybe you are looking for
-
Unable to read File using File Adapter
Hi, I am using File adapter to read XML file. I able to write payload contents to file. but using same schema, path i am unable to read the file. receive process is not initiating. what could be the possible issue? Thanks
-
I got the new 5S - but where did my new photos go?
before I restored all my old info from my 4 to the new 5S (photos, apps etc) I used the phone to take photos and text - now that I've restored it all the new photos I took are gone. Where can I find them?
-
My Remove DVR stopped working out of the blue - been great for months!
I tried to use Remote DVR via web and my phone today and both didn't work so I tried the diagnostics on the STB (7216) and everything passes except Remote DVR which now says "FAILED". When I hit ok for more info, it just says Check cable which is use
-
Hi. I am having difficulty printing graphics with the M277. For example, our logo shows our full brand name, but only a few letters of it print. I've printed the document with the graphics on other printers, so I don't think it's a problem with th
-
Hello, I am trying to backup my mail server using the mailbfr script and I am getting the following error: link_stat "/private/etc/amavisd.conf" failed: No such file or directory rsync error: some files could not be transferred (code 23) at /SourceCa