Change Boolean expression to string

AND(NodeIsLeaf(),Equals(String,PropValue(Custom.AssignedNodeType),NodeTypeEntity))
I need this evaluation formula to return the string N instead of False.  Any suggestions?
DRM Version 11.1.2.2
Thanks
AnthonyG

Put the code block in an IF statement and return what ever you want.
Ex:
IF(AND(NodeIsLeaf(),Equals(String,PropValue(Custom.AssignedNodeType),NodeTypeEntity)),N,Y)

Similar Messages

  • Evaluating boolean expressions from a string

    Hi All,
    In my program I am dynamically generating boolean expressions.
    Hence, I store the expression as a string. I want to be able to determine if that expression evaluates to true/false.
    For eg, String expr = "1 < 2";
    I want to be able to evaluate expr and print false(in this case)
    How can I do that? Are there any class that come with JDK1.4 for doing this or can you point me to some API that I can use for this.
    Thanks,
    Vijay

    I can't count how many times this has been askedhere.
    Try searching the forums.Give yourself credit - you could count it if you
    wanted to.
    OK, maybe so. But I can't count it off the top of my
    head. :-) But easier than counting the hairs on your head (well.....presuming you do have some....)
    Really, it's bizarre how much this gets
    asked. I think I'll start a new thread about it...Be realistic....the integer to string or string to integer gets asked a lot more often!

  • Boolean Expression Evaluator

    Hello everyone...
    Does any one know how to create a Java program that will evaluate boolean expression... For example, the user may enter (T AND T) OR F statement and the program will check the expression is valid or not and in addition it gives the answer T for true. Does anyone know where to download the free sample code that will be able to help me.. thanks.
    URGENT!
    -Eugene-

    http://www.japisoft.com/formula
    Features :
    * Decimal, string, boolean operators (or, and, not, xor...)
    * Unicode
    * Boolean expression support : (A or B) and not ( C equals D )
    * String expression support : "abc" != "cba"
    * IF THEN ELSE expression
    * Short expression format : 2x+3y
    * Variable : A=(cos(PI + x )*2) + [y-x]^2
    * Multiple lines expression : A = 1 B = A + 1 ...
    * Functions with decimal, boolean or string arguments
    * Evaluation tree produced by a pluggable parsing system
    * Evaluation optimization for symbol value changes
    * Standard library with 24 mathematical functions
    * Delegate for resolving unknown functions or symbols
    * Extend or add a new library dynamically
    * Share multiple formula context
    * Override any functions from the current library by your one
    * Support for multithreaded computing
    * Many samples (library extension, graphes) for API interesting parts
    * JDK 1.1 compliant (tested on JDK1.1.8 and JDK1.4.2)
    Best regards,
    A.Brillant

  • Search problems : Boolean expressions and spam folder

    I get about 1000 spam per day that I have to check.
    Some of them contains certain keyword that the real emails would never have.
    I would like to setup a smart folder or similar that found all emails in the spam folder that contains any of those keywords. I read some blogs etc. that said that spotlight boolean expressions could be used but they do not seem to work.
    e.g. "pill OR berry" yields no results at all but when each of the keywords are used on their own they produce 80 or so results each.
    Another problem I have is that I can do a manual search in the spam folder by typing in the search field and it yields results. But if I save that as a smart folder it yields no results at all. It seems that the rules do not work on the spam folder.
    I then tried to do all this from spotlight in the finder. I found the folder where the spam mailbox emails are stored (called "messages"). I managed to construct a nice search query and save it as a search. But if I delete one of the emails from the finder it still remains in Mail and the next time I start Mail it will be regenerated from somewhere.
    Anyone have any insights to provide here?

    I had actually missed that preference. Unfortunately it did not help.
    Even if I make a new smart mailbox with just one rule (the email must be in the spam folder) it doesnt work. It doesn't matter if I change between any/all either.
    I started experimenting with adding a rule saying that the email must not be in any of the other mailboxes but spam. That seemed to work for a bit but as I added more rules, excluding more mailboxes, it eventually broke. I will investigate it a bit more but currently don't have high hopes...

  • Data Change Condition Expression

    I need to create a product specification that includes dependencies between order components based on a data change notification wait condition
    How do I define the XQuery expression in the "Data Change Condition Expression" field?
    Specifically, I have 4 order components in the product specification that are independent of each other but each order component can only start when a specific data element has a certain value. The data element is at the order level and is not available as an order line item property.
    I would appreciate if someone from Oracle can provide a more detailed explanation of the fields in the "Product Specification Editor Dependencies Subtab" ->"Wait Condition subtab"
    Relative Path
    Data Change Condition Expression
    Thanks,
    ~nagu.
    Edited by: nagu on Dec 2, 2011 5:50 PM

    Provide two pieces of information:
    1. Order Item Property
    2. Boolean XQuery expression returning fn:true() to fire the dependency.
    For example:
    Assume you need to ensure all Provisioining items (From) must have reached the "PRODUCT STARTED" milestone , before the Billing Component Items (To) can start.
    Note From Component is also known as "blocking" while the To Component is known as "Waiter"
    1. Data Change Notification property: milestone
    2. Data Change Condition Expression Xquery:
    declare variable $blockingIndexes as xs:integer* external; (: list of From component items - index :)
    let $expectedMilestoneCode := "PROVISION STARTED"
    (: extract milestones values from all provisioning function items matching the expected milestone value , only for the given From component :)
    let $milestoneValues := /GetOrder.Response/_root/ControlData/Functions/ProvisioningFunction/orderItem/orderItemRef[fn:index-of($blockingIndexes, xs:integer(@referencedIndex)) != 0]/milestone[text() eq $expectedMilestoneCode]
    (: Return true only if ALL the milestones in the From component (ProvisioningFunction/orderItem/orderItemRef) are PROVISION STARTED :)
    return fn:count($milestoneValues) eq fn:count($blockingIndexes)
    Carlos

  • Dynamic execution of boolean expression

    Hi folks,
    I want to execute a boolean expression dynamically, can you pls help me how to do it.
    For example,
    String str = " ( X & ( Y | Z ) ) " ;
    They value of X , Y or Z will be either true or false.
    After replacing their value, I will get string as follow
    String result = "( true & (false | true ) ".
    Now I want to execute the String as boolean expression in order to get
    a result as a true or false.
    So, i need a solution to implement this. The expression may be simple or compound . It is so urgent waiting for your reply.
    Appreciated if you provide sample code.
    Thx !
    With regards,
    Rahul

    Java is a compiled language (well, strictly, a semi-compiled language.) This means that stuff like parsing expressions only happens at compile time. Variable names don't exist at run time, neither does the code which analyses expressions.
    If you really need to do this kind of thing, therefore, all the code for parsing these expressions has to be a part of your program, and stuff like values for variable names will have to be set explicitly by your program, not in regular variables but in variable list for the "scripting engine" you invoke.
    You can either write your own expression analyser (not a trivial task if you haven't done it before) or you can search arround the web for one someone else has written and find out if it covers your requirements. BeenShell has been suggested. Find it on the web and study it's documentation.
    Incidentally when the new release of Java comes out it will include serveral such "Scripting engines" for languages like JavaScript or Jython, and such things will be less hastle.

  • Boolean Expression Parsing

    Hi
    i have a String like "true && !true && (false || true)" and want to know if the expression is true or false. Is there any Helperclass that parses an boolean expression??
    String expression = "true && !true && (false || true)";
    boolean result = BooleanParser.parse(expression );
    Regard,
    Harald

    thats not cheating, just the simplest way to solvethe problem ;)
    ... and one missed opportunity to learn something
    about parser generators.I think there is something to be said for taking classes on that particular subject.
    That particular study area is well defined in computer science is well defined. So the good ideas that one can use are already there just waiting to be learned.

  • Boolean expression pars and evaluate

    Hi
    I need to know if there is code that suggests weather a string is a correct boolean expression or not . if it is, it evaluates it.
    foe example :
    x+1>8 returns true if x=10 e.g
    y-1 is is a wrong boolean expression
    thanx
    Niema

    As far as I know, there is no API that can do something like EVAL in BASIC (which was the last place I saw a feature like this). If you are feeling ambitious, you could write a parser to divide the String into an expression tree, substitute values for variables, and evaluate it.
    But in all probability there is simply another (easier) way of approaching whatever you are trying to do.

  • DNF boolean expressions

    Hi folks,
    I would like to produce a "minimal" boolean expression in disjunctive normal form.
    Something like a AND b OR c to
    DNF: ab or ac
    Therefor i have developed a parser which produces that normal form, but the performance decreases very much if i parse expressions with lots of variables or nested expressions like:
    (a AND (b OR c OR d) AND (e OR f OR g)) OR ((b OR c OR d) AND (e OR f OR g) AND h) OR (i AND (e OR f OR g))
    It lastes up to 5 seconds.
    Do u know any free api, which i could use for this purpose?.
    Thanks in advance.

    Thats the code:
    package com.audatex.axn.ui.vsic.datamodel.util;
    import java.util.Vector;
    public class BooleanExpressionsParser
        private static final Logger _logger =  new Logger( JATOTest.class );
        public static int nVars;
        public static int nAmount;
        public static String sActiveVars;
        public static String sValidInput;
        public boolean isK0, isK1, isKsd, isKlinear, isKmonoton;
        public static boolean[] arResults;
        private static CBoolFkt cBoolFkt = new CBoolFkt();
        public static int format(String exp) {
            int result = cBoolFkt.format(exp);
            if (result == CBoolFkt.OK) {
                nVars = cBoolFkt.nMinVars;
                nAmount = 1 << nVars;
                sActiveVars = cBoolFkt.sActiveVars.toString();
                sValidInput = cBoolFkt.sValidInput.toString();
            return result;
        public static String doCalc() {
            arResults = new boolean[nAmount];
            for (int i = 0; i < nAmount; i++) {
                for (int run = 0; run < nVars; run++) {
                    cBoolFkt.Vars[cBoolFkt.sActiveVars.charAt(run)] = isBitSet(i,
                            nVars - run - 1);
                arResults[i] = cBoolFkt.evaluate();
            return doNF();
        public static String convertExpression(String boolExpression){
            _logger.debug(" " + boolExpression);
            int result = format(boolExpression);
            String res = "";
            if(result == CBoolFkt.OK){
                _logger.debug("The format is O.k ,doing calculation ");
                res = doCalc();
        return res;
        private static String  doNF() {
            StringBuffer sMDNF = new StringBuffer();
            return doQuineMcClusky( sMDNF);
        private static String doQuineMcClusky(StringBuffer sMDNF) {
            Vector arConjunctions = new Vector();
            Vector arUsedVars = new Vector();
            Vector arMarked = new Vector();
            int nUsedVarsMask = nAmount - 1;
            for (int i = 0; i < nAmount; i++) {
                if (arResults) {
    arConjunctions.addElement(new Integer(i));
    arUsedVars.addElement(new Integer(nUsedVarsMask));
    arMarked.addElement(new Boolean(false));
    _logger.debug("arConjunctions.size(): " + arConjunctions.size());
    for (int level = 0; level < nVars; level++) {
    int nConjunctions = arConjunctions.size();
    if (nConjunctions <= 1) {
    break;
    for (int checknr = 0; checknr < nConjunctions - 1; checknr++) {
    for (int comparenr = checknr + 1; comparenr < nConjunctions;
    comparenr++) {
    if (((Integer) arUsedVars.elementAt(checknr)).intValue() ==
    ((Integer) arUsedVars.elementAt(comparenr)).intValue()) {
    int checkval = ((Integer) arConjunctions.elementAt(
    checknr)).intValue();
    int compareval = ((Integer) arConjunctions.elementAt(
    comparenr)).intValue();
    int DifferMask = xOrBits(checkval, compareval);
    if (bitCount(DifferMask) == 1) {
    arMarked.setElementAt(new Boolean(true), checknr);
    arMarked.setElementAt(new Boolean(true), comparenr);
    int NewConj = andBits(checkval, compareval);
    int NewMask = xOrBits(DifferMask,
    ((Integer) arUsedVars.
    elementAt(checknr)).intValue());
    arConjunctions.addElement(new Integer(NewConj));
    arUsedVars.addElement(new Integer(NewMask));
    arMarked.addElement(new Boolean(false));
    nConjunctions = arConjunctions.size();
    for (int checknr = 0; checknr < nConjunctions - 1; checknr++) {
    if (((Boolean) arMarked.elementAt(checknr)).booleanValue() == false) {
    for (int comparenr = checknr + 1; comparenr < nConjunctions;
    comparenr++) {
    if (((Boolean) arMarked.elementAt(comparenr)).
    booleanValue() == false) {
    int checkval = ((Integer) arConjunctions.elementAt(
    checknr)).intValue();
    int compareval = ((Integer) arConjunctions.
    elementAt(comparenr)).intValue();
    int checkmask = ((Integer) arUsedVars.elementAt(
    checknr)).intValue();
    int comparemask = ((Integer) arUsedVars.elementAt(
    comparenr)).intValue();
    int maskand = andBits(checkmask, comparemask);
    if (checkmask == comparemask) {
    if (checkval == compareval) {
    arMarked.setElementAt(new Boolean(true),
    comparenr);
    } else {
    if ((maskand == checkmask) &&
    (andBits(compareval, maskand) == checkval)) {
    arMarked.setElementAt(new Boolean(true),
    comparenr);
    if ((maskand == comparemask) &&
    (andBits(checkval, maskand) == compareval)) {
    arMarked.setElementAt(new Boolean(true),
    checknr);
    for (int cleanup = nConjunctions - 1; cleanup >= 0; cleanup--) {
    if (((Boolean) arMarked.elementAt(cleanup)).booleanValue() == true) {
    arConjunctions.removeElementAt(cleanup);
    arUsedVars.removeElementAt(cleanup);
    arMarked.removeElementAt(cleanup);
    for (int i = 0; i < arConjunctions.size(); i++)
    int nUsed = ((Integer) arUsedVars.elementAt(i)).intValue();
    int nConj = ((Integer) arConjunctions.elementAt(i)).intValue();
    for (int run = 0; run < nVars; run++) {
    if (isBitSet(nUsed, nVars - run - 1)) {
    if (!isBitSet(nConj, nVars - run - 1)) {
    sMDNF.append("!");
    sMDNF.append(cBoolFkt.sActiveVars.charAt(run));
    sMDNF.append(" | ");
    // _logger.debug(arConjunctions.toString());
    //_logger.debug(arUsedVars.toString());
    //_logger.debug(arMarked.toString());
    sMDNF.setLength(sMDNF.length() - 3);
    return sMDNF.toString();
    public static boolean isBitSet(int Number, int Bit) {
    return (Number & (1 << Bit)) > 0;
    public static int andBits(int a, int b) {
    int Result = 0;
    int CurrBit = 0;
    while ((a > 0) || (b > 0)) {
    if (isBitSet(a, 0) && isBitSet(b, 0)) {
    Result += 1 << CurrBit;
    CurrBit++;
    a >>= 1;
    b >>= 1;
    return Result;
    public static int xOrBits(int a, int b) {
    int Result = 0;
    int CurrBit = 0;
    while ((a > 0) || (b > 0)) {
    if (isBitSet(a, 0) != isBitSet(b, 0)) {
    Result += 1 << CurrBit;
    CurrBit++;
    a >>= 1;
    b >>= 1;
    return Result;
    public static int bitCount(int Number) {
    int Result = 0;
    while (Number > 0) {
    if ((Number & 1) != 0) {
    Result++;
    Number >>= 1;
    return Result;
    * @return Returns the cBoolFkt.
    public CBoolFkt getCBoolFkt() {
    return cBoolFkt;
    * @param boolFkt The cBoolFkt to set.
    public void setCBoolFkt(CBoolFkt boolFkt) {
    cBoolFkt = boolFkt;
    public class CBoolFkt {
    // Constants to handle exceptions
    public static final int OK=0, NOTOKEN=1, UNKNOWNTOKEN=2,
    NOVARS=3, VAREXPECTED=4,
    BRACKETEXPECTED=5, BRACKETNOTALLOWED=6;
    // max. number of diferent vbles in the boolean expression
    public final int nMaxVars = 12;
    // Amount of current dif. vbles in the boolean exp.
    public int nMinVars;
    // Name of the current bool. exp sorted by alph. order
    public StringBuffer sActiveVars;
    public StringBuffer sValidInput;
    // Wertebelegung der Variablen by ASCII-Namen, also z.B. Vars['a']=true
    public boolean[] Vars = new boolean[128];
    // Name of the vbles.
    final char A='a', B='b', C='c', D='d',
    E='e', F='f', G='g', H='h',
    I='i', J='j', K='k', L='l',
    // operators
    OR='|', AND='&', XOR='+', EQU='=', _NOT='!',
    LOG='>', LB='(', RB=')', TRUE='1', _FALSE='0',
    _END=0;
    // Words that are replaced by the symbols behind
    final String[] arLongNames = { "or","oder","and","und",
    "xor","not","nicht","=>" };
    final char[] arLongToken = { '|','|','&','&','+','!','!','>' };
    private StringBuffer sExpression;
    private int iExpressionCount;
    private char cToken;
    // Detection of no valid syntax and integration of the expression with the language
    // of the parser
    public int format(String expression)
    boolean bForceVar = true;
    int nBracketCount = 0;
    sValidInput = new StringBuffer();
    if (expression.length()==0)
    return NOTOKEN;
    // convert to lower case
    expression = expression.toLowerCase();
    // for replacing the key words by symbols
    StringBuffer sNoLongNames = new StringBuffer(expression);
    // process de convertion
    for (int i=0; i<arLongNames.length; i++)
    while(sNoLongNames.toString().indexOf(arLongNames[i])!=-1)
    StringBuffer sTemp = new StringBuffer();
    // saveing word address
    int index = sNoLongNames.toString().indexOf(arLongNames[i]);
    if (index>0)
    sTemp.append(sNoLongNames.toString().substring(0,index));
    // replacing word
    sTemp.append(arLongToken[i]);
    if ((index+arLongNames[i].length())<sNoLongNames.length())
    sTemp.append(sNoLongNames.toString().substring(index+arLongNames[i].length()));
    sNoLongNames = sTemp;
    // convertion complete
    expression = sNoLongNames.toString();
    for (int i=0; i<expression.length(); i++)
    // Testing tokens
    switch(expression.charAt(i))
    case ' ': continue;
    // valid tokens
    case FALSE:; case TRUE:;
    case A:; case B:; case C:; case D:;
    case E:; case F:; case G:; case H:;
    case I:; case J:; case K:; case L:
    // every next token ist ok
    bForceVar = false;
    // ok
    sValidInput.append(expression.charAt(i));
    break;
    case _NOT:;
    // the next token must be vble
    bForceVar = true;
    // ok
    sValidInput.append(expression.charAt(i));
    break;
    case AND:; case OR:; case XOR:; case LOG:; case _EQU:;
    if (bForceVar)
    return VAREXPECTED;
    // the next token must be vble
    bForceVar = true;
    // ok
    sValidInput.append(expression.charAt(i));
    break;
    case _LB:;
    nBracketCount++;
    bForceVar = true;
    // ok
    sValidInput.append(expression.charAt(i));
    break;
    case _RB:;
    if (bForceVar||(nBracketCount==0))
    return BRACKETNOTALLOWED;
    nBracketCount--;
    // ok
    sValidInput.append(expression.charAt(i));
    break;
    // not valid token
    default: return UNKNOWNTOKEN;
    if (nBracketCount!=0)
    return BRACKETEXPECTED;
    if (bForceVar)
    return VAREXPECTED;
    // Counter of the number of vbles
    nMinVars=0;
    sActiveVars = new StringBuffer();
    // limitating pos vble names
    String sAllVars = "abcdefghijkl";
    // testing the vbles
    int i;
    for (i=0; i<nMaxVars; i++)
    if (sValidInput.toString().indexOf(sAllVars.charAt(i))!=-1)
    nMinVars++;
    sActiveVars.append(sAllVars.charAt(i));
    if (nMinVars==0)
    return NOVARS;
    expression = sValidInput.toString();
    sExpression = sValidInput;
    sExpression.append(_END);
    return OK;
    public boolean evaluate()
    sExpression = sValidInput;
    iExpressionCount = 0;
    return doEqu(true);
    private boolean doEqu(boolean get)
    boolean left = doLog(get);
    for (;;)
    if (cToken==_EQU)
    left=(doLog(true)==left);
    else
    return left;
    private boolean doLog(boolean get)
    boolean left = doOr(get);
    for (;;)
    if (cToken==_LOG)
    // a>b=!a|b
    left=doOr(true)||!left;
    else
    return left;
    private boolean doOr(boolean get)
    boolean left = doXor(get);
    for (;;)
    if (cToken==_OR)
    left|=doXor(true);
    else
    return left;
    private boolean doXor(boolean get)
    boolean left = doAnd(get);
    for (;;)
    if (cToken==_XOR)
    left^=doAnd(true);
    else
    return left;
    private boolean doAnd(boolean get)
    boolean left = doPrimary(get);
    for (;;)
    switch (cToken)
    case _AND:
    left&=doPrimary(true); break;
    case A:; case B:; case C:; case D:;
    case E:; case F:; case G:; case H:;
    case I:; case J:; case K:; case L:;
    case LB:; case NOT:
    left&=doPrimary(false); break;
    default:
    return left;
    private boolean doPrimary(boolean get)
    if (get)
    getToken();
    boolean temp;
    switch (cToken)
    case A:; case B:; case C:; case D:;
    case E:; case F:; case G:; case H:;
    case I:; case J:; case K:; case L:;
    temp = Vars[cToken];
    getToken();
    return temp;
    case _NOT:
    return !doPrimary(true);
    case _TRUE:
    getToken();
    return true;
    case _FALSE:
    getToken();
    return false;
    case _LB:
    temp = doEqu(true);
    getToken();
    return temp;
    default: return true;
    private void getToken()
    cToken = sExpression.charAt(iExpressionCount++);
    I try to convert the expression, not to evaluate it.
    For example:
    (a and b) or c and (d and b) ---> DNF: b & c & d l a & b

  • How to change sql expression of SQL-Calculated Attribute of view object ?

    Hi
    jdev 11.1.1.5
    I have a view object with a SQL-Calculated Attribute (sumAnalytic) how can I change sql expression of this attribute in runtime?
    for example in application module method??

    Hi Mr Timo
    Thanks for your reply but I do not need dynamic vo because I can not change all of my vo
    I only need to change expression of SQL-Calculated Attribute of view object in run time.
    For this I set expression in view object something like this 'select 2 from dual' and in run time in my AM method I get the vo query and replace 'select 2 from dual' with something like 'selet sum(amnt) over (partition by 1)' and set new query.
    But I think the better solution must exist
    Thanks

  • Can i use Boolean Expressions in Mail Rules?

    Can i use Boolean Expressions in Mail Rules?
    I need to create a rule to check whether a message contains BOTH a first and last name of EITHER of two people.
    For example, the rule im looking to create goes something like this:
    If ANY of the following conditions are met:
    message content - contains - john & doe
    message content - contains - jane & doe
    ive tried and cant seem to get it to work...
    Message was edited by: mysterioso

    AFAIK Mail rules do not support boolean expressions.
    to do what you want you'd have to create two rules
    rule 1
    if ALL of the following conditions are met
    message content - contains - john
    message content - contains - jdoe
    and similarly for rule 2.

  • Wat should be the regular expression for string MT940_UB_*.txt to be used in SFTP sender channel in PI 7.31 ??

    Hi All,
    What should be the regular expression for string MT940_UB_*.txt and MT940_MB_*.txt to be used as filename inSFTP sender channel in PI 7.31 ??
    If any one has any idea on this please let me know.
    Thanks
    Neha

    Hi All,
    None of the file names suggested is working.
    I have tried using - MT940_MB_*\.txt , MT940_MB_*.*txt , MT940*.txt
    None of them is able to pick this filename - MT940_MB_20142204060823_1.txt
    Currently I am using generic regular expression which picks all .txt files. - ([^\s]+(\.(txt))$)
    Let me know ur suggestion on this.
    Thanks
    Neha Verma

  • How to convert a boolean expression into a number in SQL (not PL/SQL)

    I have a boolean expression
    FIELD IN (SELECT FIELD FROM TABLE)
    which I would like to convert into a number, preferably into 0 for true and into 1 for false. The reason being that I want to sum the values in a HAVING clause.
    I have tried with DECODE, SIGN, TO_NUMBER, but all fail with an error message to the order of wrong type of argument.
    Does anyone have an idea?
    /poul-jorgen

    Hi, you can do it with case if you have Oracle 9i
    Regards
    Laurent
    select case when dummy in ('X') then 1 else 0 end from dual;

  • Pl/sql boolean expression short circuit behavior and the 10g optimizer

    Oracle documents that a PL/SQL IF condition such as
    IF p OR q
    will always short circuit if p is TRUE. The documents confirm that this is also true for CASE and for COALESCE and DECODE (although DECODE is not available in PL/SQL).
    Charles Wetherell, in his paper "Freedom, Order and PL/SQL Optimization," (available on OTN) says that "For most operators, operands may be evaluated in any order. There are some operators (OR, AND, IN, CASE, and so on) which enforce some order of evaluation on their operands."
    My questions:
    (1) In his list of "operators that enforce some order of evaluation," what does "and so on" include?
    (2) Is short circuit evaluation ALWAYS used with Boolean expressions in PL/SQL, even when they the expression is outside one of these statements? For example:
    boolvariable := p OR q;
    Or:
    CALL foo(p or q);

    This is a very interesting paper. To attempt to answer your questions:-
    1) I suppose BETWEEN would be included in the "and so on" list.
    2) I've tried to come up with a reasonably simple means of investigating this below. What I'm attempting to do it to run a series of evaluations and record everything that is evaluated. To do this, I have a simple package (PKG) that has two functions (F1 and F2), both returning a constant (0 and 1, respectively). These functions are "naughty" in that they write the fact they have been called to a table (T). First the simple code.
    SQL> CREATE TABLE t( c1 VARCHAR2(30), c2 VARCHAR2(30) );
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg AS
      2     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER;
      3     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER;
      4  END pkg;
      5  /
    Package created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY pkg AS
      2 
      3     PROCEDURE ins( p1 IN VARCHAR2, p2 IN VARCHAR2 ) IS
      4        PRAGMA autonomous_transaction;
      5     BEGIN
      6        INSERT INTO t( c1, c2 ) VALUES( p1, p2 );
      7        COMMIT;
      8     END ins;
      9 
    10     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER IS
    11     BEGIN
    12        ins( p, 'F1' );
    13        RETURN 0;
    14     END f1;
    15 
    16     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER IS
    17     BEGIN
    18        ins( p, 'F2' );
    19        RETURN 1;
    20     END f2;
    21 
    22  END pkg;
    23  /
    Package body created.Now to demonstrate how CASE and COALESCE short-circuits further evaluations whereas NVL doesn't, we can run a simple SQL statement and look at what we recorded in T after.
    SQL> SELECT SUM(
      2           CASE
      3              WHEN pkg.f1('CASE') = 0
      4              OR   pkg.f2('CASE') = 1
      5              THEN 0
      6              ELSE 1
      7           END
      8           ) AS just_a_number_1
      9  ,      SUM(
    10           NVL( pkg.f1('NVL'), pkg.f2('NVL') )
    11           ) AS just_a_number_2
    12  ,      SUM(
    13           COALESCE(
    14             pkg.f1('COALESCE'),
    15             pkg.f2('COALESCE'))
    16           ) AS just_a_number_3
    17  FROM    user_objects;
    JUST_A_NUMBER_1 JUST_A_NUMBER_2 JUST_A_NUMBER_3
                  0               0               0
    SQL>
    SQL> SELECT c1, c2, count(*)
      2  FROM   t
      3  GROUP  BY
      4         c1, c2;
    C1                             C2                               COUNT(*)
    NVL                            F1                                     41
    NVL                            F2                                     41
    CASE                           F1                                     41
    COALESCE                       F1                                     41We can see that NVL executes both functions even though the first parameter (F1) is never NULL. To see what happens in PL/SQL, I set up the following procedure. In 100 iterations of a loop, this will test both of your queries ( 1) IF ..OR.. and 2) bool := (... OR ...) ).
    SQL> CREATE OR REPLACE PROCEDURE bool_order ( rc OUT SYS_REFCURSOR ) AS
      2 
      3     PROCEDURE take_a_bool( b IN BOOLEAN ) IS
      4     BEGIN
      5        NULL;
      6     END take_a_bool;
      7 
      8  BEGIN
      9 
    10     FOR i IN 1 .. 100 LOOP
    11 
    12        IF pkg.f1('ANON_LOOP') = 0
    13        OR pkg.f2('ANON_LOOP') = 1
    14        THEN
    15           take_a_bool(
    16              pkg.f1('TAKE_A_BOOL') = 0 OR pkg.f2('TAKE_A_BOOL') = 1
    17              );
    18        END IF;
    19 
    20     END LOOP;
    21 
    22     OPEN rc FOR SELECT c1, c2, COUNT(*) AS c3
    23                 FROM   t
    24                 GROUP  BY
    25                        c1, c2;
    26 
    27  END bool_order;
    28  /
    Procedure created.Now to test it...
    SQL> TRUNCATE TABLE t;
    Table truncated.
    SQL>
    SQL> var rc refcursor;
    SQL> set autoprint on
    SQL>
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    100
    TAKE_A_BOOL                    F1                                    100
    SQL> ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0;
    Session altered.
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    200
    TAKE_A_BOOL                    F1                                    200The above shows that the short-circuiting occurs as documented, under the maximum and minimum optimisation levels ( 10g-specific ). The F2 function is never called. What we have NOT seen, however, is PL/SQL exploiting the freedom to re-order these expressions, presumably because on such a simple example, there is no clear benefit to doing so. And I can verify that switching the order of the calls to F1 and F2 around yields the results in favour of F2 as expected.
    Regards
    Adrian

  • How to generate pulse during changing boolean value?

    I need to generate short pulse during changing boolean value from 0 to 1. This pulse is needed to reset counter. 
    I was trying with Event Structure with Value Change but I think that I did something wrong.
    Maybe sambody can give me some tips to do it in other way?
    Thank you in advance.
    Regards
    Solved!
    Go to Solution.

    Rogal wrote:
    I need to generate short pulse during changing boolean value from 0 to 1. This pulse is needed to reset counter. 
    I was trying with Event Structure with Value Change but I think that I did something wrong.
    Maybe sambody can give me some tips to do it in other way?
    Thank you in advance.
    Regards
    We assumed you wanted a pulse when a front panel button (boolean) was clicked.
    I am still not sure just what it is you want.
    Do you want a single pulse when x is greater than 4?
    You don't need an event structure for that.
    Omar

Maybe you are looking for

  • How can I erase old sports schedules

    I have schedules for 5 sports teams. Football, baseball and hockey. I have the settings to remove anything over 60 days, HOWEVER : (1) Last years football and hockey full season games are still showing. (2) The full baseball schedule is showing from

  • Pass Class Object To FMS Using NetConnection.call Method

    Hello All, I have a custom class that defines several methods on itself to retrieve its data. This class object is then sent to FMS via the NetConnection.call method. Once received by FMS, FMS calls the remote method to dispaly the class object on co

  • Gnome-settings-daemon no where to be found

    Hello again .. Ive read about this posted earlier but I cant find a solution to that problem anywhere.. Ok so Ive been using linux for a few months now, and only through KDE. Ive tried several other WM .. actually probably every one of them at least

  • Add Val.Fld/Key Fig. for use it in KEU2

    Hi,    Can i add a new Val.Fld/Key Fig., like a Netsales, for use it in a CO-PA cycle in a KEU2?    Where can i define it?, because i need a formula, the total of two Val.Fld/Key Fig already defined. Thanks in advance.

  • How to download SMARTFORM in 4.6c

    Hi,   Can any one tell me is there any option for downloading SMARTFORMS in 4.6c.   I've already checked the utilities option as we could find in 4.7 and cannot find such an option anywhere.   so pls help me in fixing this? Cheers, Prashanth K.R