PLSQL Expression

I need write a default plsql expression or plsql funtionbody
condition is like this
case
when
:BUSINESS_UNIT = 'ORACLE IS' then
'Design Review'
when
:BUSINESS_UNIT IN ('ENTERPRISE','SIEBEL_ENTERPRISETWO') then
'FDD Review'
end;
pls suggest me how to write the expression or funtion body for the above code in default type

Hi,
Is this your requirement :-
In the following example, the data_typ1 object type is created with one member function prod, which is implemented in the CREATE TYPE BODY statement:
CREATE TYPE data_typ1 AS OBJECT
( year NUMBER,
MEMBER FUNCTION prod(invent NUMBER) RETURN NUMBER
CREATE TYPE BODY data_typ1 IS
MEMBER FUNCTION prod (invent NUMBER) RETURN NUMBER IS
BEGIN
RETURN (year + invent);
END;
END;
Use your custom code in the function.
Thanks
Pavan Kuma N

Similar Messages

  • (no inline validation error displayed)) condition type and plsql expression

    Hello all
    Is it possible to use a plsql expression (eg: (:REQUEST = 'PXX_LIST_ITEM')) AND (no inline validation error displayed)) condition type at the smae time ?
    HTMLDB must be testing a substitution variable when the conditional display section is set to 'no inline validation errors displayed'.

    Hello,
    I don't know for sure because I never used it, but I think you can use the pl/sql variable htmldb_application.g_inline_validation_error_cnt. This variable identifies number of inline errors found.
    You can also check if the variable htmldb_application.g_notification contains a value.
    Fred.

  • Report Template: Error processing PLSQL expression

    Hi Chaps,
    I hope you can help with this one.
    I want to highlight rows according to a column value. I've based this on this example, http://htmldb.oracle.com/pls/otn/f?p=18326:54:2079363195084288::::P54_ID:322
    I have a Column Template Condition, with "Use Based on a PL/SQL expression" set. In the expression field I have the following:
    #C003# >= 2
    When I run this I no data found and I get this error:
    ERR-1025 Error processing PLSQL expression. 22.78 >= 2
    Curiously #C003# seems to have been resolved to it's value 22.78 and it has attempted to evaluate the expression 22.78 >= 2
    any ideas what it wrong here?
    cheers,
    Derek

    Hi Derek,
    Presumably you are using a collection for this?
    If so, the columns in a collection are varchar2's so you need to convert c003 using:
    TO_NUMBER(#C003#) >= 2
    Regards
    Andy

  • Weird Pl/SQL Expression Default error

    I have a date field on one page that has a pl/sql expression default of:
    IF to_number(to_char(trunc(sysdate,'dd')) < 2 THEN
    to_char(trunc(sysdate,'mm'),'MM/DD/YYYY')
    ELSE
    to_char(add_months(trunc(sysdate,'mm'),-1),'MM/DD/YYYY')
    END IF;
    This works perfectly.
    However, on a different page, I have another date field with the same code for the default, and it is set to pl/sql expression, but when I run that page, I get the following error:
    ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "IF" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe ERR-9132 Error in PLSQL expression for item default code, item=P79_BEGIN_DATE
    I have deleted and recreated the field. Changed it to static text, run the page, changed it back to pl/sql expression... Still no luck..
    Any ideas?
    Thanks,
    JohnA

    Don't know if it is just a copy and paste error, but beside the closing bracket I am missing two semicolons in this code:</br>
    </br>
    IF to_number(to_char(trunc(sysdate,'dd'))<b>)</b> < 2 THEN</br>
    to_char(trunc(sysdate,'mm'),'MM/DD/YYYY')<b>; <- one here</b></br>
    ELSE</br>
    to_char(add_months(trunc(sysdate,'mm'),-1),'MM/DD/YYYY')<b>; <- one here</b></br>
    END IF;</br></br>
    Maybe this helps you out?</br>
    </br>
    Regards, Tine.

  • Pl/sql expression for default value

    I'm trying to run this simple script as a default value using pl/sql expression, but I keep getting this error. THe select statement itself works fine as a sql statement source value, but will not work as a pl/sql exression as a default value. This (:P33_SYSUSERID_CREATED_BY ) is the field name on the form. Any ideas?
    begin
    select a.id || ', ' || A.NAME_LAST into :P33_SYSUSERID_CREATED_BY from S_USERSV a where a.name_last = 'HAMMAKER';
    end;
    Error ERR-9132 Error in PLSQL expression for item default code, item=P33_SYSUSERID_CREATED_BY
    OK
    ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: ( - + case mod new not null avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe

    Sudha,
    For a default value type of PL/SQL Expression, you could create a function that accepts an input and returns a value. If the function (not a procedure) is named GET_REFNO, you would call it using an expression in the default value field like:
    get_refno(:P3_REFTYPE)
    For a default value type of PL/SQL Function Body, you could call your existing procedure with a default value like:declare
        l_value varchar2(32767);
    begin
        get_refno(:P3_REFTYPE, l_value);
        return l_value;
    end;Scott

  • Conditions: SQL Expression vs. PL/SQL expression

    In a Condition, what is the difference between a SQL Expression and a PL/SQL expression? The examples shown when creating, say a validation show similar things
    example of pl/sql expression: to_char(sysdate,'d')=1
    example of sql expression: instr(...) > 0
    Arent the 2 expressions above similar? What makes one a sql expression and other a plsql expression?
    Thanks

    Thanks, but I think its more than a matter of documentation.
    I had a SQL expression like
    :REQUEST IN ('button1','button2') AND NOT pkg.fn
    where pkg.fn is, of course, a packaged function returning BOOLEAN.
    The process that this condition was attached to was just not firing. No errors, nothing. I was ready to tear my hair out! I changed the expression type from SQL to PL/SQL and everything was fine.
    I think there should be a check in the App Builder for this kind of thing so that such invalid conditions are not allowed to be created.
    Thanks

  • Can I use an IF Statement in a Region Source

    Hello, Im using Apex 3.x. I have a standard report page whose Region Source is a simple select statement..... SELECT xyz FROM...WHERE
    I need to add an IF statement to this Region Source, but when I do I get an error - Query cannot be parsed within the Builder.
    IF :P2_FILTER = 'A' THEN
    SELECT abc FROM...WHERE
    ELSIF :P2_FILTER = 'B' THEN
    SELECT abc FROM...WHERE
    END IF;
    The columns selected are the same in both scenarios. Is there any way to add an IF statement to the region source?
    Thank
    you

    I guess Scott is suggesting creating 2 regions (with different source query ) , then define the codition for each one. Ex. for region 1 >> condition >> plsql expression >> :P2_FILTER = 'A'
    for region 2 >> condition >> plsql expression >> :P2_FILTER = 'B'
    Hope this helps,
    Sam
    Edited by: Sam_06 on Aug 17, 2010 12:20 PM

  • Column Template conditions foiled by a single quote

    I am using a generic column template and have a few pl/sql conditions to shade different rows like so:
    '#1'  like '%Total%'This worked fine until an employee's name appeared in the first column with a single quote in his last name (like O'Brien). Well apparently Apex literally takes whatever is in the field and just shoves it in between the single quotes because the single quote is terminating the string as if you were doing this in sql instead of making it a bind variable:
    'O'BRIEN' like '%Total%'Which results in this friendly message to the users:
    ORA-06550: line 1, column 65: PLS-00103: Encountered the symbol "BRIEN" when expecting one of the following: ) , * & | = - + < / > at in is mod remainder not rem => ..  <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ as between from using || multiset member SUBMULTISET_
         Error      ERR-1025 Error processing PLSQL expression. 'O'BRIEN, JOHN P ' like '%Total%' Can someone from the Apex team confirm that this is the issue? I know I could do a replace on the single quote in my sql, but can't figure out how to escape the '#1#' properly so I don't have to do a replace. I also don't really want to use the Carl Backstrom approach of having to code in a class into the sql when these templates work for 99% of what I need to do.
    Any ideas?

    Dude you rock! I tried about 6 different combos of the q function before I got frustrated and posted. I had too many quotes in mine I guess but that works perfectly.
    Thanks again!

  • Passing #COLUMN_VALUE# as parameter to pl/sql function in column template

    Hi all,
    I want to color negative amounts in red in sql report using column template.
    I created a pl/sql function"isNegativeNum" which returns 1 or -1.
    create or replace function isNegativeNum(p_column_value varchar2) return number
    as
    l_dummy number;
    begin
          l_dummy := to_number(p_column_value,'999G999G990D00PR');
          IF l_dummy < 0
             THEN
                RETURN 1;
          else
                return -1;
          END IF;
    exception
    when others then
       RETURN -1;
    end;Below is column template.
    Column Template 1
    <td class="t3dataalt" #ALIGNMENT#><p color=red>#COLUMN_VALUE#</p></td>Column Template 1 Condition
    isNegativeNum('#COLUMN_VALUE#') = -1The issue is #COLUMN_VALUE# value is not being passed to the function, Insert statement in function reveals p_column_value as a string "#COLUMN_VALUE#". When I try without quotes like isNegativeNum(#COLUMN_VALUE#) = -1, I get below error.
    ORA-06550: line 1, column 48: PLS-00103: Encountered the symbol "#" when expecting one of the following: ( ) - + case mod new not null others select table avg count current exists max min prior sql stddev sum variance execute multiset the both leading trailing forall merge year month DAY_ hour minute second timezone_hour timezone_minute timezone_region timezone_abbr time timestamp interval date
         Error      ERR-1025 Error processing PLSQL expression. isNegativeNum(#COLUMN_VALUE#) = 1
    Any help is appreciated.
    Kishore

    Hi Kishore,
    using #COLUMN_VALUE# would probably not make much sense, because normally a report has multiple columns and not just the numeric column which you want to verify if it's negative. But APEX will fire the template condition for each column, because the report template is a column cell template.
    What you can do to make it more generic is to use for example
    #CHECK_AMOUNT#
    in the template and provide a not displayed column in your SQL statement which contains your value which is named CHECK_AMOUNT. For example:
    SELECT NAME
         , BALANCE
         , BALANCE AS CHECK_AMOUNT
    FROM XXX;Because this CHECK_AMOUNT column would be a generic name, you can use this template in all your reports as long as you provide this column.
    Thope that helps
    Patrick

  • If then Else statement not working under Computation in APEX

    Hi
    Can anyone help me where I am going wrong? I am trying to use the following code in Computation Process on Submit. I am not able to get the value. It's showing nothing.
    Page:
    *Item Name (Value Required)
    Type
    Static Assignment
    PL/SQL Function Body
    SQL Query (return single value)
    SQL Query (return colon separated value)
    SQL Expression
    PLSQL Expression
    Item Value
    Computation Point
    *Sequence (Value Required)
    Computation Point
    On New Instance (new session)
    Before Header
    After Header
    Before Region(s)
    After Region(s)
    Before Footer
    After Footer
    After Submit
    Source
    *Computation (Value Required)
    BEGIN
    IF :P3_AGING_DAYS <= '0' THEN
    :P3_AGING_BUCKET := 'Within due date';
    elsif :P3_AGING_DAYS > '0' AND :P3_AGING_DAYS <= '3' then
    :P3_AGING_BUCKET := 'Within 3 days';
    end if;
    end;

    1efb2968-171d-43f9-9d5d-d38151735ed7 wrote:
    Please update your forum profile with a real handle instead of "1efb2968-171d-43f9-9d5d-d38151735ed7".
    Can anyone help me where I am going wrong? I am trying to use the following code in Computation Process on Submit. I am not able to get the value. It's showing nothing.
    BEGIN
    IF :P3_AGING_DAYS <= '0' THEN
    :P3_AGING_BUCKET := 'Within due date';
    elsif :P3_AGING_DAYS > '0' AND :P3_AGING_DAYS <= '3' then
    :P3_AGING_BUCKET := 'Within 3 days';
    end if;
    end;
    A PL/SQL Function Body computation has to return a value rather than assigning it to an item in the PL/SQL block (APEX turns the block into the body of a function). The item for which the value is to be computed is specified in the computation properties (P3_AGING_BUCKET).
    begin
      return case
               when :p3_aging_days < 1
               then
                 'Within due date'
               when :p3_aging_days between 1 and 3
               then
                 'Within 3 days'
             end;
    end;

  • How to Change the return value for the parameters

    Hi, Can anyone help me with my problem?
    I have a parameter called "P1_Projects" defined in the HTMLDB page, on the report region, there are 2 buttons, one is "Go" button to submit the report on the screen, so user can preview the report, then another button "Export to PDF" can be clicked to generate the report using Oracle Report Services. The "Export to PDF" button will use the same set of parameters submitted for the "Go" button.
    So, the parameter "P1_Projects" is being used by these 2 buttons. and I have to pass a "%" wild card for "All Projects". To make the "Export to PDF" button work, I have to safe encode the return value for "%" to "%25" in order to pass the URL formula, but now my "Go" button doesn't work with "%25", it only recognize the "%" wild card.
    Is there a way to conditionally change the value depends which button is clicked?
    Any hint or help is highly appreciated!
    Hong

    try creating a plsql process which sets the P1_Projects item as required.
    in the plsql you can do:
    if :REQUEST = 'GO' then
    xxx
    else
    xxxx
    end if;
    set the condition to plsql expression:
    :REQUEST in ('GO', 'EXPORT')
    NB. the request value is usually set to the button name when a page is submitted from a button

  • Report Template, Column Template, Column Template Condition

    I have a template, Standard Revenue from Standard, I have cloned for a Classic report.
    Application ###>Shared Componets>Templates>Edit Report Template
    Column Template 1 looks like:
    <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t1data_revenue">#COLUMN_VALUE#</td>
    I have set Column Template 1 Condition to:
    "Use based on PL/SQL expresiion"
    I have tried several expression in "Column Template 1 Expression" - last one is:
    case
    when #COLNUM# <= 2 then false
    when #COLUMN_VALUE# < 0 then true
    else false
    end case;
    I am trying to use the value in "Column Template 2" when to value of the #COLUMN_VALUE# < 0
    where "Column Template 2" is :
    <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t1data_revenue_negative">#COLUMN_VALUE#</td>
    I get the following error when I run the page:
    ORA-01403: no data found
    and
    ERR-1025 Error processing PLSQL expression. case when #COLNUM# <= 2 then false when #COLUMN_VALUE# < 0 then true else false end case;
    Any help will be appreciated.
    thank you,
    jwm

    Hi,
    That's actually easier. See: [http://apex.oracle.com/pls/otn/f?p=267:60]
    The SQL for both reports is:
    SELECT EMPNO, ENAME, NVL(SAL,0) SAL, NVL(COMM,0) COMM
    FROM EMP
    ORDER BY EMPNOThe SAL and COMM columns have been formatted using:
    999G999G999G999G990D00For the Row Template, the Row Template 1 setting contains an empty space (you have to have something in there otherwise Apex adds back in a default row containing five cells!). The condition for this is:
    TO_NUMBER('#COMM#','999G999G999G999G990D00') < 100The template will see the data as a string, so we use the same number format to convert that string back into a number and compare this to 100. If we didn't use formatting on the numbers and we are sure that every row contained a number (hence the use of NVL()), then you could use:
    #COMM# < 100Row Template 2 contains the format for the rows that need displaying:
    &lt;tr&gt;
    &lt;td class="t18Data"&gt;#1#&lt;/td&gt;
    &lt;td class="t18Data"&gt;#2#&lt;/td&gt;
    &lt;td class="t18Data" style="text-align:right"&gt;#3#&lt;/td&gt;
    &lt;td class="t18Data" style="text-align:right"&gt;#4#&lt;/td&gt;
    &lt;/tr&gt;and is unconditional.
    The only other settings on the Row Template are the Before Rows:
    &lt;table class="t18Standard" style="border-collapse:collapse; border:1px solid black;"&gt;
    &lt;tr&gt;
      &lt;th class="t18ReportHeader"&gt;Empno&lt;/th&gt;
      &lt;th class="t18ReportHeader"&gt;Ename&lt;/th&gt;
      &lt;th class="t18ReportHeader" style="text-align:right"&gt;Sal&lt;/th&gt;
      &lt;th class="t18ReportHeader" style="text-align:right"&gt;Comm&lt;/th&gt;
    &lt;/tr&gt;and After Rows:
    &lt;/table&gt;Of course, you will note that the record counters at the bottom still show the number of records in both reports - as the SQL still outputs the same data, this doesn't change.
    Andy

  • Report Template dependant of PLSQLEXPRESSION

    I have written a report template to vary a column format depending on a PLSQL Expression.
    I want to have an expression like this in the 'Column Template 1 Expression' box.
    MY_LIB.fIndicatorStateChange(1,#COLUMN_VALUE#)
    or
    MY_LIB.fIndicatorStateChange(1,v('#COLUMN_VALUE#'))
    or
    MY_LIB.fIndicatorStateChange(1,&COLUMN_VALUE.)
    in all cases the second parameter comes up as NULL in the package.
    I am using HTML version 1.6.
    Can anyone help.
    Thanks
    Carlos

    I am using the solution to embed the code in my report to change the font color based on some condition. It works great when my region type is SQL Query but it does not work when my region type is PL/SQL Funciton Body Returning SQL Query.
    Here is a snippet of the code:
    SELECT a.Dataset_ID Contents, a.Dataset_Name,
           CASE
              WHEN a.Final_Flag = 1 THEN
                 '[span style="color:red">'||a.Dataset_Location||'[span>'
           ELSE 
                 '[span style="color:black">'||a.Dataset_Location||'[span>'
           END AS Dataset_Location
    FROM Datasets
    [/pre]
    When I do this using a PL/SQL Function body with the q:=q||q'! SELECT... Syntax I get the following error message:
    "ORA-20001: Unable to bind :RED verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist."
    It looks like it thinks the :RED is a find variable but it isn't.  Does anyone know of a way to fix this?
    (I also tried using decode instead of case and I still got the same error)
    Thanks
    - Brian                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to set a default value for a page item

    I am working with a facility table that has name and address information. The user can add contact name information on a separate page. Since the address for the facility and contact is usually the same, I want to add a default value for the contact address. The facility page is on 201 and the link to add a new contact row is on page 202. I showed in the default value :P201_street for the contact's address. But, when I run the page, the contact address field shows the :P201_street, not the actual facility address. What am I leaving out? Must be something obvious?!
    Thanks very much.
    Judy

    In the default value, I showed: v('P201_STREET1') with the default value type of: PL/SQL Expression and received the following oracle error ==> Item default is not a PL/SQL expression. Use &ITEM syntax. The v('ITEM') syntax is not valid for item defaults. So I changed it to: &P201_STREET1 and got another oracle error , ERR-9132 error in PLSQL expression for item default code, item=P202_STREET1.
    Any more suggestions? Thx.
    Judy

  • Conditionally executing a function based on the existance of an item value

    I want to populate a field based on a function. Easy enough with a function I have created to do this.
    GET_A_VALUE(:P14_ID);
    This works nicely when I put that in the default value and then go and edit an existing record.
    The problem is when we try and create a new value. :P14_ID does not exist
    I get something like this
    ORA-01403: no data found
         Error      ERR-9132 Error in PLSQL expression for item default code, item=P14_ID
    OK      
    Which makes sense as P14_ID doee not exist yet.
    I've tried to do something like this with no luck in the default field
    begin
    if :P14_ID is NOT NULL
    then GET_A_VALUE(:P14_ID);
    end if;
    end;
    Which gets me this
    ORA-06550: line 3, column 6: PLS-00221: 'GET_A_VALUE' is not a procedure or is undefined ORA-06550: line 3, column 6: PL/SQL: Statement ignored
         Error      ERR-9131 Error in PLSQL function body for item default code, item=P14_ID
    OK      
    Am I approaching this in the correct way? Any suggestions?

    I would have thought his function would look more like this:
    FUNCTION get_Value(p_val IN NUMBER)
    IS
      l_ret VARCHAR2(1);
    BEGIN
      SELECT dummy INTO l_ret FROM dual WHERE 1=1;
      RETURN l_ret;
    ENDWhen in fact it should look something like this:
    FUNCTION get_Value(p_val IN NUMBER)
    IS
      l_ret VARCHAR2(1);
      CURSOR i IS SELECT dummy FROM dual WHERE 1=1;
    BEGIN
      OPEN i;
      FETCH i INTO l_ret;
      CLOSE i;
      RETURN l_ret;
    END;

Maybe you are looking for

  • A quick primer on audio drivers, devices, and latency

    This information has come from Durin, Adobe staffer: Hi everyone, A  common question that comes up in these forums over and over has to do  with recording latency, audio drivers, and device formats.  I'm going to  provide a brief overview of the diff

  • File -- File sceranio problem

    I am having some problem in the file-file scenario at the sender file adapter level. Please look at the following message: 2006-01-09 10:23:17 Error Attempt to parse XI system response failed 2006-01-09 10:23:17 Error Transmitting the message to endp

  • Multiple document numbers not created while creating multiple idocs.

    Hi Experts, we have developed one the interface file to idoc, whenever invoice number change it will create a multiple idocs. but i am facing some issue with context handling, can you suggest the suitable mapping / UDF for the below issue. Our custom

  • New user created doesn't see any data in reports

    Hello Everyone, I am using Hyperion Planning 11.1.2.1. I have a problem when i created a new user in the system via Shared Services. The reports are Reporting and Analysis reports. I duplicated a current user in the system and applied the same groups

  • InDesign "Find Font" deletes text - help!

    So I open a file, use 'find font' to find and replace a font. Sometimes when I hit "change all" it deletes entire paragraphs of text. I've tried it with different fonts and it's not consistent. Sometime it deletes, sometimes it doesn't. Just now, I d