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

Similar Messages

  • 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 use Decode with a variable

    Maybe you've seen this done.
    I want to take statement strMenu4 and subtract the previous value
    that is stored in an array as shown in strMenu5.
    My problem is this change as shown in strMenu5 produces
    an error code:
    ORA-00904 invalid column name
    So either I'm coding something wrong or it can't be done within the
    SUM(decode) construct. If I replace the variable with a literal
    like 1000 the code works:
    SUM(decode(name,'DBWR lru scans', c1.value) - 1000) DBWR_lru_scans
    but with an array variable or even a constant the code fails:
    SUM(decode(name,'DBWR lru scans', c1.value) - Array(3)) DBWR_lru_scans, "
    Any ideas how I can use Decode with a variable and not have it interrupt it
    as a invalid column name?
    Thanks,
    Joseph Karpinski
    [email protected]
    [email protected]
    strMenu4 = "SELECT d1.instance, " _
    & " to_char(sysdate, 'dd-mon-yy hh24:mi:ss') start_time, " _
    & " SUM(decode(name,'DBWR buffers scanned', c1.value)) DBWR_buffers_scanned, " _
    & " SUM(decode(name,'DBWR lru scans', c1.value)) DBWR_lru_scans, " _
    & " SUM(decode(name,'db block gets', c1.value)) db_block_gets , " _
    & " SUM(decode(name,'consistent gets', c1.value)) consistent_gets , " _
    & " SUM(decode(name,'physical reads', c1.value)) physical_reads " _
    & " from dual, v$sysstat c1, v$thread d1 " _
    & " group by d1.instance "
    strMenu5 = "SELECT d1.instance, " _
    & " to_char(sysdate, 'dd-mon-yy hh24:mi:ss') start_time, " _
    & " SUM(decode(name,'DBWR buffers scanned', c1.value) - Array(2)) DBWR_buffers_scanned, " _
    & " SUM(decode(name,'DBWR lru scans', c1.value) - Array(3)) DBWR_lru_scans, " _
    & " SUM(decode(name,'db block gets', c1.value) - Array(4)) db_block_gets , " _
    & " SUM(decode(name,'consistent gets', c1.value) - Array(5)) consistent_gets , " _
    & " SUM(decode(name,'physical reads', c1.value) - Array(6)) physical_reads " _
    & " from dual, v$sysstat c1, v$thread d1 " _
    & " group by d1.instance "

    Re-posting in the SQL and PL/SQL forum.
    It's more appropriate.
    Thanks,
    Closing

  • How to Use Decode for manipulating time

    How can i use Decode function to manipulate time...
    Example
    suppose ive employee and his time in...i want to display status field by using decode,which reflects if that employee came after 09:15:00 the status='L' else this will print 'P'
    i tried this
    SELECT pin_code,DECODE( to_char(ACCESS_TIME,'HH24:MI:SS'>'09:15:00','l','P'))STATUS
    FROM ATTENDANCE_REG
    this query hasn't work...
    waiting for reply
    Regards
    Danish Hayder

    SQL> select case when to_number(to_char(sysdate,'sssss')) > 33300 then 'L'
      2              else 'P' end status
      3  from dual;
    S
    L
    1 row selected.                                                                                                                                                                                                                                                                                                                                           

  • 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 use decode to calculate sum for different date range

    I'm stuck with decode() function:
    I have a table like this:
    (project_id, approve_date, value, builder_code)
    I want to write a SQL query to get sum of values for different month of the approve_date, and group by builder_code)
    The result is like this:
    builder_code Sum(value)_Sep-03 Sum(value)_Oct-03 Sum(value)_Nov03
    1001 1,299 1,322 990
    1002 3,332 1,222 333
    I tried to use decode for this question but could not get the answer.
    Thanks a lot

    I don't think you need a DECODE() here. I'd do something like this-
    create table builder (
        project_id number,
        approve_date date,
        value        number,
        builder_code number
    insert into builder values( 1, to_date('09-01-2003', 'MM-DD-YYYY'), 100, 990 )
    insert into builder values( 2, to_date('09-03-2003', 'MM-DD-YYYY'), 150, 990 )
    insert into builder values( 3, to_date('09-05-2003', 'MM-DD-YYYY'), 250, 990 )
    insert into builder values( 3, to_date('09-05-2003', 'MM-DD-YYYY'), 250, 333)
    SELECT sept.builder_code, sept.sept_sum, oct.oct_sum
    FROM (SELECT builder_code, sum(value) sept_sum
            FROM builder
           WHERE approve_date >= to_date('09-01-2003','MM-DD-YYYY')
             AND approve_date < to_date('10-01-2003','MM-DD-YYYY')
           GROUP BY builder_code) sept,
         (SELECT builder_code, sum(value) oct_sum
            FROM builder
           WHERE approve_date >= to_date('10-01-2003','MM-DD-YYYY')
             AND approve_date < to_date('11-01-2003','MM-DD-YYYY')
           GROUP BY builder_code) oct
    WHERE oct.builder_code(+) = sept.builder_code
    BUILDER_CODE   SEPT_SUM    OCT_SUM
             333        250
             990        500Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • How to use "WHOSE" concept in Javascript

    Hi Scripters,
    I have one question about the difference in between Applescript & Javascript?
    My question is about this "WHOSE" concept in Javascript when compared as of to Applescript usage which made it very simple.
    The below mentioned Applescript code will select the entire page items in page 1 of document 1 whoever omiting those items whose geometric bounds are less than 0.
    tell application "Adobe InDesign CS4"
         set selection to (every page item of page 1 of document 1 whose (item 1 of geometric bounds is not less than 0))
    end tell
    Here in this above mentioned code I have used "WHOSE" concept to omit some specific page items, however using javascript it is not possible to use this WHOSE concept to simply the Javscript code.
    thanks

    Unfortunately lack of a nice filtering syntax is indeed one of the many flaws of the JavaScript language.
    Generally speaking we just write this in an ugly way with a for loop:
    var i, p, page=app.document[0].pages[0], s=[];
    for (i=0; i<page.pageitems.length; i++) {
      p = page.pageitems[i];
      if (!(p.geometricBounds[1] < 0)) {
        s.push(p);
    app.select(s);
    Some people like to use Marc Autret's whose and findItems functions though: see http://forums.adobe.com/message/3070983#3070983.

  • How to use "DECODE"

    may i know how to apply "DECODE" in SQL?

    Daphne,
    you can find the usage of decode here:
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/functions036.htm
    regards
    Rainer

  • How to Use OOPs concept in SAP develepment

    Dear all.
    I want to to the Seperate classes for the saparate forms.
    means if my form is TEST1.srf then i want to writh all related code in TEST.dll/ class...
    then i will call that class event in the main class. that is test..
    i am trying to Put the opps concept in the SAP but i cant find the way to pass the event
    form TEST class to TEST1 class..
    is it possible to write the code such way if yes then please tell me the code for this.
    thanks in advance.....

    Hi,
    Friend Function is used to access the private data of one class in another class.
    But in your Case Both the classes are global classes so you can use those directly here there is no need of using friend concept.
    I am posting the code which will provide detail functionality of friend in ooabap,please go through this you will get some information.
    class lcl_child definition deferred.
    class lcl_prent definition friends lcl_child.
      private setion.
           data  : credit_card_n type string.
    endclass.
    class lcl_child definition.
      public section.
       methods buy_toys.
    endclass.
    class lcl_child implementation.
       method buy_toys.
         date : lr_parent type ref to lcl_parent.
         create object lr_parent.
         write: lr_parent->credit_card_no.
       endmethod.
    endclass.
    Regards,
    PavanKumar.G
    Edited by: pavankumar.g on Jan 9, 2012 6:39 AM

  • 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 on the value part ?

    i have a query
    select
         col1, col2, col3
    from
         tab1, tab2
    where
         cond1= 'parameter1'     
    I need to modify this query to use a decode function instead of this parameter1.
    something like
    select
         col1, col2, col3
    from
         tab1, tab2
    where
         cond1= decode(parameter1, 'x','val1','val2')
    How can i use such a decode function on the value part ?
    IF i try this, it gives me no data found error....
    The following is also not working..IS there a way to do such cases ?
    select
         col1, col2, col3
    from
         tab1, tab2
    where
         cond1= ( select decode(parameter1, 'x','val1','val2') from dual )

    Of course it works...
    test@ORA10G>
    test@ORA10G> drop table table1;
    Table dropped.
    test@ORA10G> create table table1 (
      2    name        varchar2(50),
      3    condition1  varchar2(2),
      4    condition2  varchar2(10)
      5  );
    Table created.
    test@ORA10G> insert into table1 (name,condition1,condition2)
      2  values ('Hi there!!','xx','VAL1');
    1 row created.
    test@ORA10G> commit;
    Commit complete.
    test@ORA10G>
    test@ORA10G> select * from table1;
    NAME                           CO CONDITION2
    Hi there!!                     xx VAL1
    1 row selected.
    test@ORA10G>
    test@ORA10G> declare
      2    CodeL varchar2(3) := 'AB';
      3    CodeName varchar2(50) := '';
      4  begin
      5    select decode(CodeL,'AB','VAL1', CodeL)
      6    into CodeName
      7    from dual;
      8    dbms_output.put_line('CodeName: '||CodeName);
      9    select Name
    10    into CodeName
    11    from table1
    12    where condition1='xx'
    13    and condition2 in ( select decode(CodeL,'AB','VAL1', CodeL) from dual );
    14    dbms_output.put_line('CodeName: '||CodeName);
    15  end;
    16  /
    CodeName: VAL1
    CodeName: Hi there!!
    PL/SQL procedure successfully completed.
    test@ORA10G>pratz

  • How to use decode for a not = expression ?

    Hi ,
    i want to use in my seelct query decode( val1 , IF not = 'abc' , sum(val1)
    how can i express it as a not equal or even a >= in a decode ?
    kindly advise
    tks & rdgs

    hi ,
    i have used a function to resolve my issue
    tks for all the info
    rdgsYou would be better doing it all in SQL for performance reasons so you do not context switch between PL/SQL and SQL all the time...
    Ok, without using CASE...
    SQL> create table a (stupid_number_in_varchar  VARCHAR2(10));
    Table created.
    SQL> insert into a
      2  select '3' as stupid_number_in_varchar from dual union all
      3  select 'X' from dual union all
      4  select '4' from dual union all
      5  select 'X' from dual union all
      6  select '5' from dual;
    5 rows created.
    -- Strip out non numeric values...
    SQL> ed
    Wrote file afiedt.buf
      1  select decode(stupid_number_in_varchar, 'X', null, stupid_number_in_varchar) as mynum
      2* from a
    SQL> /
    MYNUM
    3
    4
    5
    -- Only take numbers >= 4 ...
    SQL> ed
    Wrote file afiedt.buf
      1  select decode(sign(mynum-4), -1, null, mynum)
      2  from (
      3       select decode(stupid_number_in_varchar, 'X', null, stupid_number_in_varchar) as mynum
      4       from a
      5*      )
    SQL> /
    DECODE(SIG
    4
    5
    -- Sum the result...
    SQL> ed
    Wrote file afiedt.buf
      1  select sum(mynum) from
      2  (
      3    select decode(sign(mynum-4), -1, null, mynum) mynum
      4    from (
      5         select decode(stupid_number_in_varchar, 'X', null, stupid_number_in_varchar) as mynum
      6         from a
      7         )
      8*   )
    SQL> /
    SUM(MYNUM)
             9
    SQL>

  • How to use decode for this

    Hi All
    I have one table called agreementproductkey and some columns namely Agreementproductid, keytext, fliename etc.
    There is some condition if agreement product id in not null and keytext field and fileaname field is null then i need to display the value as "NO FILE"
    This what i tried
    select decode(keytext || ' | ' || filename,null,'No File',keytext || filename) display_value, id return_value
    from agreementproductkey
    where agreementproductid = 3173
    But i didnt get the NO FILE when key text field and filename field is null for this agreementproductid.
    Thanks & Regards
    Srikkanth.M

    Hi Srikkanth,
    In the decode part, you have concatenated keytext and filename using '|' due to which it will never evaluate to null, and hence 'NOFILE' will never be displayed. CASE is a better option instead of DECODE.
    SQL> CREATE TABLE t (agreementid NUMBER, keytext VARCHAR2(10), filename VARCHAR2(10));
    Table created
    SQL> INSERT INTO t VALUES (123, 'ABC', 'ABCFile');
    1 row inserted
    SQL> INSERT INTO t VALUES (123, NULL, 'XYZFile');
    1 row inserted
    SQL> INSERT INTO t VALUES (123, 'PQR', NULL);
    1 row inserted
    SQL> INSERT INTO t VALUES (123, NULL, NULL);
    1 row inserted
    SQL> SELECT agreementid, keytext, filename,
      2         DECODE(agreementid, NULL, 'AGREEMENT NULL', DECODE(keytext || filename, NULL, 'NO FILE', 'FILE PRESENT'))
      3    FROM t;
    AGREEMENTID KEYTEXT    FILENAME   DECODE(AGREEMENTID,NULL,'AGREE
            123 ABC        ABCFile    FILE PRESENT
            123            XYZFile    FILE PRESENT
            123 PQR                   FILE PRESENT
            123                       NO FILE
    SQL> Regards
    Ameya

  • How to use decode or case function in this?

    Hi,
    I want to implement this condition in a query without using any user defined functions
    1.if (T_fees = 'ABC' then if (p_fees>0) then nvl(p_fees,0) else (p_fees + a_fees) else 0)
    2. if(g_fees <> (if t_fees = 'ABC' then if (p_fees>0) then nvl(p_fees,0) else (p_fees)
    else 0
    Is it possible to use any nested 'CASE' statement ?
    This is very urgent...
    Regards,
    Shilpa

    Hi,
    Is it possible to use any nested 'CASE' statement ?Yes it it possible.
    "afiedt.buf" 7 lines, 89 characters
      1  SELECT sysdate FROM DUAL
      2  WHERE 1 = (CASE WHEN 1=1  AND 2=2 THEN
      3             1
      4       ELSE
      5             2
      6*     END)
    SQL>/
    SYSDATE
    07-AUG-06
    1 row selected.
    "afiedt.buf" 11 lines, 139 characters
      1  SELECT sysdate FROM DUAL
      2  WHERE 1 = (CASE WHEN 1=1  AND 2=2 THEN
      3             CASE WHEN 3=3 AND 4=4 THEN
      4                     1
      5             ELSE
      6                     0
      7             END
      8       ELSE
      9             0
    10*     END)
    SQL>/
    SYSDATE
    07-AUG-06
    1 row selected.
    You can implement your logic.
    Regards

Maybe you are looking for

  • How do I set my printer to print in landscape?

    When I print what do I do to get it to print in landscape?

  • Problem with the light with bootcamp/windows 7 (64 bits)

    Hello there, After the last windows or bootcamp update, i got a problem with the light of my windows. I can't adjust it with all methods (windows power or F1/F2). I don't know how to solved it. Thanks for your help.

  • Hp mini 110 cnu9332tc2 enter current password

    HI..please help me with my HP mini 110 s/n {Personal Information Removed} p/n VJ924PA#UUF saying please enter current password..what can i do with this This question was solved. View Solution.

  • Thumbnail size when uploading pics to Websites

    Ok, I've asked this question on several sites with no luck and getting a little frustrated. When attempting to load photos from file on my local harddrive to facebook, 500px, flickr, email, etc. the the thumbnails are fixed in size. The option to enl

  • Battery Error 601 and Notebook will not boot

    My notebook will not bootup anymore.  It was running fine then I just closed the screen and went to class.  Usually this just puts it to sleep.  When I opened it back up, it would not start...  It was totally dead.  When I plug it into the charger, I