How to handle Decode function?

Hi All,
I am using a dynamic sql query for deletion. here is the Query
DELETE FROM t_mob WHERE EXISTS (SELECT 1 FROM temp_sal
WHERE UPPER(sm_trans) IN ('CHG') AND sm_code IS NOT NULL AND fsyb_code = sm_code)
AND (fsyb_code, fsyb_code) NOT IN (
SELECT sm_code, vds_code FROM t_ven , temp_sal
WHERE UPPER(sm_trans) IN ('CHG') AND sm_code IS NOT NULL
AND vds_code = sm_code and vds_code <>'CQ' AND vds_code = sm_code) ;
Before running the above Query i have few list as CQ/YY/TT/GG and so on and this are called as vend.
Now when i am trying to run the 2nd inner query i am getting result as YY/TT9/GG...
But when i have run the 1st ineer Query then it is displaying result as "TT" which is geeting deleted from the table.
Now the requiremnet is when evere we have TT it should not delete that record..What i have analyzed that 2nd inner loop is appending with TT9 but where as 1st one is showing as TT and hence the records is geeting deleted.
How i can append 9 to the above query so that it matches and hence it will stop deleting those records.
Hope u have understood my problem.
Thanks,
Anoo..

got a little lost on what is going on but if you are just trying to change a TT9 into TT a decode as you mentioned or case
should work
with t as  (select t.column_value vendor_cd  from table(sys.odcivarchar2list('YY','TT9','GC','CQ','TT')   ) t)
select vendor_cd,  decode(vendor_cd,'TT9','TT',vendor_cd) new_vendor_cd  from t;
VENDOR_CD     NEW_VENDOR_CD
YY     YY
TT9     TT
GC     GC
CQ     CQ
TT     TT

Similar Messages

  • How to use Decode Function in Webi / Designer - BOE XI 3.1

    Hi All,
    I have a SQL query which needs to include in the webi report.
    Below is the query :
    SELECT
    SECURITY.SEC_CUSIP_NO "CUSIP", 
    SECURITY.STY_SEC_TY_CD "SECURITY TYPE",
    SECURITY.SEC_DERIVED_DESC_TX "SECURITY DESCRIPTION",
      SECURITY.sec_dep_teleg_de "FED DESCRIPTION",
      SEC_STND_PR "STANDARD/FACTORED PRICE",
      SEC_STND_PR_EFF_DT "STANDARD/FACTORED PRICE Date",
      SECURITY.SEC_YIELD_PR "YIELD PRICE",
      SECURITY.SEC_YIELD_PR_DT "YIELD RICE EFFECTIVE DATE",
      STND_PR_VND_VENDOR_CD "PRICE SOURCE",
      SEC_MATURITY_DT "MATURITY DATE",
      SEC_ISSUE_DT "ISSUE DATE",
                 CASE WHEN SECURITY.STY_SEC_TY_CD IN ('BA','CD','CDD','CDE','CDM','CDV','CP','CPD') THEN
                    (position.PSN_AVAIL_PAR_VL + position.PSN_COLLAT_PAR_VL) * (SECURITY.SEC_STND_PR) / 100
                 ELSE
                    (position.PSN_AVAIL_PAR_VL + position.PSN_COLLAT_PAR_VL) * (  (  SECURITY.SEC_YIELD_PR * DECODE (SECURITY.SEC_PRIN_FT, 0, 1, SECURITY.SEC_PRIN_FT))) / 100
                    * DECODE(SECURITY.STY_SEC_TY_CD, 'AMP', DECODE(NVL(SECURITY.SEC_MULTIPLIER_UNIT_VL,0), 0, 1, SECURITY.SEC_MULTIPLIER_UNIT_VL), 'MMP', DECODE(NVL(SECURITY.SEC_MULTIPLIER_UNIT_VL,0), 0, 1, SECURITY.SEC_MULTIPLIER_UNIT_VL), 'AMPT', DECODE(NVL(SECURITY.SEC_MULTIPLIER_UNIT_VL,0), 0, 1, SECURITY.SEC_MULTIPLIER_UNIT_VL), 1 )
                 END
            ) "MARKET VALUE"
    FROM SECURITY SECURITY
       ,   position position
    WHERE STND_PR_VND_VENDOR_CD = 'VT'
    AND SEC_MATURITY_DT > SYSDATE-1
    and SECURITY.sec_sys_id=position.sec_sys_id
    I could create a report which has selected objects and defined where condition from the above query. I have also created a variable for 'when' & 'then' condition but stuck at else part which contains 'DECODE' function.
    Please suggestions how to write the same at the report or designer level.
    Thanks,
    Rameez Shaikh

    Hi Rameez,
    Looking at the query you can create the object directly in the universe, either create two objects one for inner decode and use it in outer case logic. In report it is nothing but nested if logic. For eg.  If(a=b;1;(if(a=c;2;3))
    Thanks
    Gaurav

  • How to use decode function in oracle apex 3.2.1

    Hello Friends,
    how to use decode
    var_decode := 'decode'||'('|| var1 ||','|| -800000000000000||','||'.A'||','||
    appreciate your help.
    regards/kumar
    Edited by: kumar73 on Apr 23, 2010 12:25 PM
    Edited by: kumar73 on Apr 23, 2010 12:27 PM

    Hey just on this particular point, there's a handy PL/SQL method for escaping quotation characters which may reduce the complexity of the string.
    For example, if I had a string:
    I can't understand why quoting my 'quote' characters never seems to "work"!and I wanted to pass that into a variable, I could do this:
    vc_foo:= 'I can''t understand why my ''quote'' characters never seems to "work"!';or I could use the q function, whereby you enclose your string within a quote delimiter of your choice, like so:
    vc_foo:= q'^I can't understand why quoting my 'quote' characters never seems to "work"!^';
    note: I used the caret (^) character by convention but any valid character will do
    ...all of which leaves your original string more or less unadulterated.
    I find this particularly useful for generating dynamic SQL and dynamic PL/SQL, as it leave the query looking a tad more readable, although if you are chaining together multiple strings with double-pipes, it can make it a little muddier. I find it particularly useful if I'm going to deal with string data from, for example, a field with Irish-derived surnames such as "O'Reilly"...
    Give it a go!

  • How to use decode function

    Hello Friends,
    I have a query that has different columns and I am not sure what the data type of each column is ...
    I want to use decode function which displays the following if the value of the column is like this ..
    if the value of column is -714E ie -700000000000000 then display as .A
    if the value of column is -814E ie -800000000000000 then display as .B
    NOTE ; don't know which column is having the value - and i don't know the data type of the column is ..
    got to use the decode function for all the columns selected ..
    I want to use decode function pls let me know how to write for this kind of requirement.
    appreciate your help in this rgds.
    thanks/kumar

    Dear Sir / Madam,
    Thanks for your understanding.
    Right now I am facing a unique problem.
    I am using decode function in a select statement. The columns are dynamic some columns are of type number and some are varchar datatypes. I want to apply decode function for every column irrespective of datatype.
    What i am finding difficult is if the column is a number datatype , the decode funciton is working good but if the column datatype is varchar or char datatype then i am getting ..
    here's the decode function..
    decode (CHAI.EVNDRIVE,
    -800000000000000,'.A',
    -700000000000000, '.B',
    -600000000000000 ,'.C',
    -500000000000000 , '.D',
    -400000000000000 , '.E',
    -300000000000000 , '.F',
    -200000000000000, '.G',
    -100000000000000 , '.H',
    -1000000000, '.R' ,CHAI.EVNDRIVE ) EVNDRIVE
    report error:
    ORA-01722: invalid number
    pls let me know how to over come this kind of scenario.
    is their a way to find whether the column datatype is number or char , so that i can check the column datatype before the decode funciton is applied ..
    thanks ..
    kumar

  • How to write decode function in plsql

    hi
    guys
    can u plz help me in this topic
    .........

    Hi ,
    You could use the decode function in an SQL statement as follows:
    SELECT supplier_name,
    decode(supplier_id,      10000,      'IBM',
         10001,      'Microsoft',
         10002,      'Hewlett Packard',
              'Gateway') result
    FROM suppliers;
    The above decode statement is equivalent to the following IF-THEN-ELSE statement:
    IF supplier_id = 10000 THEN
    result := 'IBM';
    ELSIF supplier_id = 10001 THEN
    result := 'Microsoft';
    ELSIF supplier_id = 10002 THEN
    result := 'Hewlett Packard';
    ELSE
    result := 'Gateway';
    END IF;
    The decode function will compare each supplier_id value, one by one.
    Regards,
    xaheer

  • How to use DECODE function in Exspression?

    Hi,
    Can we use DECODE in Expression?
    I'm trying to use DECODE function but there is an error during the validation. But when i validate the mapping, it is successfully compiled but it is failed during deployment.
    But if I use CASE instead of DECODE, it works fine.
    Can we use DECODE in OWB???
    Thanks
    Raj

    Hi,
    In OWB 10gR2, if your are using only one DECODE in an expression, it's working. The package will compile when deploying the mapping. OWB will replace the DECODE by a CASE.
    But when you are using nested decode in an expression ( for example : decode(col1, 1, 'M', decode(col2, 'Madame', 'Mme', null)) ) only the first one is replaced by a case at deployment.
    In ROW_BASED mode, text of the expression is used outside of an sql statement and deployment will fails with "PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL statement only."
    If operating mode for the mapping is set to SET_BASED, it's working because the expression is used in an sql statement.
    I have logged a SR in metalink for this issue and a bug is opened (bug 5414112).
    But I agree with you, it's better to use case statement.
    Bernard

  • How to handle help function type in a dynpro

    Hello
    I've made a button with the functiontype H ( Help Function) and now I'd like to react on this button.
    But in the POV AND POH I can't call a module, because for this I need an input-/outputfield.
    (FIELD "FIELDNAME" MODULE "MODULENAME").
    My question is, how can I react on this functiontype / "HelpButton" ?
    Thx in advance
    Christian

    There are two ways:
    First************
    Process after input.
    module user_command.
    Code inside module user_command:
    IF SY-UCOMM = 'H'      "Function code for help button
    *fetch all the list and store into an internal table.
    * Call another screen to display the internal table.
    endif.
    Second*****************
    Create an input field on the screen and make it invisible.
    Process after input.
    module user_command.
    Code inside module user_command:
    IF SY-UCOMM = 'H'      "Function code for help button
    *fetch all the list and store into an internal table.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
    *         DDIC_STRUCTURE         = ' '
          retfield               = 'name of field of internal table which is to be returned to invisible dynpro field'
    *         PVALKEY                = ' '
         dynpprog               = 'program name'
         dynpnr                 = 'dynpro number'
         dynprofield            =  'name of invisible dynpro field'
    *    STEPL                  = 0
    *    WINDOW_TITLE           =
    *    VALUE                  = ' '
        value_org              = 'S'
    *   MULTIPLE_CHOICE        = ' '
    *   DISPLAY                = ' '
    *   CALLBACK_PROGRAM       = ' '
    *   CALLBACK_FORM          = ' '
        TABLES
          value_tab              = Internal table containing list to be displayed
    *     FIELD_TAB          =
    *     RETURN_TAB             =
    *      dynpfld_mapping        =
       EXCEPTIONS
         parameter_error        = 1
         no_values_found        = 2
         OTHERS                 = 3
    endif.

  • Wireless keyboard operation on ipad - how to handle touch functions like email garbage can?

    Received gift of wireless keyboard for my ipad. Managed bluetooth pairing and am stumped on functions other than simple typing. Can any keys be used for functions like the garbage can in email?

    As far as I know it just replaces the onscreen keyboard, the iPad is a touch device and you will need to touch the screen for some things. The function keys for display brightness control, iPod and volume control also work.

  • How to convert Oracle function in UDB

    Hi ,
    i am writing this function in oracle.Could you please convert this function in UDB because i am new in this and dont know how to use decode function in UDB
    Please following is the code for oracle.
    CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
    return number
    as x number;
    begin
    select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
    SELECT
    prereq_count,
    username
    FROM
    table1
    group by username ;
    return x;
    end fun;
    Regards
    Vishal

    First, you posted in the wrong forum for UDB, this is DB2 on z/OS
    Secondly, your question is not SAP related (at least I can't see that).
    Thirdly, you posted the same question for SQL-Server:
    want to convert function in SQL Server 2000
    Markus

  • How to use decode concept in htp.p?

    Hi All,
    How to use decode function in htp.p syntax?
    Thanks,
    Anoo..

    Hi,
    Could you please give more details on what you like to achieve? Decode function works only in sql query.
    You can first do sql query, and then do htp.p.
    Or you can use PL/SQL IF or CASE statements.
    You can also create custom decode function if you need.
    Regards,
    Oleg

  • I bought a cd with Lightroom 5. After installation and registration I am not able to use 'help' function and I cannot update the software. I anyone able to give me a hint how to handle it? Thank you ind advance Karl

    I bought a cd with Lightroom 5. After installation and registration I am not able to use 'help' function and I cannot update the software. Is anyone able to give me a hint how to handle it?
    Thank you in advance
    arl

    Hi Keith, sorry for my late reply.
    Surely I am able to connect to the help function when Icontact the website
    of AdobeLR5.The problem is as follows,
    When I open LR5 on my computer and work with it and try to open the help
    function in the software, I don't get it.
    When I bought the CD I was naiv enough to believe that I get an independent
    working software. I learned in the meantime, that the seller does not allow
    to work with, without being connected to them.
    I don't believe that I am paranoid, but I like to buy something and use it
    without to inform the supplier that I do it. Otherwise I could have bought
    the license fpr LR5 via internet.
    Best regards
    Karl
    2015-01-02 13:42 GMT+01:00 kglad <[email protected]>:
        I bought a cd with Lightroom 5. After installation and registration I
    am not able to use 'help' function and I cannot update the software. I
    anyone able to give me a hint how to handle it? Thank you ind advance Karl
    kglad <https://forums.adobe.com/people/kglad?et=watches.email.outcome>
    marked Keith_Reeder
    <https://forums.adobe.com/people/Keith_Reeder?et=watches.email.outcome>'s
    reply on I bought a cd with Lightroom 5. After installation and
    registration I am not able to use 'help' function and I cannot update the
    software. I anyone able to give me a hint how to handle it? Thank you ind
    advance Karl
    <https://forums.adobe.com/thread/1669640?et=watches.email.outcome> as
    helpful. View the full reply
    <https://forums.adobe.com/message/7059196?et=watches.email.outcome#7059196>

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to handle JCO Exceptions at JCO (RFC) function call

    Hello Forum,
    I am implementing an JCO Server scenario.
    I use dynamic repositories like Example7.java from the JCO documentation.
    Example7 throws an JCO.AbapException if anything went wrong, e.g. the function is not implemented.
    How to react on this AbapException?
    The examples in SAP Help documentation only catch
    SYSTEM_FAILURE and COMMUNICATION_FAILURE.
    All other RFC modules I have seen which declare the function modules to be used by dynamic JCO repositories (like Example7.java) do not define any other Exception parameters.
    But these two are only thrown and caught when something with communication went completely wrong, e.g. RFC not found.
    But when RFC can be reached and the JCO Server is executing the Java method, an AbapException could be thrown on error. How to react on this?
    In my implementation based on the examples I always get a ABAP dump. The dump says:
    Exception named  without message text. Why that name?
    How to handle this type of exception in order to avoid the dump?
    Can anyone post an example please?
    Thanks,
    Carsten
    Edited by: Carsten Schön on Apr 15, 2008 4:22 PM
    Edited by: Carsten Schön on Apr 15, 2008 4:24 PM

    Hi Micky,
    thanks for your quick response.
    If so, to throw JCO.AbapException on JCO Server side is not correct?
    What I do is throwing the JCO.AbapException (like in the JCO Example 7).
    At the RFC call in APAB I handle both exceptions SYSTEM_FAILURE and COMMUNICATION_FAILURE like
    CALL FUNCTION 'MY_JCO_FUNCTION_MODULE'
        DESTINATION JCO_DEST
        <...>
        EXCEPTIONS
          SYSTEM_FAILURE        = 1  MESSAGE RFC_MESS
          COMMUNICATION_FAILURE = 2  MESSAGE RFC_MESS.
    This works as far something with RFC is wrong, e.g. Server can not find the function or Server not reachable.
    But the AbapException thrown by the JCO Server (Java) is not handled that way. Why?
    Sorry if this is the wrong forum but I tried posting in Netweaver integration and got no answer for 1 week and because it's ABAP related I thought the topic suites here.
    Carsten
    Edited by: Carsten Schön on Apr 15, 2008 5:10 PM

  • How can i use this expression in DECODE function?

    My PNO table formart is
    PNO PDate PCount
    P001 08/27/05 09:45 20
    P001 08/27/05 09:50 10
    P002 08/27/05 03:40 20
    P003 08/28/05 11:00 20
    P003 09/28/05 10:00 20
    P003 08/27/05 11:00 10
    P003 09/27/05 04:00 50
    I want to display total pcount for shift1(morning) and shift2(evening) & the date is 08/27/05
    PNO Shift1(08/27/2005 08:00 to 12:30) Shift2(08/27/2005 02:00 to 05:30)
    P001 30 0
    P002 0 20
    P004 10 50
    So for shift1 condition is:
    pdate>=08/27/2005 08:00 and pdate<=08/27/2005 12:30
    So for shift2 condition is:
    pdate>=08/27/2005 02:00 and pdate<=08/27/2005 05:30
    If i tried to give this expression in decode function , its not working.
    Please give me the sql query to solve this problem.
    Millions of thanks in advacne

    forgot to paste the output for a given date.
    SQL> create table pno
      2  (pno    varchar2(32)
      3  ,pdate  date
      4  ,pcount number)
      5  /
    Table created.
    SQL>
    SQL> insert into pno values('P001', to_Date('08/27/05 09:45', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P001', to_Date('08/27/05 09:50', 'mm/dd/yy hh:mi') ,10)
      2  /
    1 row created.
    SQL> insert into pno values('P002', to_Date('08/27/05 03:40', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL>
    SQL> insert into pno values('P003', to_Date('08/28/05 11:00', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('09/28/05 10:00', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('08/27/05 11:00', 'mm/dd/yy hh:mi') ,10)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('09/27/05 04:00', 'mm/dd/yy hh:mi') ,50)
      2  /
    1 row created.
    SQL> select pno,sum(pcount) "Morning Shift Count"
      2  from pno
      3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 08:00'
      4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 12:30'
      5  group by pno
      6  /
    PNO                              Morning Shift Count                           
    P001                                              30                           
    P003                                              10                           
    SQL> select pno,sum(pcount) "Evening Shift Count"
      2  from pno
      3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 02:00'
      4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 05:30'
      5  group by pno
      6  /
    PNO                              Evening Shift Count                           
    P002                                              20                           

  • How to use a decode function

    I want to use the following with decode, recently started on BODS.
    Can you please provide the steps to use decode function
    in source tabke fieldname is ordid and in target fieldname is Orderid
    decode(Order_ID = 1709,lpad(Order_ID,7,'700'),Order_ID)
    thank you very much for the helpful i

    1) In the mapping tab of target column, click on Functions, select Miscellaneous Functions category, you can find decode function in it. Lpad can be found in String functions category.
    OR
    2) You can directly script this or paste this code at the mapping tab. In this case, remove the Order_ID from the script wherever used, drag and drop this column from the input schema of Query transform to avoid the syntax error. 
    Regards,
    Suneer

Maybe you are looking for

  • BPM-70830 while deploying process in BPM Composer

    Hi, I got these errors When I try to deploy a bpm project which created and developed in BPM Composer(11.1.1.6.0). Can anyone help me? Thanks a lot! There're already 34 processes successfully deployed with BPM Composer before this error occur, howeve

  • Macbook to TV(S-video/composite)

    Hey I recently bought a mini DVI to Video adapter for my Macbook so that I can connect it to a Television set. Connected with S-video & Composite(yellow jack), both ways does not connect properly.. what shows on the TV is in black White and the pictu

  • Error: AeInData.cpp-712 and VideoSegmentsImpl.cpp-114

    This error occurs both when I try to drag a clip with a speed adjustment applied to it and now randomly when I export to Windows Media Video Premiere Pro Debug Error: [..\..\Src\AESupport\AEInData.cpp-712] I'm also getting the below errors, Premiere

  • Logging ACL entry to Syslog server

    I have a simple access-list configured on the outside of an ASA access-list outside_in permit tcp any host x.x.x.x eq 80 access-list outside_in permit tcp any host x.x.x.x eq 443 access-list outside_in deny ip any any Could someone please post a samp

  • Time capsule does not appear in the finder.

    My time capsule appears in airport utility. It is ready to go. I have it on ethernet because airport isn't a very powerful wireless router. The time capsule does not appear in the finder. It does not appear in the disc utility. It does not appear in