If then else in SQL

I have the following query:

SELECT
CDV.location_id,
TDC. Address1,
CDV.address2,
Sum (APS.amount_due_remaining) TOTAL_BALANCE,
Sum(decode(sign(TO_DATE(due_date,'DD-Mon-RRRR')-TO_DATE(SYSDATE,'DD-Mon-RRRR')),1,APS.amount_due_remaining,0)) NOT_YET_DUE_BAL
OF Table1 cdv.
Table2 al,
Table3 rctt,
Table 4 aps,
table5 rct,
Table 6 fool
WHERE rct.column1 = aps.column1
AND aps.column1 = rctt.column2
AND aps.column2 = cdv.column3
AND rctt.name = al.description (+)
and rct.sot_id = sot.sot_id
GROUP BY
TDC. CDV.location_id,
TDC. Address1,
CDV.address2
HAVING SUM (aps.amount_due_remaining) > 0

In the above query if
APS. Currency <>sot.currency so I want to display
Sum(APS.amount_due_remaining*APS.exchange_rate) TOTAL_BALANCE,
Sum(decode(sign(TO_DATE(due_date,'DD-Mon-RRRR')-TO_DATE(SYSDATE,'DD-Mon-RRRR')),1,APS.amount_due_remaining*APS.exchange_rate,0)) NOT_YET_DUE_BAL
ON THE OTHER
Sum (APS.amount_due_remaining) TOTAL_BALANCE,
Sum(decode(sign(TO_DATE(due_date,'DD-Mon-RRRR')-TO_DATE(SYSDATE,'DD-Mon-RRRR')),1,APS.amount_due_remaining,0)) NOT_YET_DUE_BAL
IF I use CASE for this, I'm getting ORA-00979 not a grop in error of expression

Thank you
Kiran

user518071 wrote:

In the above query if
APS. Currency <> sot.currency so I want to display
Sum(APS.amount_due_remaining*APS.exchange_rate) TOTAL_BALANCE,
Sum(decode(sign(TO_DATE(due_date,'DD-Mon-RRRR')-TO_DATE(SYSDATE,'DD-Mon-RRRR')),1,APS.amount_due_remaining*APS.exchange_rate,0)) NOT_YET_DUE_BAL
ON THE OTHER
Sum (APS.amount_due_remaining) TOTAL_BALANCE,
Sum(decode(sign(TO_DATE(due_date,'DD-Mon-RRRR')-TO_DATE(SYSDATE,'DD-Mon-RRRR')),1,APS.amount_due_remaining,0)) NOT_YET_DUE_BAL

Your query groups by:

GROUP BY

TDC. CDV.location_id,

TDC. Address1,

CDV.address2

Each group can have several lines. So what if some lines in one (or more) groups have aps.currency <> sot.currency and a few lines in the same group have aps.currency = sot.currency. As you can see, the issue is not with the CASE, but with your logic. Unless you want to see the two group totals: one for the lines where the aps.currency <> sot.currency and the other for the rest of the lines. Then coul you use something like:

Sum (case when APS. Currency <> sot. Currency Then APS.amount_due_remaining end) TOTAL_BALANCE1,.

Sum (case when APS. Currency <> sot. Currency Then NULL else APS.amount_due_remaining end) TOTAL_BALANCE1

In addition, end_date is DATE, right? Conversion from DATE to DATE, causes an implicit conversion and may return unexpected results. Use

Sum (decode (Sign (trunc (due_date) - trunc (sysdate)), 1, APS.amount_due_remaining * APS.exchange_rate, 0)) NOT_YET_DUE_BAL

Or better:

Sum (case when trunc (due_date) > trunc (sysdate) Then APS.amount_due_remaining * APS.exchange_rate else 0 end) NOT_YET_DUE_BAL

SY.

Tags: Database

Similar Questions

  • SQL syntax recordset IF THEN ELSE

    Here's what I'm trying to do: I am trying to display two different levels of content based on a user is profitable or not. for example, if the field xyz_paying = 'Yes' then select *, otherwise only display some fields, so I will try to use a mysql statement to create a SELECT query. I tried to do that IF, THEN, ELSE, but I'm getting syntax error messages. could someone show me a simple example please. or suggest a good resource. Thank you.

    I can't seem to get the sql to do what I want, so I changed gears and I use a conditional region to display only when my paid domain == works y. very well.

    I guess it's as good as force sql to do what you want. I'm now pulling all the data in the tables but it displays in a selective way.

  • Help to fic my if-then-else logic in Forms 6i

    Hello world
    I have the following if-then-else in a when-validate-point called trigger where I'm trying to make it work the way I want to, but only works if I have 3 numeric values for each item. If put a letter in one of them, then I get the following error:
    FRM-40735: WHEN-VALIDATE-ITEM trigger raised unhandled exception ORA-06502.
    Can someone please help me fix my logic?
    Begin
    If (:BLOCK1.ITEM1 BETWEEN 0 AND 100) and (:BLOCK2.ITEM2 BETWEEN 0 AND 100) and (:BLOCK3.ITEM3 BETWEEN 0 AND 100) Then
    :BLOCK1.ITEM4 := (:BLOCK1.ITEM1*0.40) + (:BLOCK1.ITEM2*0.40) + (:BLOCK1.ITEM3*0.20);
    Elsif
    (:BLOCK1.ITEM1 IN ('F', 'P', 'NA')) and (:BLOCK1.ITEM2 BETWEEN 0 AND 100) and (:BLOCK1.ITEM3 BETWEEN 0 AND 100) Then
    :BLOCK1.ITEM4 := (:BLOCK1.ITEM2 + :BLOCK1.ITEM3)/2;
    Elsif
    (:BLOCK1.ITEM2 IN ('F', 'P', 'NA')) and (:BLOCK1.ITEM1 BETWEEN 0 AND 100) and (:BLOCK1.ITEM3 BETWEEN 0 AND 100) Then
    :BLOCK1.ITEM4 := (:BLOCK1.ITEM1 + :BLOCK1.ITEM3)/2;
    Elsif
    (:BLOCK1.ITEM1 IN ('F')) AND :BLOCK1.ITEM2 IN ('F')) AND (:BLOCK1.ITEM3 IN ('F')) Then
    :BLOCK1.ITEM4 := 'F';
    Elsif
    (:BLOCK1.ITEM1 IN ('P')) AND (:BLOCK1.ITEM2 IN ('P')) AND (:BLOCK1.ITEM3 IN ('P')) Then
    :BLOCK1.ITEM4 := 'P';
    Elsif
    (:BLOCK1.ITEM1 IN ('NA')) AND (:BLOCK1.ITEM2 IN ('NA')) AND (:BLOCK1.ITEM3 IN ('NA')) Then
    :BLOCK1.ITEM4 := 'NA';
    Else
    Null;
    End if;
    End;
    Published by: user626836 on September 28, 2011 08:42

    Published by: user626836 on September 28, 2011 08:54

    Yes, everywhere, wherever you want to see the numerical score or Alpha you will use this code. Depending on your version of the database of the stated CASE may not work, but all versions support DECODING.

    Craig...

    Published by: Silvere Sep 29, 2011 07:18

    I need to clarify... the DECODING is a SQL function. If you can't use it in SQL queries. You will get a compiler error if you try to use the DECODE function in PL/SQL.

  • How to get if THEN ELSE another condition table

    Hi eveybody,.
    I have a situation and I need your advice guys.
    I apply if THEN ELSE condition in PL/SQL from another table. I do the merger in tableA that will run IF Column1 in tableC = Y.
    Ex: Tablec has three columns: source, dest, condition. Condition IF = Y in tableC, then merge into tableA use (Sql query in table C source selection) B.

    Please let me know how to get the condition = Y of table C.
    Condition IF = Y for each source in C, then fusion will happen for this source.

    Please provide your comments and your responses.
    I'd really appreciate your comments and your responses.
    Thank you very much.

    user13426784 wrote:
    DB link is passed as parameter in MS and we need to check the status for this link db to TableC.

    select   status
      into  v_status
      from  tableC
      where db_link = v_source;
    if v_status = 'Y'
      then
        EXECUTE IMMEDIATE 'MERGE INTO tableA A USING
    (select  from tableA@' || v_source || ')B
    when matched insert
    when not matched update';
    end if;
    

    SY.

  • if-then-else logic

    Here's the test with values from the table and insert.


    create table students (
      name varchar2(25 BYTE),
      joined_date DATE,
      exam_type VARCHAR2(25 BYTE),
      SCORE NUMBER(2,1),
      CUT_OFF_DATE DATE
     );
    insert into students values('john','26-mar-14','SCREEN',7.6,'10-apr-14');
    insert into students values('john','10-Apr-14','RETEST',8.0,'10-apr-14');
    

    I try to return the single folder with the score of the same name of the student. I use CASES, but he really do not act as "IF-THEN-else" as the use of a control statement.


    select name,
      joined_date,
      case 
      ---something like IF statment if below[b] statement 1[/b] --is true then it
      --should return below statement
      when exam_type ='SCREEN' and score between 8.0 and 10.0
      then score
      ----[b]statement 2[/b] --if above expr fails, the below to be executed
      when exam_type ='RETEST' and score between 8.0 and 10.0
      and joined_date >= cut_off_date
      then score
      else null
      end result
    from students;
    

    output-

    Name joined_date Result
    John26/03/14
    John04/10/148


    in the game of results above, I need only the score of '8' and 'John' and the unique records only? like this, there are more then millions of records must be calculated.

    Please help me with logic


    Thank you

    Jason

    Well,.

    in this case, you will need to use something like ROW_NUMBER to keep only the "first" instance:

    SELECT name,

    joined_date,

    exam_type,

    score

    FROM (select s.*,

    ROW_NUMBER() over (partition by order of name of joined_date) rn

    s students

    where 1 = case when (exam_type = "SCREEN" and score between 8 and 10)

    or (exam_type = "RETEST" and the score between 8 and 10 and joined_date > = cut_off_date)

    then 1

    end

    )

    WHERE rn = 1;

  • start end in if then else.

    Hello

    I've seen people to help

    If 1 = 1 then

    HOMELESS: = 9;

    on the other

    HOMELESS: = 10;

    end if;

    or


    If 1 = 1 then
    Start
    HOMELESS: = 9;
    end
    on the other
    Start
    HOMELESS: = 10;
    end;
    end if;

    (1) which is good. (good coding practices)
    (2) is it wrong by removing start end if then else.

    what I show begin end can be used for the management of exceptions, if it can be used for any other things please tel me.


    Yours sincerely

    944768 wrote:
    what I show begin end can be used for the management of exceptions, if it can be used for any other things please tel me.

    The previous poster gave you good links.

    In your example, I think that putting BEGIN/END in each IF/ELSE condition is rare and would not be useful, so I'd omit them.

    Nested BEGIN/END blocks can be useful If you want to:
    (a) put a label, or
    (b) DECLARE a variable that will be used only within that block, and/or
    (c) write a specific EXCEPTION handler.

    Since your example only none of that above, I don't see the use of these nested blocks. When something is useless, do not.

    P.S. If the goal is to write modular code, anonymous blocks can declare functions and procedures that can be called from the main block.

    set serveroutput on
    DECLARE
      PROCEDURE proc_inside(p_msg in varchar2) IS
        BEGIN
          dbms_output.put_line(
            'Message from procedure within an anonymous block: '||p_msg
          );
        END proc_inside;
    BEGIN
      proc_inside('Message A.');
      proc_inside('Message B.');
    END;
    /
    
    anonymous block completed
    Message from procedure within an anonymous block: Message A.
    Message from procedure within an anonymous block: Message B.
    

    Published by: Ashton stew on March 10, 2013 16:46

  • How an action can test if (if-then-else) a symbol is visible?

    I have a symbol that can be hidden or display depends on a number of previous actions. I need a new action that tests the visibility of this symbol, so I can run a new action if-then-else. How this can be done? I speak not the pictures hidden behind others, just the actions/hide.

    Thank you. I'll work with it.

  • Unable to minimization/maximization if-then-else block

    When you change a procedure, I lost the ability to minimization/maximization of a block if-then-else. How to bring back this feature? I'm using version 1.5.1 build HAND-5440.

    Have a look at tools > Preferences > Code Editor > display - he has a preference "Show Code folding margin. If this were put in judgment you don't get the code folding margin in the editor. However, if your code folding margin appears (preference is on) but doesn't give you any points trick, remember that there may be a noticeable delay between opening the code editor and the fold points scored - more code, it may be.

    Finally, there was a change at a given time (don't remember the version it was introduced) where the section of code to be folded must exceed three lines you can collapse it. For example, it won't give you an option to fold:

    if condition then
      single line of code;
    end if;
    

    but it will be:

    if condition then
      single line of code 1;
      single line of code 2;
    end if;
    

    theFurryOne

  • Poor implementation of "box, when then else"?

    It seems to me that my expression < next > is executed even if < WHEN > is false. I have a queury with LISTAGG, and if there are too many people, the string exceeds the limit of 4000 characters. I tried to use "BOX WHEN" to give a message instead of the list of names, but I always get an error.

    I have reproduced this with the HR schema. (A simple example ;))

    This was my first expression:
    SELECT department_id
    ,LISTAGG('Employee_ID: '||EMPLOYEE_ID ||' Name: '||FIRST_NAME ||' '||LAST_NAME ||' Email: '||EMAIL||' Phone number: '||PHONE_NUMBER||'Hiredate: '||HIRE_DATE, ',') WITHIN GROUP (ORDER BY hire_date) AS Employees
    FROM employees e
    GROUP  BY department_id;
    throw this error:
    ORA-01489: resultatet av strengsammenkjeding er for langt
    01489. 00000 -  "result of string concatenation is too long"
    *Cause:    String concatenation result is more than the maximum size.
    *Action:   Make sure that the result is less than the maximum size.
    With this expression I do not exceed the limit of 4000 characters and the message "too many employees" are correctly displayed.
    SELECT department_id
    ,CASE WHEN ((select count(*) from employees where department_id=e.department_id) < 30)
    THEN (LISTAGG('Employee_ID: '||EMPLOYEE_ID ||' Name: '||FIRST_NAME ||' '||LAST_NAME ||' Email: '||EMAIL||' Phone number: '||PHONE_NUMBER, ',') WITHIN GROUP (ORDER BY hire_date))
    ELSE 'Too many employees'
    END AS Employees
    FROM employees e
    GROUP  BY department_id;
    For this Department 50 expression exceeds the limit of 4000 characters, and I get the above error. But the 50 Department has 45 employees and should not be the same in the part 'THEN'
    SELECT department_id
    ,CASE WHEN ((select count(*) from employees where department_id=e.department_id) < 30)
    THEN (LISTAGG('Employee_ID: '||EMPLOYEE_ID ||' Name: '||FIRST_NAME ||' '||LAST_NAME ||' Email: '||EMAIL||' Phone number: '||PHONE_NUMBER||'Hiredate: '||HIRE_DATE, ',') WITHIN GROUP (ORDER BY hire_date))
    ELSE 'Too many employees'
    END AS Employees
    FROM employees e
    GROUP  BY department_id;
    Oracle is a very silly implementation of ' BOX WHEN.. "or I do something wrong?

    I can solve this another way?

    Kind regards
    Thomas

    A way out could be

    SQL> SELECT department_id, SUBSTR (NVL (listagg (str, ',') WITHIN GROUP (ORDER BY hire_date), 'Too many employees'), 1, 20) || ' ... ' employee
        FROM (SELECT department_id,
                     hire_date,
                     CASE
                        WHEN COUNT (*) OVER (PARTITION BY department_id) <= 30
                        THEN
                              'Employee_ID: '
                           || employee_id
                           || ' Name: '
                           || first_name
                           || ' '
                           || last_name
                           || ' Email: '
                           || email
                           || ' Phone number: '
                           || phone_number
                           || 'Hiredate: '
                           || hire_date
                     END
                        str
                FROM employees e -- WHERE department_id != 50 OR department_id IS NULL
                                )
    GROUP BY department_id
    /
    DEPARTMENT_ID EMPLOYEE
    ------------- -------------------------
               10 Employee_ID: 200 Nam ...
               20 Employee_ID: 201 Nam ...
               30 Employee_ID: 114 Nam ...
               40 Employee_ID: 203 Nam ...
               50 Too many employees ...
               60 Employee_ID: 103 Nam ...
               70 Employee_ID: 204 Nam ...
               80 Too many employees ...
               90 Employee_ID: 100 Nam ...
              100 Employee_ID: 109 Nam ...
              110 Employee_ID: 205 Nam ...
                  Employee_ID: 178 Nam ... 
    
    12 rows selected.
    
  • simple if then else... wats wrong?

    What is wrong with the simple sql below? I am new to programming... and try to get the logic if then another ElseIf... am I suppose to put; at the first END IF;... when I did... it gives another strange error...
    DECLARE
    v_sql VARCHAR2(100);
    v_num number;
    BEGIN
    v_sql := 'SELECT 100 FROM DUAL';
    area := 20;
    EXECUTE IMMEDIATE v_sql INTO v_num;
    IF v_num > 100 THEN
      DBMS_OUTPUT.PUT_LINE('count is positive');
      IF area > 0 THEN
        DBMS_OUTPUT.PUT_LINE('count and area are positive');
      END IF
    ELSIF v_num = 0 THEN
      DBMS_OUTPUT.PUT_LINE('count is zero');
      ELSE
      DBMS_OUTPUT.PUT_LINE('count is negative');
    END IF;
    END;
    /
    Error on line 1
    ORA-06550: line 13, column 1:
    PLS-00103: encountered the symbol "ELSIF" when expecting one of the following conditions:

    ;

    Your report part contains no variable with the name box.

    Arun-

    PS: Use a different variable instead of the region, something like v_area.

  • If then else

    Hi all

    I wrote the sub program...


    declare
    Spend_in_CR_Baby COMP (18.4).
    Spend_in_CR_Child COMP (18.4).
    Spend_in_CR_Home COMP (18.4).
    Spend_in_CR_Man COMP (18.4).
    Spend_in_CR_Woman COMP (18.4).
    v_CUST_KEY COMP (10,0);
    v_DIV_DESC varchar2 (30);
    v_sale_amt COMP (18.4).
    Start
    Select CUST_KEY, DIV_DESC, sale_amt bulk collect into v_CUST_KEY, v_DIV_DESC, v_sale_amt
    match where CUST_KEY = CUST_KEY;
    If (v_DIV_DESC = 'CR Baby') then Spend_in_CR_Baby: = v_sale_amt; end if;
    If (v_DIV_DESC = "Child CR") then Spend_in_CR_Child: = v_sale_amt;
    end if;
    If (v_DIV_DESC = 'CR Home') then Spend_in_CR_Home: = v_sale_amt;
    end if;
    If (v_DIV_DESC = 'CR Man') then Spend_in_CR_MAN: = v_sale_amt;
    end if;
    If (v_DIV_DESC = "CR woman") then Spend_in_CR_Woman: = v_sale_amt; end if;
    game update
    the CUST_KEY value = v_CUST_KEY
    where CUST_KEY = CUST_KEY;
    end;

    and here are the error messages: Please help

    Error report:

    ORA-06550: line 11, column 1:

    00497 PLS: do not mix between row and several rows (in BULK) list

    ORA-06550: line 11, column 1:

    00497 PLS: do not mix between row and several rows (in BULK) list

    ORA-06550: line 11, column 1:

    00497 PLS: do not mix between row and several rows (in BULK) list

    ORA-06550: line 11, column 88:

    PL/SQL: ORA-00904: invalid identifier

    ORA-06550: line 11, column 1:

    PL/SQL: SQL statement ignored

    06550 00000 - "line %s, column % s:\n%s".

    * Cause: Usually a PL/SQL compilation error.

    * Action:

    You are COLLECTING in BULK in Atomic variables (i.e. variables that can only contain a single value).  BULK COLLECTION requires that you query in collection types.

    However, what actually are you trying to achieve, because often there is no need (and it's often a bad habit) to collect data block in memory to treat it.  SQL is perfectly able to process data and to give back the results you want for example

    for example the following would summarize the amount of sales for each 'Department' (I guess they are departments)...

    declare

    Number of Spend_in_CR_Baby;

    Number of Spend_in_CR_Child;

    Number of Spend_in_CR_Home;

    Number of Spend_in_CR_Man;

    Number of Spend_in_CR_Woman;

    Start

    Select sum (case when div_desc = 'CR Baby' then sale_amt 0 otherwise end) as sum_baby

    , sum (case when div_desc = 'Child CR' then sale_amt 0 otherwise end) as sum_child

    , sum (case when div_desc = 'CR Home' then sale_amt 0 otherwise end) as sum_home

    , sum (case when div_desc = 'CR Man' then sale_amt 0 otherwise end) as sum_man

    , sum (case when div_desc = 'CR woman' then sale_amt 0 otherwise end) as sum_woman

    in Spend_in_CR_Baby

    Spend_in_CR_Child

    Spend_in_CR_Home

    Spend_in_CR_Man

    Spend_in_CR_Woman

    match

    where cust_key = v_cust_key;

    end;

    and the money is then returned in the variables in the code.

    Not quite sure that your update statement was trying to do, and there is no logic in your query or update to have "WHERE CUST_KEY = CUST_KEY" because it will always be true.  If one of those who is supposed to be a variable parameter or local procedure etc. so you must qualify properly by using the procedure name for example "WHERE CUST_KEY = procedure_name. CUST_KEY.

  • If then else confusion.

    All,

    I created following procedure to sent emails in html format. Here, I make one request a condition, if the length of message_text is more then 5 then only, it should send emails, otherwise, I didn't need to send empty mails. I used, if so also later in the procedure to achieve this, but it seemed, something was not right here, and after execution of this fact, the output is "no error".

    CREATE OR REPLACE PROCEDURE mail_alert_log AS

    CURSOR C1 IS

    SELECT rownum, message_text,

    originating_timestamp of

    sys.x$ dbgalertext

    where originating_timestamp > sysdate-(15 /(24*60)) and message_text like "ORA-% ';

    l_body varchar2 (32767).

    B1 x$ dbgalertext % rowtype;

    BEGIN

    l_body: = '< TABLE BORDER is 1 BGCOLOR = "#EEEEEE" >';.

    l_body: = l_body | "< TR BGCOLOR ="BLACK"> ';

    l_body: = l_body | "< TH > < DO COLOR 'WHITE' = > Rownum < / DO > ';

    l_body: = l_body | "< TH > < DO COLOR 'WHITE' = > Message < / DO > ';

    l_body: = l_body | "< TH > < DO COLOR 'WHITE' = > Timestamp < / DO > ';

    l_body: = l_body | "< /TR > ';

    FOR rec in C1

    LOOP

    l_body: = l_body | "< b > ';

    l_body: = l_body | "< TD > ' | recomm. Rownum. "< Table > ';

    l_body: = l_body | "< TD > ' | Rec.message_text: '< table >';

    l_body: = l_body | "< TD > ' | Rec.originating_timestamp: '< table >';

    l_body: = l_body | "< /TR > ';

    END LOOP;

    l_body: = l_body | ' < /table > ';

    IF length (b1.message_text) > 5

    THEN

    UTL_MAIL. SEND)

    SENDER = > ' [email protected] ',

    Mime_type = > "text/html",

    RECIPIENTS = > ' [email protected] ',

    SUBJECT = > "Alert.log to PTMDEV11 errors."

    MESSAGE = > l_body);

    ON THE OTHER

    dbms_output.put_line ("' no error");

    END IF;

    END;

    /

    SQL > exec mail_alert_log

    No errors

    PL/SQL procedure successfully completed.

    SQL > SELECT rownum, message_text,

    Length (message_text) of

    sys.x$ dbgalertext

    where originating_timestamp > sysdate-(15 /(24*60)) and message_text like "ORA-% ';  2 3 4

    ROWNUM

    ----------

    MESSAGE_TEXT

    --------------------------------------------------------------------------------

    LENGTH (MESSAGE_TEXT)

    --------------------

    1

    ORA-1541 marked during: alter database datafile ' /db/ptmdev/data1/system01.db

    f' offline...

    95

    Concerning

    BTW, you can use sql Developer to format your code. It is seasier to read it.

    CREATE OR REPLACE PROCEDURE mail_alert_log

    AS

    CURSOR C1

    IS

    SELECT rownum,

    message_text,

    originating_timestamp

    OF sys.x$ dbgalertext

    WHERE originating_timestamp >-(15 /(24*60)) sysdate

    AND message_text LIKE "ORA-% ';

    l_body VARCHAR2 (32767).

    B1 x$ dbgalertext % rowtype;

    BEGIN

    l_body: ='

    ';

    l_body: = l_body | »

    ';

    l_body: = l_body | "

    ';

    B1.message_text: = ";

    FOR rec in C1

    LOOP

    l_body: = l_body | »

    ';

    l_body: = l_body | »

    ';

    l_body: = l_body | »

    ';
    Rownum '.

    l_body: = l_body | "

    Message';

    l_body: = l_body | "

    Timestamp';

    l_body: = l_body | »

    '|| recomm. Rownum. » '|| Rec.message_text |'

    B1.message_text: = b1.message_text: rec.message_text;

    l_body: = l_body | »'|| Rec.originating_timestamp |'';

    l_body: = l_body | ";

    END LOOP;

    l_body: = l_body | ";

    ###

    IF LENGTH (b1.message_text) > 5 THEN

    UTL_MAIL. SEND (SENDER =>' [email protected]', MIME_TYPE-online "text/html","RECIPIENTS" =>' [email protected]', errors of SUBJECT-online 'Alert.log for PTMDEV11', MESSAGE-online l_body).

    ON THE OTHER

    dbms_output.put_line ("' no error");

    END IF;

    END;

    /

  • JavaScript custom for If/Then/Else statement code

    Can someone help me understand this code. I have a field in a PDF file that I need to generate a discount based on the price of an item. If the price is higher than 5000, then I need the field to say 1500. Otherwise the field discount must be price *. 30.

    I tried, but it did not work: if price > 5000 then discount = discount 1500 = price*.3

    Someone at - it help?

    Thank you!

    Acrobat forms use JavaScript, so you need to use the JavaScirpt syntax for JavaScript syntax appropriate for the 'If... else' statement. You will also need to access the domain object as established by the Acrobat JavaScript object using the method "getField" of the doc, "this.getField (cName)" object, then the property "value" for this object.

    custom calculation script for the ' discount field

    establish the name of the price field

    var c = "price";

    get the value of the price field

    var nPrice = this.getField (c) .vallue;

    Assume that the discount is 30% of the price

    NPrice = Event.Value * 0,30;

    the value of reduction 1 500 if the price is higher to 5,000

    If {(nPrice > 5000)

    Event.Value = 1500;

    }

    end of the custom calculation script

    For more information, see Conditional Execution by Thom Parker.

  • If then else-based sequence generator

    Hello

    I want to increment a sequence generator based on my if then another condition. I know that it is not if another feature, but rather we deal.
    Can you please let me know how to solve this problem?

    Kind regards
    Siva

    Hello

    There are different approaches, can have expressions SQL handling sequences (you will need to deploy only the code base set);
    http://blogs.Oracle.com/warehousebuilder/illustrations/sequences_in_owb1.jpg

    Also, using the sequence in the multipath scenario generator;
    http://blogs.Oracle.com/warehousebuilder/illustrations/sequences_in_owb2.jpg

    Using the sequence generator, OWB has more smarts on you doing so can generate different flavors or SQL/PLSQL.
    See you soon
    David

  • NULL value in IF - THEN-ELSE handling

    I have a slider that retrieves prior_value and current_value from a table;

    Select current_value from xyz, prior_value;

    Then, I need to set a flag indicator based on compared them to the above two attributes.

    IF prior_value > current_value
    then
    Set flag_ind = 62;
    ELSIF
    prior_value < current_value
    then
    Set flag_ind = 63;
    ELSIF
    prior_value = current_value
    then
    Set flag_ind = 64;
    END IF;

    the problem is if prior_value is NULL, the comparison above does not give results as expected.

    How can I handle this.
    Thank you.

    Maybe something like that?

    IF prior_value IS NULL
    then
      -- case when prior_value is null
    elsif
       prior_value > current_value
    then
       set flag_ind = 62;
    ELSIF
       prior_value < current_value
    then
       set flag_ind = 63;
    ELSIF
       prior_value = current_value
    then
       set flag_ind = 64;
    END IF;
    

Maybe you are looking for