IF Statement Syntax

Hi,I'm writing a calc script, and I'm trying to capture alternate results with an IF statement. I calculate a ratio, and if it exists, I put data one place, and if the ratio equals zero, another place. In my IF condition, I put IF("DPWTOT"->"0"->"00000" / "DPWTOT"->"0"->"00000"->"ALLXFLD")which is calculating a ratio that will either be zero or a decimal value. The documentation says I can use "a Boolean test, as well as formulas to be calculated", but it only gives an example of a straight Boolean expression. When I run this calc script, I get an error that says "expected type [BOOLEAN] found [NUMBER]([]) in function [IF]"Can anyone tell me how I can use a formula in the IF condition, and possibly if you know where I can find a good source of syntax examples? Thanks.Michael BulgerSelective Insurance

Jade's response is right on. Your formula is incomplete. It is only saying IF A divided by B. You need to specify the equals portion so that your formula reads IF A divided by B equals C do something, ELSEIF A divided by B equals D do something else.Remember as Jade pointed out, when declaring an equals in an IF statement you have to use == not =.Good luck

Similar Messages

  • IF statement syntax in SQL script view

    I need to include a "IF" condition in the "SELECT" section of my SQL script view.
    I tried the following syntax's but I get the error 'Incorrect SQL syntax near 'IF'
    1.  IF(Revenue <> '0' AND Quantity <> '0', Revenue/Quantity, '0') AS Gross Price
    2.  IF(Revenue != '0' AND Quantity != '0', Revenue/Quantity, '0') AS Gross Price
    3.  IF(Revenue <> '0' AND Quantity <> '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    4.  IF(Revenue != '0' AND Quantity != '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    My final SQL would read like follows:
    SELECT field1, field2, IF(......) AS field3
    FROM table1
    Can anybody please help with the correct IF statement syntax to be used in the SQL script based view?

    Hi Lakshmi,
    below is the syntax for IF statement.
    IF <bool_expr1> THEN
    <then_stmts1>
    ELSEIF <bool_expr2>
    THEN <then_stmts2>
    [ELSE <else_stmts3>]
    END IF
    eg :
    BEGIN
    DECLARE found INT := 1;
    SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;
    IF :found = 0 THEN
    INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');
    ELSE
    UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;
    END IF;
    END;
    Sreehari

  • Improving SQL Insert statement syntax

    It's about insert statement syntax, in insert statement, unlike in update statement column names and corresponding values are separated in two different sets. With this separation debugging/writing of insert statement is going to be time taking activity. To identify what value is getting stored in any column, first column position needs to be identified and after that by counting commas in the values list value is located. If functions are included in insert statement then counting of commas doesn't help to locate the value.
    In any non trivial application column count in insert statement is going to be very big number and it is unmanageable.
    If column name and value are written next to each other as it is done in cause of UPDATE statement, it is going to drastically reduce the debugging efforts and there by improves the productivity of the developers.
    So I request SQL community please consider having a variant of insert statement in similar lines of update statement. This will simplify the life of millions of developers.
    Edited by: user9110509 on Feb 6, 2010 10:19 AM

    Hi,
    That's a good idea! An optional alternate way of specifying the columns would be handy.
    Perhaps the reason it hasn't been done yet is that most people, like those who have responded to this message, do not find the current syntax much of a problem. We can't be sure if your idea "is going to drastically reduce the debugging efforts" until it is available, but my guess is that it isn't.
    One thing I do to make sure the two lists match is to indent the values directly below the column names, like this:
    INSERT INTO emp (empno, ename,   hiredate,                job)
          VALUES (9876,  'OBAMA', TO_DATE ( '20-JAN-2009'
                              , 'DD-MON-YYYY), 'PRESIDENT');If the list is very long, or individual values are very complicated, then I might start with a list of the column names
    INSERT INTO emp          -- Step 1: not ready to run yet
    (     empno
    ,     ename
    ,     hiredate
    ,     job
    VALUESthen use the editor's copy and paste commands to duplicate that list:
    INSERT INTO emp          -- Step 2: not ready to run yet
    (     empno
    ,     ename
    ,     hiredate
    ,     job
    VALUES
    (     empno
    ,     ename
    ,     hiredate
    ,     job
    ;and then fill in the VALUES section, leaving the copied names as comments:
    INSERT INTO emp          -- Step 3: ready to run
    (     empno
    ,     ename
    ,     hiredate
    ,     job
    VALUES
    (     9876               -- empno
    ,     'OBAMA'               -- ename
    ,     TO_DATE ( '20-JAN-2009'
              , 'DD-MON-YYYY
              )          -- hiredate
    ,     'PRESIDENT'          -- job
    ;

  • [svn:fx-trunk] 11202: Make controlBarContent read/ write so you can use other states syntax besides includeIn

    Revision: 11202
    Author:   [email protected]
    Date:     2009-10-27 14:32:23 -0700 (Tue, 27 Oct 2009)
    Log Message:
    Make controlBarContent read/write so you can use other states syntax besides includeIn
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-23386
    Reviewer: Corey
    API Change: no
    Is noteworthy for integration: No
    tests: checkintests mustella/gumbo/components/Panel, Application
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-23386
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Application.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/Panel.as

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • UPDATE statement syntax

    I seem to have the most problem with UPDATE statement syntax. The following select works fine:
    select * from rco.rpt_ds1_cnt_cat c, rco.rpt_ds1_valid_per_lerg l
    where l.loc = c.aloc;
    All I want to do, and preferably with aliases is set c.aloc = l.loc. Every imaginable syntax is coming up with errors, either invalid columns or SET word missing, etc.
    Can someone tell me how to word this?

    You need to be aware that id there is a record in rpt_ds1_cnt_cat that does not have a matching record in rpt_ds1_valid_per_lerg this statement will update aloc_valid to NULL. If that is not what you are looking for, then you need to add a predicate like:
    UPDATE rpt_ds1_cnt_cat C
    SET aloc_valid = (SELECT DISTINCT validperlerg
                      FROM rpt_ds1_valid_per_lerg l
                      WHERE l.loc = c.aloc)
    WHERE c.aloc IN (SELECT loc FROM rpt_ds1_valid_per_lerg)
    or
    UPDATE rpt_ds1_cnt_cat C
    SET aloc_valid = (SELECT DISTINCT validperlerg
                      FROM rpt_ds1_valid_per_lerg l
                      WHERE l.loc = c.aloc)
    WHERE EXISTS (SELECT 1
                  FROM rpt_ds1_valid_per_lerg l
                  WHERE l.loc = c.aloc)If loc is the PK of rpt_ds1_valid_per_lerg, or is constrained unique, then you could also update a join, which is what I think you were trying for originally.
    Something like:
    UPDATE (SELECT c.aloc_valid, l.validperlerg
            FROM rpt_ds1_cnt_cat c, rpt_ds1_valid_per_lerg l
            WHERE l.loc = c.aloc)
    SET aloc_valid = validperlergHTH
    John

  • Member formula IF statement syntax

    Hi guys
    Can someone assist me with the syntax of the IF statement on a member formula.
    On the measure "Total Cost", i would like to apply a formula which calls value loaded to a series of other measures (m1, m2, m3, etc) such that if the Number of bags is = 1, then a value loaded to M1 is called, and if the Number of bags is 2, a value loaded to m2 is called.
    Thanks

    I think there may a better way to do what you are trying to achieve but below is the syntax for IF statement
    IF("number of bags" == 1)
    "m1";
    ELSEIF("number of bags" == 2)
    "m2";
    ELSEIF("number of bags" == 3)
    "m3";
    ENDIF;

  • Callable Statement Syntax

    I am using the callable statement to invoke a MS SQL Server stored procedure that will return a result set. I have several questions:
    1) According to the Java documentation I should be using the following format for a prepareCall that will return a result paramater with 4 input paramaters:
    { ? = call SP_ABC(?, ?, ?, ?)}
    In my particular case the stored procedure will return 14 pieces of data in a result set. Do I need to write code for 14 registerOutParameter fields? Is the syntax mentioned above accurate for the 14 pieces of data or do I need to repeat the question marks (?) 14 times? What shoud the syntax be for my prepareCall statement?

    The ? in the sql syntax refer to variables passed to the procedure as either in or in/out parameters. You need to write code to register any OUT variables (including any return value).
    The data returned from the SP will be returned as a ResultSet which is processed in the normal way.
    So assuming that you have a procedure declared as:
    create proc p @1 int, @2 int OUTPUT as ...then your code would look like this:
    statement = connection.prepareCall("{?=call p (?,?}");
    // register the return code
    statement.registerOutParameter(1,Types.INTEGER);
    // register the OUTPUT var @2
    statement.registerOutParameter(3,Types.INTEGER);
    // Set the input param @1
    statement.setInt(2,0);
    rs = statement.executeQuery();
    // Get the return code
    int rc = statement.getInt(1);
    // Get the output param @2
    int out = statement.getInt(3);
    // process the result set
    while(rs.next()) {...}Dave

  • Decode statement syntax?

    I want decode a column value based on the flag condition value in other column
    example: Select DECODE (UPPER (VPA.Secondary_other), 'TRUE', VPA.Secondary_Other_Response) from Table

    Hi,
    francislazaro wrote:
    I want decode a column value based on the flag condition value in other column
    example: Select DECODE (UPPER (VPA.Secondary_other), 'TRUE', VPA.Secondary_Other_Response) from TableThe syntax is correct. "TABLE" isn't a good name for a table, but I don't see anything else that's obviously wrong or suspicious.
    I can't tell if it will do what you want or not, since I don't know what you want.
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) and the results you want from that data.

  • Mysql statement syntax error

    hi,
    i have an error with my sql statement and i try to find the error but i couldn't could you please help me to find the error in this statement.
                   sql.append("SELECT * FROM CARS WHERE TO_DAYS('");
                   sql.append(PickDat + "') >= TO_DAYS('FROM_D')");
                   sql.append("AND TO_DAYS('");
                   sql.append(DropDat + "') <= TO_DAYS('UNTIL_D')");
                   sql.append("AND PICK_UP_DROP ='");
                   sql.append(pickdropPnt + "'AND CAR_TYPE ='");
                   sql.append(carclass + "'");
    error message :
    java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near '' at line 1 java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near '' at line 1
    thanks,
    yuetNi

    hi,
    thanks for your reply, i tried to use your idea but it still give me an error which i couldn't understand it.
    is it ok if i use the code below to convert a String to Date.
              java.sql.Date PickDat = java.sql.Date.valueOf(PDate);
              java.sql.Date DropDat = java.sql.Date.valueOf(DDate);
              System.out.println("IN CARINFO FUNC." + pickdropPnt + PDate + DDate + carclass);
                   sql.append("SELECT * FROM CARS");
                   sql.append("WHERE TO_DAYS('" PickDat "') BETWEEN TO_DAYS('FROM_D') AND TO_DAYS('UNTIL_D') ");
                   sql.append("AND TO_DAYS('" DropDat "') BETWEEN TO_DAYS('"+PickDat+"') AND TO_DAYS('UNTIL_D') ");
                   sql.append("AND PICK_UP_DROP ='" + pickdropPnt +"' ");
                   sql.append("AND CAR_TYPE ='"+carclass + "'");
    thanks for your help
    regards,
    yuetNiSwee

  • Sql statement syntax

    How can I use sql statement select a record by a date field?

    Like talden suggested, you should use PreparedStatements. They are much clearer and they are portable across different JDBC drivers and databases. Just create the date you to use by some means (like get it from the Calendar class). Then use setDate() or setTimestamp() method from PreparedStatement.
    String query = "select * from mytable where mydatecol = ?";
    PreparedStatements ps = connection.prepareStatement(query);
    Date myDate = new Date();
    ps.setTimestamp(1, myDate);
    setDate only gives you the date (by day), setTimestamp also includes smaller units up to nanoseconds or something depending on what your platform suppors.

  • Syntax and format of a IF statement in formula XPath in a InfoPath field

    Good day
    I needed assistance with IF statement syntax in a InfoPath field formula.
    If Field_1 = null
    concat(substring-before(txtComponentNo1, "."), ".", substring-before(field17, "."), ".", substring-after(field17, "."))
    Else
    concat(substring-before(txtComponentNo1, "."), ".", substring-before(field17, "."), ".", substring-after(field17, ".")+1)
    or in Advance XPath
    If Field_1 = null
    concat(substring-before(../../../my:grpComponent_1/my:grpComponent1/my:txtComponentNo1, "."), ".", substring-before(../../my:field17, "."), ".", substring-after(../../my:field17, "."))
    Else
    concat(substring-before(../../../my:grpComponent_1/my:grpComponent1/my:txtComponentNo1, "."), ".", substring-before(../../my:field17, "."), ".", substring-after(../../my:field17, ".") + 1)
    Thanks

    Hi,
    Here is the good explanation of what you are looking for.
    http://blogs.msdn.com/b/infopath/archive/2006/11/27/conditional-default-values.aspx
    and please check this as well for basic understanding
    http://www.bizsupportonline.net/infopath2010/if-else-statements-conditions-rules-infopath-2010.htm
    Krishana Kumar http://www.mosstechnet-kk.com

  • Syntax Error with EXPORT statement in ECC 6

    Hi All,
    I have one issue with EXPORT statement syntax.
    I have declared data like below:
    DATA: BEGIN OF mem_id,
              mandt LIKE sy-mandt,
              uname LIKE sy-uname,
              modno LIKE sy-modno,
            END OF mem_id.
    export the memory id
        EXPORT E_VBKOK XANZPK TEXTTAB XBOLNR TO MEMORY ID MEM_ID.
    When I am checking the syntax error i am getting like "MEM_ID" must be a character-type field (data type C, N, D or T). by "INTERFACE". by "INTERFACE". "INTERFACE". by "INTERFACE". by "INTERFACE".
    I know this statement would be like IMPORT ITAB TO JTAB FROM MEMORY ID 'table'. So I have written like below
    EXPORT E_VBKOK XANZPK TEXTTAB XBOLNR TO MEMORY ID 'MEM_ID'. But still it is throwing an error.
    Can you please let me know how can I resolve this?
    Regards,
    Jyothi CH.

    Hi Jyothi,
    data: l_var type string.
    concatenate '6' '8' into l_var separated by space.
    export l_var to memory id 'BB'.
    Here we have to declare the type(structure) for l_var not for BB
    and in another program
    data:l_var type string.
    import l_var from memory id 'BB'.
    write : l_var.

  • MAXL Import data statement error

    Can someone assist me in the maxl import data statement.
    In the import data statement "import database App.DB data from data_file "\\servername\\folder1\\folder1\\data.txt";
    The error I get is trying to specify the syntax for the path of the server. Does someone have an example of the import statement syntax that is referencing the data file from a server?
    Thanks

    Have you tried something like :-
    import database App.Db data from text data_file "\\\\servername\\sharename\\directory\\datafile.txt" using server rules_file "dataload" on error write to "dataerrors.err";
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Insert statements in jsp

    I am having a problem. I would like to insert some form data into a database using jsp but I have coded it and it gives me an error insert statement syntax is incorrect here is my code
    <%@page import="java.sql.*"%>
    <html>
    <head>
    <title>
    </title>
    </head>
    <body>
    <%
    String _driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String _url = "jdbc:odbc:testdata";
    try {
                 Class.forName (_driver);
                 String dataSourceName = _url;
                 String dbURL = dataSourceName;
                 Connection con = DriverManager.getConnection(dbURL);
                 Statement s = con.createStatement();
                 String insert;
                 insert = "insert into order (field1 , field2 , field3) values ('"
                 + request.getParameter("item1") + "' , '" + request.getParameter("item2") + "' , "
                 + "'" + request.getParameter("item3") + "')";
                 out.print(insert);
                 s.execute(insert);
                 s.close();
                 con.close();
                 }  // closes try statement
                 catch (Exception err) {
                 out.print("ERROR: " + err);
                 }; // closes catch statement
    %>
    <a href="shoppingcart.jsp">go back to shopping cart</a>
    </body>
    </html>here is the error it gives me
    ERROR: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    the insert statement looks right to me but there is something wrong anyone got any ideas. Thanxs in advance.

    AAAHHHH. Order is a reserved word and that was what my table was named. I suppose because of the order by clause it is. Figures spend hours staring at it and it is right there. I have to start using prefixes and suffixes on my code it would save me so much hassel.

  • SkinnableComponent does not react to state changes

    (Flex 4.5) I'm finding that SkinnableTextBase will change its styles according to the CSS file when it changes state, but SkinnableComponent won't. Why?
    Here's what I do. I create a class which extends SkinnableTextBase like this:
    public function MySTB() {
        super();
        states = new Array();
        for each (var name:String in ["inactive", "active"]) {
            var state:State = new State();
            state.name = name;
            states.push(state);
    I create another class which is the same, but which extends SkinnableComponent.
    In the CSS I tell them to have a green background when they are in the "active" state:
    customLabel|MySTB:active, customLabel|MySCom:active {
        content-background-color: #ccffcc;
    And I give both of them basically the same skin.
    When I call setCurrentState("active") on each of them, the SkinnableTextBase changes its background colour, but the SkinnableComponent doesn't. Why not? I would like to base a component on SkinnableComponent and need it to respond to state changes.

    Thanks Karl for the response. In this case the issue is not skin states but component states. It's rather confusing but there are two types of state and in fact the CSS states syntax as given above pertains to the component state. The skin has nothing to do with it.
    There must be something in SkinnableTextBase which is not in SkinnableComponent which causes the css syntax to be applied; though in theory this should work in any component. (see last example here: http://cookbooks.adobe.com/post_How_to_use_the_new_CSS_syntax_in_Flex_4-15726.html).

Maybe you are looking for

  • How do I delete mass junk emails?

    It seems to me that when I recieve a large quantity of junk emails to my Outlook via my Iphone 5 I shouldn't have to individually mark each one before I can trash them. I should be able to select all and then unmark the ones I want to save. The guys

  • Custom field added in Module pool is not reflecting in SRM Shopping cart

    Hi all, I have to add a custom field for Plant in the Ship-To address subscreen(BBPSC01) in Shooping cart in SRM. I have added the field in the program "saplbbp_sc_ui_its" in screen 310. But I think need to write the HTML code/Java script in HTML tem

  • Group By Statement

    Hello, I am new to SQL so I apologise. I need to execute the following query on my Oracle 10g database: I have a table like this: OID             Truck    Loading Time        Timestamp 1 HT01 10 10:01 2 HT02 8 09:03 4 HT02 6 10:04 5 HT01 10 11:01 8 H

  • Using messageBox in locking fields

    I've got a form that's functioning somewhat like an index. When data is filled in for a particular entry, it needs to be locked down. My strategy for accomplishing this is using a button with scripting to set the access on those particular fields to

  • Role Creation using CAT Scripts

    Hi, Step by step procedure needed. I need role creation using scripts(SECATT),org values that needs to maintain is full authorization. pls help me. ram