XQuery syntax to evaluate math formula

I want to evaluate a math formula inside of a function, so I can't use dynamic SQL.
I found that the query on an XML-variable with a literal works well.
 DECLARE @sParsedFormula varchar(200);
 DECLARE @xFormula xml;
 SET @xFormula = '';
 SET @sParsedFormula = '1+2';
 SELECT @xFormula.query('3+3') , @xFormula.query('sql:variable("@sParsedFormula")')
Output (1st value is correctly evaluated, 2nd not):
"6", "1+2"
I can't directly pass @sParsedFormula to the query otherwise I get "The argument 1 of the XML data type method "query" must be a string literal".
What is the correct XQuery-syntax to evaluate the SQL:variable?
Tx,
Patrick

You are obviously on the wrong track when you ask for the impossible.
You can use sql:variable in XQuery to provide a value. You cannot provide an
expression.
If you want to pursue the set-up, your function will have to parse the expression and evalaute it. You can do this is in T-SQL, but it is not the best language for string parsing. Count on wast^H^H^H^Hspending quite a few hours on the development.
If you do it in C#, undoubtedly it will be easier, and I would expect that you can find classes that performs the parsing and evaluation. This can reduce your development costs considerably.
Of the languages I have worked with, there is one where the evaluting the expressions are dirt simple: Perl. Here you can just say
  $value = eval($expr)
But running Perl code from SQL Server? Nah.
If you want to do this in T-SQL only, it will have to be dynamic SQL. To avoid the cursor you can do somthing like:
   SELECT @sql =
     (SELECT 'SELECT ' + ltrim(str(id)) + ', ' + expr + ';' + char(13) + char(10)
      FROM   #temp
      FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
  PRINT @sql
  INSERT #newtemp(id, value)
     EXEC (@sql)
  UPDATE #temp
  SET    value = n.value
  FROM   #temp t
  JOIN   #newtemp n ON t.id = n.id
So, yes, XML had a place in your solution. But where you were looking.
But note that with this solution, you will lose it all if one expression does not parse.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Syntax for Evaluate function in OBIEE

    Hi
    I have browsed through the docs but couldn't find syntax for Evaluate function. Could someone pass me the full syntax and if possible a helpful example against essbase.
    Thanks

    Hi
    definitely
    syntax:- EVAULATE('your db function(%1,%2)', parameter list)
    here %1 and %2 are the no.of parameters (columns or may constant values) to be passed for the db-function
    if you have 3 parameters then you need to use %3 also.. means the columns to be passed.
    following exapmples are for ORACLE db,
    ex1: EVALUATE('upper(%1)', 'kishore kumar') gives the result as -> KISHORE KUMAR
    ex2: EVALUATE('upper(%1)', 'Markets.Region') here Markets.Region is column.
    you also can call the user-defined functions through evaulate
    EVALUATE('functioname(%1,%2), column1, column2)
    the above function has 2 parameters to be inputted
    Thanks & Regards
    Kishore Guggilla
    Edited by: Kishore Guggilla on Jan 16, 2009 11:00 PM

  • Using a Math Formula in AS3

    Hi,
    I am trying to test using a math formula (probit function) in AS3. I can't get the script to work: the dynamic text box is displaying NaN after I run the function and use a hard-coded number for the variable. Here's the button's script that is getting a NaN display. I must be doing something wrong and would appreciate any help getting it working.
    stop()
    var p:Number = 39 //hard-code this number for testing
    function NORMSINV(p:Number):Number {
        // Coefficients in rational approximations
        var a:Array = new Array(-3.969683028665376e+01,  2.209460984245205e+02,
                              -2.759285104469687e+02,  1.383577518672690e+02,
                              -3.066479806614716e+01,  2.506628277459239e+00);
        var b:Array = new Array(-5.447609879822406e+01,  1.615858368580409e+02,
                              -1.556989798598866e+02,  6.680131188771972e+01,
                              -1.328068155288572e+01 );
        var c:Array = new Array(-7.784894002430293e-03, -3.223964580411365e-01,
                              -2.400758277161838e+00, -2.549732539343734e+00,
                              4.374664141464968e+00,  2.938163982698783e+00);
        var d:Array = new Array (7.784695709041462e-03, 3.224671290700398e-01,
                               2.445134137142996e+00,  3.754408661907416e+00);
        // Define break-points.
        var plow:Number=0.02425;
        var phigh:Number=1-plow;
        // Rational approximation for lower region:
        if (p<plow) {
            var q:Number=Math.sqrt(-2*Math.log(p));
            return (((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
                                                         ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
        // Rational approximation for upper region:
        if (phigh<p) {
            q=Math.sqrt(-2*Math.log(1-p));
            return -(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
                                                                ((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
        // Rational approximation for central region:
        q=p-0.5;
        var r:Number=q*q;
        return (((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q /
                                     (((((b[0]*r+b[1])*r+b[2])*r+b[3])*r+b[4])*r+1);
    var n1:Number=NORMSINV(p)
    mathBtn.addEventListener(MouseEvent.CLICK, mathButtonClick, false, 0, true);
    function mathButtonClick(e:MouseEvent):void {
        T1.text = n1.toString()    //click the button and NaN displays
    Regards,
    saratogacoach

    I don't know the formula that you're trying to achieve, but the log and sqrt must use positive values.
    If you're uncertain if a variable (or formula result) will give you a negative result and you need a positive one, you can use the Math.abs, which return s always a positive value.
    I've just altered like this in the first IF:
    var q:Number=Math.sqrt(Math.abs(-2*Math.log(p)));
    and in the second:
    q=Math.sqrt(Math.abs(-2*Math.log(Math.abs(1-p))));
    In this case the second formula has two Math.abs since I don't know the result of "1-p" (in this case is negative) and then you multiply by "-2" wich will make the number negative again, so it has to be positive for the square root. If you have the change consider changing the formula to see you can eliminate, so many Math.abs, make it simple.
    Otherwise is just a question of predicting results and see if the formula fits right.

  • Math formulas and docs for IP forecasting strategies

    Hi all,
    For better understanding I neew math formulas for IP forecasting strategies.
    I've found some references on page http://help.sap.com/erp2005_ehp_04/helpdata/EN/44/03134ec148333de10000000a1553f7/content.htm to "For more information about forecasting in the context of demand planning, see http://help.sap.com/  ® Documentation ® mySAP Business Suite ® mySAP Supply Chain Management ® SAP Supply Chain Management ® SAP Advanced Planning and Optimization (SAP APO) ® Demand Planning ® Demand Planning Process ® Definition/Redefinition of Forecast Models ® Creating a Master Forecast Profile ® Univariate Forecasting."
    But I'didnt found that page. Any ideas?
    Thanks

    Hi,
    It could help...
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/1051f12c-66da-2b10-6dac-ec3acef8c4e8

  • How to use math formula on waveforms

    Hi all,
    I'm trying to create a program that can use math scipts, formulas etc on waveforms. I've done it for one signal, but I don't know how to change work on 2 or more signals;/ Let's see exampe: one channel is voltage, the second is current and I want to see both of them and as a third signal power so I'm writting formula ch3=ch1*ch2. Another example: I've signal which represents speed of starting motor (500 points) but I need only few points so the formula will be: ch1(20:120) and I have points from 20 to 120. Is it possible to do it? I can't do it using blocks cause I don't know which signal means what... so ch1 can be voltage, ch2 speed, ch3 current ch4-torqu etc. I know that I can cut a part of signal by subarray or subwaveform but it must be done by formula to use (for example) something like that:
    ch1(1:20)=0 <- replace all point from 1 to 20 of ch1 by 0
    ch2(50)=40 <-replace point 50 of ch2 by 40
    ch3=ch1*2 + ch2 <- do this operation but first do both above this one.
    Is it possible? or it's to complicated?
    I attached my vi which is working for one selected signal (I don't want to select it... but I don't know how to do it;/) and signal that I'm using to check how it's work
    Thanks
    Mike
    Attachments:
    Archive.zip ‏134 KB
    math formula.vi ‏152 KB

    I've upgraded it a little and it works with 2 signals but very sensible;/ formula must have this construction: c3= ... , both of signals must be switched on, there's no way to use part of signal (e.g.c1(21:54) ) and I can't use 2 rows (something like this: c3=c1*c2; c3=c1 doesn't work);/ additionally I wanted to have possibility to use all of signals as input and all of them as output
    Attachments:
    math formula.vi ‏183 KB

  • Help - Nested XMLQuery (XQuery) Syntax

    I need to query a relational table that includes an XMLType column as Binary XML.  The XMLType column contains an XML document of arbitrary length. My query is in part dependent on relational column values and data values within the XML documents.  The body of the XML document, beneath the root element, is composed of 3 main sections (elements): Header1, 1/document; Header2, 1/document; and Details, 1/document.  The Details section is composed of multiple, arbitrary in number, Detail sections (elements). Example data and table layout are below.
    For a particular TLID or CUST, or SHIP_DATE, etc. I need to return the Header1, Header2, and multiple Detail sections where element values within particular Detail sections match additional qualifications.
    If I just want to return the Detail sections, I can do this successfully with the following query:
    select cust,  tlid,  xmlquery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                            for $i in /C52R09/DETAILS/DETAIL
                            where $i/OrderNumber = "SBC00999"
                            return $i' PASSING xml_doc
                            RETURNING CONTENT).getClobVal() detail
    from xml_truck_info
    where tlid = '424500'
        and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                     $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
    I need, however, to return the Header1 and Header2 sections once per document if the query returns any Detail sections, regardless of  whether the query returns 1 or multiple Detail sections.
    My impression is that this will require a nested XQuery.  I haven't had success getting the syntax correct for this.  I've wasted a tremendous amount of time searching the web for examples that would replicate my scenario.  It seems there is a dearth of detailed, clear info and examples available on Oracle's XQuery implementation and structure.  I found a few examples that approximate what I'm trying to do; however, when I tweak them, the query spits up.
    Based on the following 2 examples pulled from the web or Oracle documentation:
    SELECT rownum, XMLQuery(
       <counties>
        {for $c in ora:view("CHAMBER_OF_COMMERCE")
         let $coc_county := $c/ROW/COC_COUNTY/text(),
             $coc_name := $c/ROW/COC_NAME,
             $coc_phone := $c/ROW/COC_PHONE/textb()
         where $coc_county = $cc_county/county/text()
         order by $coc_county
         return
            <county population="{xs:unsignedInt(sum(/cities/city/population))}">
               <name>{$coc_county}</name>
               <chamber phone="{$coc_phone}">{$coc_name/text()}</chamber>
               <attractions>
                  {for $a in collection("/public")
                   where $coc_county = $a/attraction/county/text()
                   return $a
               </attractions>
            </county>}
        </counties>
        PASSING BY VALUE cc_city_populations,
           XMLTYPE('<county>' || cc_county || '</county>') AS "cc_county"
        RETURNING CONTENT)
    FROM county_census;
    and
    SELECT XMLQuery(
    'for $i in $h//channel
    return
    <headlines>
    <title>OTN new articles on Oracle Solaris</title>
    <items>
         for $j in $h//item
         where ora:contains($j, "Oracle Solaris")
         return <item> {($j/title, $j/link)}</item>
    </items>
    </headlines>'
    PASSING xmlparse (document httpuritype ('http://feeds.delicious.com/v2/rss/OracleTechnologyNetwork/
    otntecharticle').getCLOB()) as "h"
    RETURNING CONTENT).getStringVal() as RESULT FROM DUAL;
    I have modified my simple, successful query above to the following:
    select tlid, XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                  for $i in /C52R09
                  return
                    <Headers>
                      "{$i/Header1}"
                      "{$i/Header2}"
                    </Headers>
                        for $x in $i/DETAILS/DETAIL
                        where $x/MarvinOrderNumber = "SBC00999"
                        return $x
                    PASSING xml_doc
                  RETURNING CONTENT).getClobVal() detail
    from xml_truck_info
    where TLID = '424500'
        and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                     $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
    When run in SQLDeveloper the result consistently reflects an issue with the curly braces '{}' around the second 'for' expression.  I have run this with different iterations, to include removing the curly braces around the $i/Header1 and $i/Header2 sections.  It makes no difference.  I get similar results as follows:
    Error at Command Line:16 Column:6
    Error report:
    SQL Error: ORA-19114: XPST0003 - error during parsing the XQuery expression:
    LPX-00801: XQuery syntax error at '{'
    9                   {
    -                   ^
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My table, XML_TRUCK_INFO, looks like this:
    Name                Type
    CUST                VARCHAR2(7)
    LOC                 VARCHAR2(5)
    TLID                NUMBER
    STID                NUMBER
    SHIP_DATE           DATE
    SHIPPED_FLAG        VARCHAR2(1)
    XML_DOC             SYS.XMLTYPE STORAGE BINARY    
    Here is a sample of the XML_DOC content that I am running  the XQuery against.
    <?xml version="1.0" standalone="yes"?>
    <C52R09 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamspaceSchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                           
            http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
      <HEADER1>
        <TruckNumber>424500</TruckNumber>
        <StopID>16</StopID>
        <ShipFrom>CITYNAME</ShipFrom>
        <ShippingDate>10-JUN-2013</ShippingDate>
        <PlannedDepartureDate>10-JUN-2013 05:00</PlannedDepartureDate>
        <ETADate>11-JUN-2013</ETADate>
        <LoadName>SW 29</LoadName>
        <StopName>16-FREEPORT, </StopName>
        <StopComment/>
        <TruckStatus>INVOICED</TruckStatus>
        <ReportType>C</ReportType>
      </HEADER1>
      <HEADER2>
        <DestAddrName>CUSTOMER-BUSINESS-NAME</DestAddrName>
        <DestAddrLine1>23 EAST 4TH AVENUE</DestAddrLine1>
        <DestAddrLine2/>
        <DestCity/>
        <DestState/>
        <DestZip>55555</DestZip>
      </HEADER2>
      <DETAILS>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>3</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>3</QtyOrdered>
          <QtyShipped>3</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD746</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD747</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:31</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD748</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:06</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>4</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>3</QtyOrdered>
          <QtyShipped>3</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD749</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD750</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD751</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 06:46</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>5</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>2</QtyOrdered>
          <QtyShipped>2</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD752</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD753</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:42</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC01011</OrderNumber>
          <LineNumber>1</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>28-MAY-2013</OrderDate>
          <JobName>Job2</JobName>
          <QtyOrdered>4</QtyOrdered>
          <QtyShipped>4</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163766</CustomerPONumber>
          <CubicFeet>4.6</CubicFeet>
          <ListPrice>823</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YV016</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:46</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV017</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:25</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV018</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 06:51</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV019</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:22</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
      </DETAILS>
    </C52R09>
    I would appreciate any help and/or insights from others more experienced in this than I.
    Thanks in advance,
    Paul

    Sorry, as I look back at the declaration in the root element included in the example, I must have used an older version of the data.  The root element with declarations should have been this:
    <C52R09 xmlns="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:SchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                 
    http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
    I've included the query with the declaration (using data values in the table, but different from those in the example) and the result below:
    PK_XML-MOS2>>select tlid
      2       , XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
      3           let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
      4            return if ($dtls) then
      5            <Doc>
      6            {
      7              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
      8            , <Details>{ $dtls }</Details>
      9            }
    10            </Doc>
    11            else ()'
    12           PASSING xml_doc
    13                 , '17Z00266' as "order_no"
    14           RETURNING CONTENT
    15         ).getClobVal() detail
    16  from xml_truck_info
    17  where tlid = 398043
    18    and xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
    19          /C52R09/HEADER1[TruckNumber=$truck_no]'
    20          PASSING xml_doc
    21                , '398043' as "truck_no"
    22        );
    More .....
          TLID  DETAIL
        398043   
    I've included the query without the declaration (same data values as above) and the result below:
    PK_XML-MOS2>>select tlid
       2       , XMLQuery('let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
       3            return if ($dtls) then
       4            <Doc>
       5            {
       6              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
       7            , <Details>{ $dtls }</Details>
       8            }
       9            </Doc>
      10            else ()'
      11           PASSING xml_doc
      12                 , '17Z00266' as "order_no"
      13           RETURNING CONTENT
      14         ).getClobVal() detail
      15  from xml_truck_info
      16  where tlid = 398043
      17    and xmlexists('/C52R09/HEADER1[TruckNumber=$truck_no]'
      18          PASSING xml_doc
      19                , '398043' as "truck_no"
      20        );
    no rows selected
    The first example, with the declaration, returns the TLID value, although no detail section.  Whereas, the second, without the declaration, finds nothing to return.
    Thanks again.

  • Please Help With : XVM-01003: [XPST0003]/LPX-00801: XQuery  Syntax error at

    Hi gurus,
    I need your help on using the XMLQuery function. We are FINALLY in the processing of migrating from 10g to 11gR2! Oracle says that we should replace extracValue with XMLQuery, so I am trying to do that but I am getting the errors below,
    XVM-01003: [XPST0003] Syntax error at (if I use a PL/SQL variable).
    LPX-00801: XQuery syntax error at (if I use the literals).
    I have read through many of the posts related to XMLQuery and its default element namespace, but I have no luck on that. I have an example that has this kind prefix (a part of the xml is posted here):
    <soap:Body>
    <soap:Fault xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case&apos;s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    I need to get the Text inside the Reason node. No matter what I do with the default namespace (and if I don't declare one I also get an error), I get the following error:
    XMLQuery ('declare default element namespace s="http://www.w3.org/2003/05/soap-envelope" ; /s:Envelope/s:Body/s:Fault/s:Reason/s:Text'):
    LPX-00801: XQuery syntax error at 's'
    1 declare default element namespace s="http://www.w3.org/2003/05/soap-envelop
    - ^
    ORA-06512: at line 103
    XMLQuery('declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ; /soap:Envelope/soap:Body/soap:Fault/soap:Reason/soap:Text'):
    LPX-00801: XQuery syntax error at 'xmlns:soap'
    1 declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soa
    - ^
    ORA-06512: at line 103
    Using the XMLTable function does not have any problems.
    What do I do wrong here? I could just use the XMLTable to replace all the extractValue(s) that I have, but I really want to learn how to make the XMLQuery correct. Please help!
    I just tried this and I got the same error:
    XMLQuery('declare default namespace s="http://www.w3.org/2003/05/soap-envelope" ; (::) $p/s:Envelope/s:Body/s:Fault/s:Reason/s:Text' passing p_XMLDoc as "p"
    Thank you.
    Ben
    Edited by: myora9i on Apr 22, 2011 1:42 PM

    Hi Ben,
    Can someone please explain to me when should I use the default key word and when I should not use it?If you declare a default namespace then all unqualified (= unprefixed) elements will be considered belonging to that namespace.
    If you declare a namespace with a prefix, you'll have to qualify each element in the XQuery.
    See below example based on your XML sample :
    DECLARE
      soap_doc xmltype := xmltype(
      '<soap:Body xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Fault>
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case''s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    </soap:Fault>
    </soap:Body>'
      v_text  varchar2(100);
    BEGIN
      -- with a default namespace,
      -- no need to prefix each element :
      SELECT XMLCast(
        XMLQuery(
          'declare default element namespace "http://www.w3.org/2003/05/soap-envelope"; (::)
           /Body/Fault/Reason/Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
      -- with a declared namespace prefix,
      -- each element must be qualified with the prefix :
      SELECT XMLCast(
        XMLQuery(
          'declare namespace s = "http://www.w3.org/2003/05/soap-envelope"; (::)
           /s:Body/s:Fault/s:Reason/s:Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
    END;
    /

  • Maths formula parser

    Hi,
    Does oracle provide any function that parses and evaluets a math formula/expression by resolving the operator precedence in it.
    e.g. I have a math formula in the form of a string variable '(2+3)*(4+5)'
    Does oracle have a function that will resolve this and return answer 45.
    OR
    Does anyone have a stored proc/func for this that I can use.
    Any help is appreciated.
    Thanks in advance.

    I created this a long time ago in response to a post on this forum. Someone wanted an IIF() construct.
    CREATE FUNCTION iif (p_expr IN VARCHAR2,
                         p_true_result IN VARCHAR2,
                         p_false_result IN VARCHAR2) RETURN VARCHAR2 IS
       l_sqlstr VARCHAR2(4000);
       l_result PLS_INTEGER;
    BEGIN
       l_sqlstr := 'SELECT 1 FROM dual WHERE '||REPLACE(p_expr,'"','''');
       BEGIN
          EXECUTE IMMEDIATE l_sqlstr INTO l_result;
          RETURN p_true_result;
       EXCEPTION WHEN NO_DATA_FOUND THEN
          RETURN p_false_result;
       END;
    END;{code}
    or, for a strictky PL/SQL version (i.e. you can't call it in sql)
    {code}CREATE FUNCTION iif (p_expr IN VARCHAR2) RETURN BOOLEAN IS
       l_sqlstr VARCHAR2(4000);
       l_result PLS_INTEGER;
    BEGIN
       l_sqlstr := 'SELECT 1 FROM dual WHERE '||REPLACE(p_expr,'"','''');
       BEGIN
          EXECUTE IMMEDIATE l_sqlstr INTO l_result;
          RETURN TRUE;
       EXCEPTION WHEN NO_DATA_FOUND THEN
          RETURN FALSE;
       END;
    END;The first version would be called like:
    SELECT IIF('"A" in ("A","B","C") and 3 > 2 and 4 between 2 and 5','TRUE','FALSE') FROM dual;The second something like:
    IF IIF('"A" in ("A","B","C") and 3 > 2 and 4 between 2 and 5') THEN
    END IF;Just keep in mind Brian's comments about SQL injection from earlier in this thread
    John

  • Syntax for EVALUATE function - placing condition in it

    Hello All,
    I have a formula in discoverer like this
    SUM(col1)
    OVER(PARTITION BY col2, col3, col4
    ORDER BY col5 ASC
    RANGE BETWEEN col6-3 AND col6
    I need to implement the same in BI,
    I have used this to implement the SUM part
    EVALUATE( 'SUM(%1) OVER ( PARTITION BY %2,%3,%4) ORDER BY %5)' as double,
    col1,
    col2,
    col3,
    col4)
    But, couldn't get the syntax for 'RANGE BETWEEN' clause..
    i have tried like this
    EVALUATE( 'SUM(%1) OVER ( PARTITION BY %2,%3,%4) ORDER BY %5 RANGE BETWEEN %7 AND %6 )' as double,
    col1,
    col2,
    col3,
    col4,
    col5,
    col6,
    col7)
    Its throwing an error 'ORA-00905: missing keyword at OCI call OCIStmtExecute.'
    can anyone please suggest me some ideas to resolve this.
    Thanks in advance,
    Raghu

    Hi Goran,
    Thanks for the reply, it was of great help..
    Can you once check this please
    EVALUATE( 'SUM(%1) OVER ( PARTITION BY %2,%3,%4,%5
    ORDER BY %6 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )' AS DOUBLE,
    "Global Distributor Sales (by Period)"."Net Sales",
    Specialist."Specialist Group Name", Specialist."Specialist Manager Name",
    Specialist."Specialist Name", "End Sold-To Customer"."Sold-To Customer
    Account Name", "Process Fiscal Period Calendar"."Fiscal Period")
    This is giving the running sum of values with in the partition window..
    but, can you suggest, how to modify the query, so as to get the values of 'Sales' between
    2 fiscal periods back and the current fiscal period..
    in the discoverer it is used like this,
    SUM(Net Sales SUM)
    OVER(PARTITION BY Specialist Group Name,Specialist Manager Name,Specialist Name,"Sold-To Customer Account Name",GPH Segment2
    ORDER BY "Fiscal Period (7)" ASC
    RANGE BETWEEN NUMTOYMINTERVAL("Fiscal Period Of Year"-1,'MONTH') PRECEDING AND CURRENT ROW )
    which gives the values between 2 periods back and current period
    Thank you,
    Raghu

  • Convert data values in columns to another value based on a math formula

    ISSUE:
    I have a database of emergency incidents with descriptive data and longitude and
    latitude. I would like to make a google map out of the information but unfortunately
    the X Y coordinates are projected in Florida State Plane West in feet. Google maps
    requires WGS84 longitude and latitude in decimal degrees.
    PROBLEM:
    I have written some code in Transact SQL that will convert the values. But I am at a loss as to how to do the following:
    1.) plug in the X Y values from my database using an sql SELECT statement.
    2.) apply the formula to convert from State Plane to WGS84 to these X Y values
    3.) output the results.
    In other words, I have the data and I have the formula, but I am not figuring out how to plug the data into the formula and output the results. I am missing how to tie it all together.
    CODE:
    DECLARE @Easting DECIMAL(18,10);
    --SET @Easting = CAST(I_MapX AS DECIMAL(18,10));
    DECLARE @Northing DECIMAL(18,10);
    --SET @Northing = CAST(I_MapY AS DECIMAL(18,10));
    DECLARE @m2sft DECIMAL(10,10);
    SET @m2sft = 1200.0/3937.0;
    DECLARE @N0 DECIMAL(3,2);
    SET @N0 = 0.0;
    DECLARE @E0 DECIMAL(18,11);
    SET @E0 = 656166.6666666665;
    DECLARE @S0 DECIMAL(12,5);
    SET @S0 = 2692050.5001/@m2sft;
    DECLARE @K0 DECIMAL(18,18);
    SET @K0 = 0.9999411764705882;
    DECLARE @a DECIMAL(10,2);
    SET @a = 6378137.0/@m2sft;
    DECLARE @e DECIMAL(18,17);
    SET @e = 0.0818191911198883;
    DECLARE @ePrime DECIMAL(18,17);
    SET @ePrime = 0.08208852110265381;
    DECLARE @r DECIMAL(18,10);
    SET @r = 6367449.14577/@m2sft;
    DECLARE @V0 DECIMAL(15,12);
    SET @V0 = 0.005022893948;
    DECLARE @V2 DECIMAL(15,12);
    SET @V2 = 0.000029370625;
    DECLARE @V4 DECIMAL(15,12);
    SET @V4 = 0.000000235059;
    DECLARE @V6 DECIMAL(15,12);
    SET @V6 = 0.000000002181;
    DECLARE @L0 DECIMAL(4,2);
    SET @L0 = 82.0;
    DECLARE @w DECIMAL(18,10);
    SET @w = (@Northing - @N0 + @S0)/(@k0*@r);
    DECLARE @of DECIMAL(18,10);
    SET @of = @w + (sin(@w)*cos(@w))*(@V0 + @V2*power(cos(@w),2) + @V4*power(cos(@w),4) + @V6*power(cos(@w),6));
    DECLARE @Rf DECIMAL(18,10);
    SET @Rf = @k0*@a/sqrt((1 - power(@e,2)*power(sin(@of),2)));
    DECLARE @EPrime2 DECIMAL(18,10);
    SET @EPrime2 = @Easting - @E0;
    DECLARE @Q DECIMAL(18,10);
    SET @Q = @EPrime2/@Rf;
    DECLARE @tf DECIMAL(18,10);
    SET @tf = tan(@of);
    DECLARE @nf DECIMAL(18,10);
    SET @nf = @ePrime*cos(@of);
    DECLARE @B2 DECIMAL(18,10);
    SET @B2 = -0.5 * @tf * (1 + POWER(@nf,2));
    DECLARE @B4 DECIMAL(18,10);
    SET @B4 = -1/12*(5 + 3 * POWER(@tf,2) +POWER(@nf,2) * (1-9 * POWER(@tf,2)) - 4 * POWER(@nf,4));
    DECLARE @B6 DECIMAL(18,10);
    SET @B6 = 1/360*(61 + 90*POWER(@tf,2) + 45*POWER(@tf,4) + POWER(@nf,2)*(46 - 252*POWER(@tf,2) - 90*POWER(@tf,4)));
    DECLARE @Latitude DECIMAL(18,10);
    SET @Latitude = (@of + @B2*POWER(@Q,2)*(1 + POWER(@Q,2)*(@B4 + @B6*POWER(@Q,2))))*180/(PI());
    DECLARE @B3 DECIMAL(18,10);
    SET @B3 = -1/6*(1 + 2*POWER(@tf,2) + POWER(@nf,2));
    DECLARE @B5 DECIMAL(18,10);
    SET @B5 = 1/120*(5 + 28*POWER(@tf,2) + 24*POWER(@tf,4) + POWER(@nf,2)*(6 + 8*POWER(@tf,2)));
    DECLARE @B7 DECIMAL(18,10);
    SET @B7 = -1/5040*(61 + 662*POWER(@tf,2) + 1320*POWER(@tf,4) + 720*POWER(@tf,6));
    DECLARE @L DECIMAL(18,10);
    SET @L = @Q*(1 + POWER(@Q,2)*(@B3 + POWER(@Q,2)*(@B5 + @B7*POWER(@Q,2))));
    DECLARE @Longitude DECIMAL(18,10);
    SET @Longitude = (@L0 - (@L/cos(@of))*180/(PI()))*-1;
    SELECT
    I_EventNumber
    FROM Incident
    WHERE I_tTimeDispatch > 'May 7, 2012'
    SAMPLE DATA:
    Here is some raw data in order to get you started. Please notice the MapX and MapY
    coordinates are VARCHAR because they are Florida State Plane projections. The goal is
    to take these and turn them into WGS84 longitude and latitude expressed as decimal
    degrees to be used in Google maps. NOTE: I can convert from VARCHAR to DECIMAL. I just can't figure out where to plug my database columns into the sql query to output a result.
    CREATE TABLE Incidents
    I_EventNumber VARCHAR(20)
    I_MapY VARCHAR(15)
    I_MapX VARCHAR(15)
    INSERT INTO Incident
    VALUES
    (FCW69, 0815312, 0672298)
    , (FCW70, 0833311, 0697870)
    , (FCW71, 0807747, 0699684)
    , (FCW72, 0801252, 0689469)
    , (FCW73, 0853491, 0692350)

    Here's a way to get the results, all as part of a single extensive query (this would probably be more suited for defining a VIEW, where you could join on the input table with the VIEW to incorporate the computed values.
    If you instead had a business situation where you might need to execute this logic from many different places, rewriting as a user defined function might be better.  Anyway, for the answer plus a demonstration of the power of CROSS APPLY to generate
    interim working values...
    Create_Sample_Data:
    Declare @Incident TABLE
    I_EventNumber VARCHAR(20), I_MapY VARCHAR(15), I_MapX VARCHAR(15)
    INSERT INTO @Incident
    VALUES
    ('FCW69', '0815312', '0672298')
    , ('FCW70', '0833311', '0697870')
    , ('FCW71', '0807747', '0699684')
    , ('FCW72', '0801252', '0689469')
    , ('FCW73', '0853491', '0692350') /* This insert is SQL 2008 syntax only.. do multiple inserts or a UNION for 2005 */
    AsQuery:
    Select *
    from @INCIDENT
    Cross Apply
    Select
    N0 = 0.0,
    E0 = 656166.6666666665,
    K0 = 0.9999411764705882,
    e = 0.0818191911198883,
    ePrime = 0.08208852110265381,
    V0 = 0.005022893948,
    V2 = 0.000029370625,
    V4 = 0.000000235059,
    V6 = 0.000000002181,
    L0 = 82.0,
    Easting = CAST(I_MapX AS DECIMAL(18,10)),
    Northing = CAST(I_MapY AS DECIMAL(18,10))
    ) as CAStatic
    Cross Apply
    Select m2sft = 1200.0/3937.0,
    EPrime2 = Easting - E0
    ) as CAComputed1
    Cross Apply
    Select S0 = 2692050.5001/m2sft,
    r = 6367449.14577/m2sft,
    a = 6378137.0/m2sft
    ) as CAComputed2
    Cross Apply
    Select
    w = (Northing - N0 + S0)/(k0*r)
    ) as CAComputed4
    Cross Apply
    Select
    [of] = w + (sin(w)*cos(w))*(V0 + V2*power(cos(w),2) + V4*power(cos(w),4) + V6*power(cos(w),6))
    ) as CAComputed5
    Cross Apply
    Select
    Rf = k0*a/sqrt((1 - power(e,2)*power(sin([of]),2))),
    tf = tan([of]),
    nf = ePrime*cos([of])
    ) as CAComputed6
    Cross Apply
    Select
    Q = EPrime2/Rf,
    B2 = -0.5 * tf * (1 + POWER(nf,2)),
    B4 = -1/12*(5 + 3 * POWER(tf,2) +POWER(nf,2) * (1-9 * POWER(tf,2)) - 4 * POWER(nf,4)),
    B6 = 1/360*(61 + 90*POWER(tf,2) + 45*POWER(tf,4) + POWER(nf,2)*(46 - 252*POWER(tf,2) - 90*POWER(tf,4)))
    ) as CAComputed7
    Cross Apply
    Select
    Latitude = ([of] + B2*POWER(Q,2)*(1 + POWER(Q,2)*(B4 + B6*POWER(Q,2))))*180/(PI()),
    B3 = -1/6*(1 + 2*POWER(tf,2) + POWER(nf,2)),
    B5 = 1/120*(5 + 28*POWER(tf,2) + 24*POWER(tf,4) + POWER(nf,2)*(6 + 8*POWER(tf,2))),
    B7 = -1/5040*(61 + 662*POWER(tf,2) + 1320*POWER(tf,4) + 720*POWER(tf,6))
    ) as CAComputed8
    Cross Apply
    Select
    L = Q*(1 + POWER(Q,2)*(B3 + POWER(Q,2)*(B5 + B7*POWER(Q,2))))
    ) as CAComputed9
    Cross Apply
    Select
    Longitude = (L0 - (L/cos([of]))*180/(PI()))*-1
    ) as CAComputedLatLong
    Notice that each subsequent CROSS APPLY depends on a "working value" column being defined in some previous cross apply, or the working query.  There are a few other options, such as leaving off the very last Cross Apply, and computing Longitude as part
    of the main query at the beginning, but it works either way.
    EDIT: P.S. - By the way, this query is based on the formula in the original poster's query.  My formula matches that formula, and I bet it's right (as far as the lat/long conversion), but it could be the formula for Soylent Green, and I wouldn't know any
    better... :-)

  • Creating Complex Math Formulas in IDCS4 (Mac)

    I have to create a 180 page Engineering handbook for a company, with LOTS of complex mathematic formulas. It also has a lot of engineering drawings, sketches, tables, etc. I'll use IDCS4 on a Mac platform, OSX 10.6.7. I also have Acrobat Pro, PS and Illustrator from the CS4 Suite. Their final deliverable will be a PDF, which the customer will make available for download, so I definitely want to convert text, images drawings, etc, to the smallest possible size.
    Unfortunately, my customer has no electronic documents to work with. My current plan is to scan the original printed book, clean up the scans in Photoshop, then use OCR in Acrobat to convert characters to text. I will probably export to RTF, DOC, TXT or some other format so I can import into IDCS4 and create an electronic version (suggestions welcome).
    Unfortunately, Acrobat OCR butchers the formulas and turns them into goobledegook. What plugins or programs are people using to create fairly complex mathematical formulas inside IDCS4? Can I do it inside IDCS4, or do I need to work in Word, Pages, or a dedicated mathematical formula program? I will need Greek symbols, integrals, differential equation capability, etc.
    My main concern at this time is the formulas, but I am open to any suggestions on converting scanned images to vectors, handling tables, and the best way to get my text content into IDCS4 with the least amount of time and effort.
    Thanks for your help.
    Lou Dina

    Try these resources:
    http://www.unics.uni-hannover.de/nhtcapri/mathematics.html
    http://www.cs.tut.fi/~jkorpela/math/
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course
    (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs
    (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

  • Creating Math Formulas in Dreamweaver

    I've been given an assignment to create a web page for an
    online precalculus mathematics course using Dreamweaver. I know
    just enough about web site design to get by creating very basic
    sites, so this is quite a challenge for me! The course materials
    are currently in MS Word format and a lot of the formulas appear to
    have been created with the formula editor. I tried copying the
    formulas from the Word doc and pasting them into Dreamweaver, but
    they look distorted (and I have a feeling this isn't a great idea).
    Does anyone out there have experience creating mathematical
    formulas in Dreamweaver--or importing them from another program?
    There are literally hundreds of formulas and diagrams throughout
    the course, so I'm looking for an efficient way of doing
    this.

    Try these resources:
    http://www.unics.uni-hannover.de/nhtcapri/mathematics.html
    http://www.cs.tut.fi/~jkorpela/math/
    Alec Fehl, MCSE, A+, ACE, ACI
    Adobe Community Expert
    AUTHOR:
    Microsoft Office 2007 PowerPoint: Comprehensive Course
    (Labyrinth
    Publications)
    Welcome to Web Design and HTML (Labyrinth Publications)
    CO-AUTHOR:
    Microsoft Office 2007: Essentials (Labyrinth Publications)
    Computer Concepts and Vista (Labyrinth Publications)
    Mike Meyers' A+ Guide to Managing and Troubleshooting PCs
    (McGraw-Hill)
    Internet Systems and Applications (EMC Paradigm)

  • Basic math formula problems, percentage formatting

    Hi!
    I have a table full of data, and I'd like to calculate the percentage change from one row to the next.
    I thought I could use formula like
    =(J3-J2)/J2
    And this works. I get result like 0.31.
    I'd like to format it as percentage. Clicking on the "Format as percentage button" changes my formula and makes it invalid.
    The cell value becomes:
    =(Total 1.6.2009-Total 1.5.2009)/Total 1.5.2009
    "Total" is the name of the column (which is actually a sum of items on the row) and "1.5.2009" is the name of the row.
    Why does Numbers destroy the formula to use the names of the row and column instead of cell reference?
    By the way, I can't just add " * 100" to my formula to have it be 31 instead of 0.31, that will also cause a formula syntax error.
    So I'm trying to calculate percentage change from one sum cell to the sum cell on the next row, but this doesn't seem possible.
    Any ideas?

    Petteri,
    I suppose there is a possibility that when you first attempted to apply Percent format to your result you made some wrong key-press.  It should work correctly that way, and does on my system.
    One tip; If I were you, I would turn off that "Use Header Cell Names as References" Preference.  It's more trouble than it is worth.  Just a gimmick in my opinion.
    Jerry

  • Evaluate math expression

    Hi Guys,
    I need to write java command line program to evaluate a mathematical
    expression input by user without parantheses using Stack approach.
    Can anyone give me the clue how to start of with.
    Is it possible to evaluate the expression in infix notation directly using stack, without converting to prefix notation.
    Thanks in advance

    Is there something nicer?You can also use java 6 and javascripts. I saw a
    thread where someone posted an example.
    KajI posted something a couple of weeks back (reply #2):
    http://forum.java.sun.com/thread.jspa?threadID=5137192
    Of course, you don't need to bind any variables and can do it like this:import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    import javax.script.ScriptException;
    public class ScriptDemo {
        public static void main(String[] args) {
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName("js");
            try {
                String expression = "3+4";
                Object result = engine.eval(expression);
                System.out.println(expression+" = "+result);
            } catch(ScriptException se) {
                se.printStackTrace();
        output: 3+4 = 7.0
    */

  • Need help with Xquery Syntax.

    Hi there,
    I am using a Berkeley XML DB and I have a xquery which I need to execute in a particular format. I have the following xquery:
    for $a in collection("test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return $a/book_ID/text()
    This xquery runs fine and I have the end result to be 6.
    I need the same result to be specified in a XML TAG like <order_ID> 6 </order_ID> for which I have the following xquery:
    for $a in collection"test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return <order_ID>$a/book_ID/text()</order_ID>
    This xquery runs but return me back with the string "<order_ID>$a/book_ID/text()</order_ID>".
    Can you please help me to correct the above output to result in "<order_ID> 6 </order_ID>"
    Thanks.

    Try
    for $a in collection("test.dbxml")/Bookstore/Book
    where $a/book_ID/text() eq "6"
    return <order_ID>{$a/book_ID/text()}</order_ID>Lauren Foutz
    Edited by: LaurenFoutz on Apr 17, 2009 9:41 AM

Maybe you are looking for

  • A problem caused by the file name

    hi,i have a problem today,here is the source file: //saved as String.java class Strings{ public static void main(String [] args){ String x="java"; System.out.println("x string ="+x); and when i try to compile it,the compiler complains as follows: jav

  • Request for unlocked BIOS GT60

    hey svet, i may need a modded bios for my gt60-i789w7h. i cant use any virtual machine which is x64 cause theres no option in my bios to enable the vt-feature. (and add maybe some oc features if possible. im a gamer ) can u help me with that?! could

  • Find / List PDFs without OCR

    Is there a utility or a batch process that will find and list all PDFs in a folder or set of folders that have not been OCR'd?  We're running Acrobat 9 in Windows XP.

  • Flex Grid Issues

    Hi, I am using Flex Grid in my project where i am successfully able to populate xml data dynamically. what i am doing here, I am dynamically generating the xml using httpservice. This HttpService is returning an XmlList that i am using to bind the gr

  • TS1424 Why do I keep getting this message when I am trying to purchase game or song?  MZCommerce.Credit Balance Mismatch.Mobile_message

    Please explain why I cannot purchase songs or games and I have money in my account.