Help on a decode statement

I wish to decode a column I've named "Request Description"
to include the data name "Odometer" if odometer exists and if not I want to display the result: ('request_bytes' from 'module_name')
e.g.: 9A from ECM
lines 2,3,4 are the referenced areas.
Here is my entire query:
SELECT distinct vehicle.vin, ada_param.TARGETED_VALUE_ID as "Module ID",
     max(to_char(decode(data_req.NAME,'Odometer','Odometer',
     '%AUTODTC%',ada_param.req_data_bytes||'from'||module.name))) as "Request Description",
vehicle_call_session.session_initation_time as "Call Start",
vehicle_call_session.session_end_time as "Call End", ' ' as "Latitude", ' ' as "Longitude",
     vehicle_class.make||' '||vehicle_class.model||' '||vehicle_class.year as "Description",
     data_req_type.id as "Data Type", vehicle_case_data.raw_value as "Raw Data",
     data_req.name as "DTC/Parameter", vehicle_case_data.dtc_status as "DTC Status"
FROM vs1_ll.vehicle,
vs1_ll.data_req,
vs1_ll.vehicle_call_session,
vs1_ll.vehicle_class,
vs1_ll.vehicle_case_data,
vs1_ll.program,
vs1_ll.prog_data_req_set_assoc,
vs1_ll.data_req_set,
vs1_ll.vehicle_prog_enroll,
vs1_ll.vehicle_fleet_assoc,
vs1_ll.ada_param,
vs1_ll.data_req_type,
vs1_ll.vehicle_call_detail,
     vs1_ll.module_data_req_assoc,
     vs1_ll.module,
     vs1_ll.c2_param
WHERE ( (vehicle.ID = vehicle_call_session.vehicle_id)
AND (vehicle_class.ID = vehicle.vehicle_class_id)
AND (data_req.ID = vehicle_case_data.data_req_id)
AND (vehicle_call_session.ID =
vehicle_case_data.vehicle_call_session_id
AND (program.ID = prog_data_req_set_assoc.program_id)
AND (data_req_set.ID = prog_data_req_set_assoc.data_req_set_id)
AND (vehicle.ID = vehicle_prog_enroll.vehicle_id)
AND (program.ID = vehicle_prog_enroll.program_id)
AND (vehicle.ID = vehicle_fleet_assoc.vehicle_id)
AND ((data_req.ID = ada_param.ID)
          OR (data_req.ID = c2_param.ID))
AND (data_req_type.ID = data_req.data_req_type_id)
AND (vehicle_call_session.ID =
vehicle_call_detail.vehicle_call_session_id
AND (program.ID = vehicle_call_detail.program_id)
          AND (module_data_req_assoc.DATA_REQ_ID = data_req.ID)
and vehicle_call_session.SESSION_STATUS_ID = 1
and vehicle_fleet_assoc.FLEET_ID = 8
and vehicle_call_session.SESSION_INITATION_TIME >= to_date ('03/14/2007 3:57:00 PM','MM/DD/YYYY HH:MI:SS PM')
and vehicle.vin = 'XXXXXXXXXXXXXXXXX'
and data_req.name like '%AUTODTC%'
and data_req.name like 'Odometer'
group by (vehicle.vin, ada_param.TARGETED_VALUE_ID, vehicle_call_session.session_initation_time, vehicle_call_session.session_end_time, vehicle_class.make||' '||vehicle_class.model||' '||vehicle_class.year,
data_req_type.id, vehicle_case_data.raw_value, data_req.name, vehicle_case_data.dtc_status)
order by vehicle_call_session.SESSION_INITATION_TIME, vehicle.vin
any ideas would be appreciated as this is currently returning no data.

hmmm....tried a case and it seems to lock up:
SELECT distinct vehicle.vin, ada_param.TARGETED_VALUE_ID as "Module ID",
     (case data_req.NAME when 'Odometer' then 'Odometer'
     when '%AUTODTC%' then (ada_param.req_data_bytes||'from'||module.name) END) "Request Description",
vehicle_call_session.session_initation_time as "Call Start",
vehicle_call_session.session_end_time as "Call End", ' ' as "Latitude", ' ' as "Longitude",
     vehicle_class.make||' '||vehicle_class.model||' '||vehicle_class.year as "Description",
     data_req_type.id as "Data Type", vehicle_case_data.raw_value as "Raw Data",
     data_req.name as "DTC/Parameter", vehicle_case_data.dtc_status as "DTC Status"
FROM vs1_ll.vehicle,
vs1_ll.data_req,
vs1_ll.vehicle_call_session,
vs1_ll.vehicle_class,
vs1_ll.vehicle_case_data,
vs1_ll.program,
vs1_ll.prog_data_req_set_assoc,
vs1_ll.data_req_set,
vs1_ll.vehicle_prog_enroll,
vs1_ll.vehicle_fleet_assoc,
vs1_ll.ada_param,
vs1_ll.data_req_type,
vs1_ll.vehicle_call_detail,
     vs1_ll.module_data_req_assoc,
     vs1_ll.module,
     vs1_ll.c2_param
WHERE ( (vehicle.ID = vehicle_call_session.vehicle_id)
AND (vehicle_class.ID = vehicle.vehicle_class_id)
AND (data_req.ID = vehicle_case_data.data_req_id)
AND (vehicle_call_session.ID =
vehicle_case_data.vehicle_call_session_id
AND (program.ID = prog_data_req_set_assoc.program_id)
AND (data_req_set.ID = prog_data_req_set_assoc.data_req_set_id)
AND (vehicle.ID = vehicle_prog_enroll.vehicle_id)
AND (program.ID = vehicle_prog_enroll.program_id)
AND (vehicle.ID = vehicle_fleet_assoc.vehicle_id)
AND ((data_req.ID = ada_param.ID)
          OR (data_req.ID = c2_param.ID))
AND (data_req_type.ID = data_req.data_req_type_id)
AND (vehicle_call_session.ID =
vehicle_call_detail.vehicle_call_session_id
AND (program.ID = vehicle_call_detail.program_id)
          AND (module_data_req_assoc.DATA_REQ_ID = data_req.ID)
and vehicle_call_session.SESSION_STATUS_ID = 1
and vehicle_fleet_assoc.FLEET_ID = 8
and vehicle_call_session.SESSION_INITATION_TIME >= to_date ('03/14/2007 3:57:00 PM','MM/DD/YYYY HH:MI:SS PM')
and vehicle.vin = 'XXXXXXXXXXXXXXXXX'
and data_req.name like '%AUTODTC%'
or data_req.name = 'Odometer'
order by vehicle_call_session.SESSION_INITATION_TIME, vehicle.vin

Similar Messages

  • Help with Nesting DECODE statements

    Hello. I'm trying to write a sql script to generate data report for payments. I need to incorporate specific conditions to SUPPRESS BLANK ADDRESS field lines. I am pulling Address_Line1, Address_Line2, Address_Line3, plus CITY, STATE, ZIP as Address_Line4. If any fields are blank, I need to suppress the blank line and move the other lines up.
    Here are 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;
    /

    Hi,
    Here is the code along with some sample data. I substitute the "+" symbol for "/" becuase some addresses where using "c/o" in the address line.
    The address fields are null, as shown by the query below (ref query results below):
    SQL> select address_line1
      2  from po.po_vendor_sites_all
      3  where address_line1='3457 SOLUTIONS CENTER'
      4  and address_line2 is null;
    ADDRESS_LINE1
    3457 SOLUTIONS CENTERHere is the script:
    WITH got_delimited_list AS
    SELECT address_line1 || ' +' ||
    address_line2 || ' +' ||
    address_line3 || ' +' ||
    city ||', ' || state ||'  ' || zip AS delimited_list
    FROM po.po_vendor_sites_all
    SELECT REGEXP_SUBSTR (delimited_list, '[^+]+', 1, 1) AS vad1
    , REGEXP_SUBSTR (delimited_list, '[^+]+', 1, 2) AS vad2
    , REGEXP_SUBSTR (delimited_list, '[^+]+', 1, 3) AS vad3
    , REGEXP_SUBSTR (delimited_list, '[^+]+', 1, 4) AS vad4
    FROM got_delimited_list;Sample of the data records returned:
    VAD1
    VAD2
    VAD3
    VAD4
    3457 SOLUTIONS CENTER
    CHICAGO, IL  60677-3004
    VAD1
    VAD2
    VAD3
    VAD4
    5172 EAGLE WAY
    CHICAGO, IL  60678-1517
    VAD1
    VAD2
    VAD3
    VAD4
    RETAILERS' OCCUPATION TAX
    SPRINGFIELD, IL  62796-0001
    VAD1
    VAD2
    VAD3
    VAD4
    DEPT. NUMBER 478150
    P.O. BOX 790100
    ST LOUIS, MO  63179-9933
    VAD1
    VAD2
    VAD3
    VAD4
    P.O. BOX 62251
    BALTIMORE, MD  21264-2251
    VAD1
    VAD2
    VAD3
    VAD4
    P.O. BOX 660481
    DALLAS, TX  75266-0481
    VAD1
    VAD2
    VAD3
    VAD4
    3525 PIEDMONT RD.
    BUILDING FIVE
    SUITE 300
    ATLANTA, GA  30305

  • Immediate help required with decode statement in scheduling jobs

    Hi
    Iam trying to change a job that runs my procedure using dbms_job.. Here is the output I got.
    Can someone help me why this is giving me errors.
    <code>
    SQL> exec dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24'));
    BEGIN dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24')); END;
    ERROR at line 1:
    ORA-06550: line 1, column 30:
    PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
    statement only
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    </code>
    Thanks in advance

    A possible solution:
    declare
    v_next_varchar varchar2(30);
    v_next_date date;
    begin
    select decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),
                              -1,'trunc(sysdate) +18.5/24',
                                 1,'trunc(sysdate) +1+6.5/24'
    into v_next_varchar
    from dual;
    execute immediate 'select ' || v_next_varchar || ' from dual ' into v_next_date;
    dbms_job.next_date(22, v_next_date);
    commit;
    end;Bye, Aron

  • Need help on decode statement

    I had the table as follows :
    ITEMCODE TEDCODE AMOUNT
    AAAA BED 12345
    AAAA EDU CESS 1234
    AAAA SHECESS 123
    AAAA CST 3% 12456
    AND SO ON.
    Now i want to convert the rows in Column heading TEDCODE to columns. But i want the specific rows like BED, EDU CESS, SHECESS in one column suppose EXCISE, and the other row i.e CST 3% in other column under heading TAX.
    Please help me how i can do it using Decode statement.

    SQL> create table t (itemcode varchar(4),tedcode varchar(10),amount number);
    Table created.
    SQL> insert into t values('AAAA','BED',12345);
    1 row created.
    SQL> insert into t values('AAAA','EDU CESS',1234);
    1 row created.
    SQL> insert into t values('AAAA','SHECESS',123);
    1 row created.
    SQL> insert into t values('AAAA','CST 3%',12456);
    1 row created.
    SQL> select itemcode, tedcode,decode(tedcode,'CST 3%',null,amount) EXCISE, decod
    e(tedcode,'CST 3%',amount,null) TAX from t;
    ITEM TEDCODE    EXCISE                                          TAX
    AAAA BED        12345
    AAAA EDU CESS   1234
    AAAA SHECESS    123
    AAAA CST 3%                                                   12456

  • Help! format of decode statements with between or signs ?

    Looking for an example of a decode statement with either a between/and or < > signs in the comparison field.
    I have tried several variations, but none seem to work. Any help would be appreciated.
    Here's a sample that doesn't work.
    Select course_no, section_no, capacity, decode(capacity, (capacity < 12), Less than 12, (capacity between 13 and 15), 13-15, More than 15) from section;
    Thanks in advance

    Hi,
    There is a limitation to the Case function, as it cannot be used in the PL/SQL (atleast upto Oracle 8i). Therefore, the only option left is Decode.
    If you have to compare the values like capacity < 12 then display Less than 12. You can write it using combination of other functions.
    For e.g. follow the steps below:-
    1)If you deduct 12 from capacity : (capacity-12) [it will give result as +ve, 0 or -ve.]
    2)If you have to narrow down the values to above three options, use function sign:
    SIGN(capacity-12) [will result into +1, 0 or -1]
    3)Then compare the values using Decode:
    DECODE(SIGN(capacity-12),-1,Less than 12,Greater than or equal to 12)
    The Decode can be used inside Decode(nested Decode) in above steps to compare more than one values (range between) to get the desired result. Hope have made it clear enough. If not, please let me know.
    Cheers.
    Yogesh D.

  • Need help in decode statement to check condition

    Hi All,
    I have table emp with below structure
    empno
    work_phone_no
    Home_phone
    cell_phone
    For the employee if work_phone & Home Phone is null then in place of work_phone we need to send the cell_phone number.
    How to use the decode statement in this scenario to test for Home_phone
    condition in the select statement.
    select DECODE (work_phone_no,
    null, cell_phone_no,office_phone_no )
    from emp
    Thanks

    Hi,
    Given the data you posted:
    empno work_phone_no home_phone_no cell_phone_no
    1     null          80032108556   8003210855
    2     null          null          8003210000 and your requirement is
    "If work & Home nunbers are null then display cellhone number in place of workphone number "
    , then, as John said, you do not want the results you posted. You want:
    1 null       80032108556
    2 8003210000 null That is, on the first row, where empno=1, the work_phone_no is NULL because the home_phone_no is NOT NULL, and cell_phone_no is only to be shown when both of the other phone numbers are missing.
    To get the results above, use CASE:
    SELECT  empno
    ,       CASE
                WHEN  work_phone_no IS NULL
                  AND home_phone_no IS NULL
                THEN cell_phone_no
                ELSE work_phone_no
            END  AS work_phone_no
    ,       home_phone_no
    FROM    ...If you really do want the results you posted, then, as John said, use NVL.

  • Need help in DECODE statement

    I have a scenario like
    if account no is 0001 or 0002 or 0003 then account_flag <> 'Y'
    ELSE IF account no is 00009 then account_status <> 'Y'
    How to write DECODE statement for this in Where part of select statement
    Note: account_flag and account_status are 2 different columns in same table

    Hi,
    I assumed you mean to update the values?
    You can use case for that:
    MHO%xe> select * from same_table;
    ACCOU A A
    0001  N N
    0002  N N
    0003  N N
    0004  N N
    0005  N N
    0006  N N
    0007  N N
    0008  N N
    0009  N N
    0010  N N
    10 rijen zijn geselecteerd.
    Verstreken: 00:00:01.90
    MHO%xe> update same_table
      2  set    account_flag  = case when account_no in ('0001', '0002', '0003')
      3                              then 'Y'
      4                              else account_flag
      5                         end
      6  ,      account_status = case when account_no = '0009'
      7                              then 'Y'
      8                              else account_status
      9                         end;
    10 rijen zijn bijgewerkt.
    Verstreken: 00:00:00.15
    MHO%xe> commit;
    Commit is voltooid.
    Verstreken: 00:00:00.09
    MHO%xe> select * from same_table;
    ACCOU A A
    0001  Y N
    0002  Y N
    0003  Y N
    0004  N N
    0005  N N
    0006  N N
    0007  N N
    0008  N N
    0009  N Y
    0010  N N
    10 rijen zijn geselecteerd.
    Verstreken: 00:00:00.07
    MHO%xe> desc same_table
    Naam                                      Null?    Type
    ACCOUNT_NO                                         VARCHAR2(5)
    ACCOUNT_FLAG                                       VARCHAR2(1)
    ACCOUNT_STATUS                                     VARCHAR2(1)

  • How to determine INT and FLOAT in a DECODE statement

    Can anyone help me with the following problem:
    I have a column defined as a NUMBER(15,4). I am trying to determine the java type using the getScale() method in ResultSetMetaData. When the scale is greater than 0, then it is an float, else it is an int. In this case, the getScale() method should return 4. However, when querying with a DECODE statement on the NUMBER(15,4) field, the getScale() method always returns 0 and the value is therefore converted to an int. Anyone knows how to solve this problem?
    Thanks

    Alcides,
    Oracle NUMBER data type is mapped to "java.math.BigDecimal" class.
    You will find more information in the JDBC Developer's Guide and Reference which is part of the Oracle documentation and available from:
    http://www.oracle.com/technology/documentation/index.html
    Good Luck,
    Avi.

  • DECODE statement

    please can someone kindly code the following line of SQL using the DECODE statement:
    case when Student_Status in ('Registered','Repeat','Referral', 'Deferral')and GRADE <> 'MISSING' then EXAM1_RESULT else Null end as Valid_EX1
    It will be most appreciated.
    Thanks

    user607929 wrote:
    I'm ever so sorry, I keep sending the same Wrong thing.
    This is what i need translated to DECODE:
    "case when
    Student_Status in ('Registered','Repeat','Referral', 'Deferral') and GRADE is not 'MISSING'
    then EXAM1_RESULT
    else Null end as Valid_EX1"
    the issue is with the NOT 'MISSING' string.Check this. Just re-arrange of Andrés Muchiut post
    DECODE (
    STUDENT_STATUS
    ,'Registered',DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Repeat' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Referral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Deferral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    , null) Valid_EX1Hope this may help you...

  • Decode statement in a mapping involve Source Text File & Table.

    Hi All,
    Oracle 9i Warehouse Builder Client: 9.2.0.4.0
    Oracle 9i Warehouse Builder Repository: 9.2.0.2.0
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    Does OWB allow to use Decode statement in a mapping involves Source Text File and Oracle Table.
    My understanding is it's not possible, since OWB makes use of Sqlloader. For this work arround could be make use of External Table instead of Text Flat File.
    However I came across an old posting (June-2003) which says that this feature is available OWB 9.2.
    Following is the url:
    IF THEN LOGIC from Flat File to Table
    Can someone please confirm this?
    Thanks in Advance.
    Regards,
    Vidyanand

    Hi all,
    If you want to validate correctly this mapping you must to :
    1. Right click on the mapping, then Configure
    2. Right click on Sql Loader Data Files, then Create
    3. Verify that the location name is correct and complete the Data File Name
    4. OK
    The validation is now OK.
    I hope it will be help you
    Best Regards
    Samy

  • Help with Select Decode Round

    Hi, If anyone could help me with this. I need to round all these numbers in the DECODE but without repeating ROUND.
    This way works:
    SELECT title "Title", category "Category",retail "Current Price",
    DECODE(category,
    'COMPUTER',(ROUND(retail * 1.1,2)),
    'FITNESS', (ROUND(retail * 1.15,2)),
    'SELF HELP', (ROUND(retail * 1.25,2)),
    (ROUND(retail * 1.03,2)))"Revised Price"
    FROM books
    ORDER BY category, title;
    But I need something more like this:
    SELECT title "Title", category "Category",retail "Current Price",
    DECODE (ROUND((category,
    'COMPUTER',retail * 1.1,
    'FITNESS', retail * 1.15,
    'SELF HELP', retail * 1.25,
    retail * 1.03)"Revised Price"),2)
    FROM books
    ORDER BY category, title;
    so that ROUND is not repeated more than once..they all need to be rounded to two decimal places.
    any help would be great. Thanks

    your second is close. You need to round the decode statement. like this:
    SELECT title "Title", category "Category",retail "Current Price",
           ROUND(DECODE(category, 'COMPUTER',retail * 1.1,
                                  'FITNESS', retail * 1.15,
                                  'SELF HELP', retail * 1.25,
                                  retail * 1.03),2) "Revised Price"
    FROM books
    ORDER BY category, title;Note that the alias (I assume) revised Proce needs to go outside of both the decode and the round.
    John

  • Problem with DECODE statement while migrating forms to 6i

    Hi,
    I'm migrating a form from 5 to 6i. When I compiled the form, I got this error witha decode statement.
    The error is
    Error 307 at line 15 column 7
    too many declarations of "DECODE" match this call
    The trigger has this code:
    IF :PRUN_RECS_INSERTED = 'Y' THEN
          RETURN ;
       END IF ;
       INSERT INTO GJBPRUN
        ( GJBPRUN_JOB,
          GJBPRUN_ONE_UP_NO,
          GJBPRUN_NUMBER,
          GJBPRUN_ACTIVITY_DATE,
          GJBPRUN_VALUE )
       SELECT :KEYBLCK_JOB,
              :ONE_UP_NO,
               GJBPDFT_NUMBER,
               SYSDATE,
          DECODE(GJBPDFT_VALUE, 'SYSDATE',
                          DECODE(GJBPDEF_LENGTH,'11',TO_CHAR(SYSDATE,'DD-MON-YYYY'), SYSDATE),
                          GJBPDFT_VALUE)
       FROM   GJBPDFT G, GJBPDEFEdited by: Charan on Mar 16, 2011 9:15 AM

    Hi Charan
    i think it's all about using both CHARACTER and DATE values at the same time in a DECODE statment u should either use char or date datatype.
    DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle Database returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.
    e.g.
    If expr and search are character data, then Oracle compares them using nonpadded comparison semantics.
    expr, search, and result can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2.
    The string returned is of VARCHAR2 datatype and is in the same character set as the first result parameter.
    for more pls have a look here
    Hope this helps,
    Regards,
    Abdetu...

  • How to replace huge decode statements with lookups to some simple code/key

    I have a legacy PL/SQL application, composed of many very huge decode statements. And the most terribe one is that the guys who develops the application left the company now, leaves no documentation.
    We are trying to read and understand those PL/SQL programs, and I'm asked to replace those huge decode statements with lookups to some simple code/key tables? But I have no idea about how to design such code/key tables. Is there any one who has similar experience may help me? Besides code/key tables, any idea will be welcome.
    Thank you very much!

    Not sure what your data looks like but sometimes decode can be replaced with more appropriate functions, ie;
    SQL> with t as (
       select 'DAY' a, 30 b, null c, null d from dual union all
       select null a, null b, 'MONTH' c, 12 from dual)
    select coalesce(b,d)
    from t
    COALESCE(B,D)
               30
               12
    2 rows selected.
    SQL> with t as (
       select 'DAY' a, 30 b, null c, 0 d from dual union all
       select null a, 0 b, 'MONTH' c, 12 from dual)
    select greatest(b,d)
    from t
    GREATEST(B,D)
               30
               12
    2 rows selected.

  • Decode statement in Select line of a View Object Query

    I attempted to create a view object in expert mode with a customized query.
    The query had a decode statement in the select line of the query. The view
    object compiled correctly but gave an error when run.
    ex: select .... decode(CrpSchools.SCHOOLS_ID,null,CrpCustSchools.SCHOOL_NAME,CrpSchools.SCHOOL_NAME) SCHOOL_VALUE, ...
    from ....
    where ....
    The error was that school_value does not exist in the statement. I got the error when
    doing a vo.executeQuery().
    When I removed the decode statement everything worked correctly. Does anyone know if
    the decode statement cannont be used in the select line of a query in a view object?
    Or maybe I was linking the query column (SCHOOLS_ID) up to the view attribute (SCHOOL_VALUE) incorrectly in the
    Attribute Mappings tab of the VO wizard?

    There should be no problem using a DECODE() statement, provided that you've aliases the column as you have done.
    At design time, if you click on the (Test) button, does your query test ok?
    Are you by chance applying a custom where clause at runtime?
    If so, are you saying:
    setWhereClause("yourtable.column_alias = ?";
    or are you doing:
    setWhereClause("column_alias = ?";
    for an expert-mode query, you'll need to use the latter syntax.

  • Logical Standby SQL Apply Using Incorrect Decode Statement

    We are seeing statements erroring out on our logical standby that have been rewritten (presumably by sql apply) with decode statements that don't appear to be correct. For example, here is one of the rewritten statements.
    update /*+ streams restrict_all_ref_cons */ "CADPROD"."OMS_SQL_STATEMENT" p
    set *"APPLICATION"=decode(:1,'N',"APPLICATION",:2)*,
    "STATEMENT"=dbms_reputil2.get_final_lob(:3,"STATEMENT",:4)
    where (:5='N' or(1=1 and (:6='N' or(dbms_lob.compare(:7,"STATEMENT")=0)or(:7 is null and "STATEMENT" is null)))) and(:8="APPLICATION")
    The problem comes in, we believe, with the attempt to write the value "APPLICATION" to the application column which is only a 10 character field. the value for the :1 bind variable is "N" and the value for :2 is null.
    We see the following error on the logical standby:
    ORA-00600: internal error code, arguments: [kgh_heap_sizes:ds], [0x01FCDBE60], [], [], [], [], [], []
    ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [kxtoedu+54] [PC:0x2542308] [ADDR:0xFFFFFFFFFFFFFFFF] [UNABLE_TO_READ] []
    ORA-12899: value too large for column "CADPROD"."OMS_SQL_STATEMENT"."APPLICATION" (actual: 19576, maximum: 10)
    Is this a configuration issue or is it normal for SQL Apply to convert statements from logminer into decode statements?
    We have an Oracle 10.2.0.4 database running on windows 2003 R2 64-bit os. We have 3 physical and 2 logical standby's, no problems on the physical standbys.

    Hello;
    I noticed some of your parameters seem to be wrong.
    fal_client - This is Obsolete in 11.2
    You have db_name='test' on the Standby, it should be 'asadmin'
    fal_server=test is set like this on the standby, it should be 'asadmin'
    I might consider changing VALID_FOR to this :
    VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES)Would review 4.2 Step-by-Step Instructions for Creating a Logical Standby Database of Oracle Document E10700-02
    Document 278371.1 is showing its age in my humble opinion.
    -----Wait on this until you fix your parameters----------------------
    Try restarting the SQL Apply
    ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATEI don't see the parameter MAX_SERVERS, try setting it to 8 times the number of cores.
    Use these statements to trouble shoot :
    SELECT NAME, VALUE, UNIT FROM V$DATAGUARD_STATS;
    SELECT NAME, VALUE FROM V$LOGSTDBY_STATS WHERE NAME LIKE ;TRANSACTIONS%';
    SELECT COUNT(1) AS IDLE_PREPARERS FROM V$LOGSTDBY_PROCESS WHERE
    TYPE = 'PREPERER' AND STATUS_CODE = 16166;Best Regards
    mseberg
    Edited by: mseberg on Feb 14, 2012 7:37 AM

Maybe you are looking for

  • How do I get the codec for .mov files recorded on an ipad, so I can edit them in premiere El. 12?

    I have .mov files recorded from an ipad with these specs: AAC, Mono, 44.100 KHZ H.264 320x568 (yes the ipad was used vertically, not horizontally) 29.96 fps I want to edit them in premiere 12, but get this error message: This type of file is not supp

  • Error in Running a dimension ( BIB-9509 Oracle OLAP did not create cursor.)

    oracle.dss.dataSource.common.QueryRuntimeException: BIB-9509 Oracle OLAP did not create cursor. oracle.express.ExpressServerExceptionError class: OLAPI Server error descriptions: DPR: Unable to create server cursor, Generic at TxsOqDefinitionManagerS

  • Itunes 10.5 won't let me burn cd anymore

    Hi, Here is the deal. I have installed Itunes 10.5 on my computer (windows vista) and since I have not been able to burn cds. It seems like it starts and then nothing happens. Itunes is running as if the cd was being burned but the cd driver is not b

  • Trouble Syncing Roland TR-606 with Logic Pro

    Hello. I had this working before and I dont know what went wrong. The setup is like this Logic sending MIDI Clock > Midisport Interface > Kenton Pro Solo (set to send Sync24 out of the 'Through' port > Roland 606's MIDI sync input. When I start and s

  • Downloads will not open

    I'm trying to download a program and it seems to download but then claims it had to close although it did not start - I get the options "ignore" "report" or "relaunch". It has happened with multiple downloads now...I cannot actually open/run anything