Calculations in SQL

I am trying to get a query to perform some math on some user fields so that this query could be made a formatted search for another user field ... all in the BOM.
DECLARE @X1 AS REAL
SET @X1 = $\[$3.U_PartLength\] * $\[$3.U_PartWidth\]
SELECT $\[$3.U_PartLength\], @X1
This code produces an error near "$3.U_PartLength"
The user fields are defined as "Units and Amounts" and "Quantity"
The reason I don't include the calculation in the SELECT statement is that this is the beginning of a complex series of calculations after which I will have to choose the lesser of two values.
Thank you,
Sal

I worked on this all weekend and the only way I can get the system to recognize the UDF is to encase it in square brackets with its own SELECT as follows:
DECLARE @LENGTH AS FLOAT
DECLARE @WIDTH AS FLOAT
DECLARE @YMODE AS NCHAR(1)
SET @WIDTH = CONVERT(FLOAT, (SELECT $\[$3.U_PartWidth\]))
SET @LENGTH = CONVERT(FLOAT, (SELECT $\[$3.U_PartLength\]))
SET @YMODE = (SELECT $\[$3.U_YieldMode\])
I can then do math using the "@" variables.
It seems that the system will only process SAP's special "$" variables through the SELECT command. All the other commands I tried on these "$" variables resulted in error.
Does this make sense?
Sal

Similar Messages

  • Calculations Using SQL Query

    Hi All,
    I am using Oracle Database Version 11.2.
    I have a formula (A-B)/[(A-B)/10]. The tables that are holding the rows for this calculations are given below:
    ROWS_TAB
    ====== ===================
    Row          Amount
    ====== ===================
    A            5000
    B            -5000
    FORMULA_TAB
    ======== =========== ======== =============
    | ROW#  | Operator            | ROW        |   CONSTANT   |
    ======== =========== ======== =============
    | 10        |     E                   |      A       |                         |
    | 20        |     -                    |     B        |                         |
    | 30        |     E                   |      A       |                         |
    | 40        |     -                    |     B        |                         |
    | 50        |     /                    |               |      10                |
    | 60        |    /                     |               |                          |
    ======== =========== ======== =============
    The operator E starts a new calculation. The above formula has two sub-expressions thereby the table has two rows with E. Minus denoted by -, Plus denoted by +, Multiply denoted by *, and Division denoted by /.
    I want to write single SQL query to perform this calculation. Is it achievable in SQL?
    The scripts used to generate the tables are as below:
    create table ROWS_TAB
    (row_name VARCHAR2(1),
    amount NUMBER);
    create table FORMULA_TAB
    (row# NUMBER,
    operator VARCHAR2(1),
    row_name VARCHAR2(1),
    constant NUMBER);
    INSERT INTO ROWS_TAB VALUES('A', 5000);
    INSERT INTO ROWS_TAB VALUES('B', -5000);
    INSERT INTO FORMULA_TAB VALUES(10, 'E','A',null);
    INSERT INTO FORMULA_TAB VALUES(20, '-','B',null);
    INSERT INTO FORMULA_TAB VALUES(30, 'E','A',null);
    INSERT INTO FORMULA_TAB VALUES(40, '-','B',null);
    INSERT INTO FORMULA_TAB VALUES(50, '/','',10);
    INSERT INTO FORMULA_TAB VALUES(60, '/','','');
    Can anyone help in writing SQL query....
    Thanks in advance
    Best Regards
    Bilal

    As Frank said, it would be much easier to simply input the formula. Then, assuming you have OLAP option:
    variable formula varchar2(30)
    exec :formula := '(A-B)/((A-B)/10)';
    with t as (
               select  *
                 from  rows_tab
                 model
                   dimension by(row_number() over(order by row_name) r)
                   measures(
                            row_name,
                            amount,
                            count(*) over() cnt,
                            cast(:formula as varchar2(4000)) formula
                   rules(
                         formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
    select  :formula || ' = ' || dbms_aw.eval_number(formula) result
      from  t
      where r = cnt
    RESULT
    (A-B)/((A-B)/10) = 10
    SQL>
    And if you do not have OLAP, you could use xquery:
    with t as (
               select  *
                 from  rows_tab
                 model
                   dimension by(row_number() over(order by row_name) r)
                   measures(
                            row_name,
                            amount,
                            count(*) over() cnt,
                            cast(:formula as varchar2(4000)) formula
                   rules(
                         formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
    select  :formula || ' = ' || xmlquery(replace(formula,'/',' div ') returning content) result
      from  t
      where r = cnt
    RESULT
    (A-B)/((A-B)/10) = 10
    SQL>
    SY.

  • Creating a ad-hoc calculation using sql query

    Hi All,
    I want to know if its possible some way to create a ad-hoc sql query inside a workbook so as to create a calculation using that sql.
    I have a folder which gives me balance for any period. My requirement is to display current period balance along with prior years closing balance in same record for each code combination. I dont want to modify folder definition.
    Thanks for your inputs.
    Vishal.

    You could try creating a custom function for this purpose. You would need to register the function in the End User Layer and then you can call the function from your report.

  • AVG Calculation in sql Report

    Fyi,
    I have Pl/sql returning sql query in oracle apex report. i use sum and avg in report using union.
    In Report ordering enable in all fields.
    when i use ordering in this report the the sum and avg row comes first.
    Problem is i dont want to ordering on that Sum and Avg row. it must at last of the report.
    kindly help me. it's urgent.
    Thanks

    Harry wrote:
    Fyi,
    I have Pl/sql returning sql query in oracle apex report. i use sum and avg in report using union.
    In Report ordering enable in all fields.
    when i use ordering in this report the the sum and avg row comes first.
    Problem is i dont want to ordering on that Sum and Avg row. it must at last of the report.See +{thread:id=2336820}+
    kindly help me. it's urgent.It's no more or less urgent than any other question on these forums.

  • Different results of same calculation between SQL and PL/SQL

    This SQL statement:
    select 1074 * (4 / 48) from dual;Gives the result 89.5.
    However this PL/SQL block
    declare
        tmp     NUMBER;
    begin
        SELECT 1074 * (4 / 48) into tmp from dual;
        dbms_output.put_line('Result '||tmp);
    end;Gives a different result:
    Result 89.49999999999999999999999999999999999996
    If I change and give my variable tmp a precision and scale, say (38,36) then the result is 89.5.
    Edit. I have done this on both 10g (10.2.0.4.0) and 11g (11.1.0.7.0) with the same result in both.
    Edited by: kendenny on Jul 9, 2010 10:19 AM for additional information

    What's your current NUMWIDTH value in SQL*Plus (I'm assuming you are using that as your tool)?
    SQL> set numwidth 50
    SQL> select 1074 * (4 / 48) from dual;
                                           1074*(4/48)
             89.49999999999999999999999999999999999996

  • Help Calculating in SQL

    Hi,
    I am using oracle 10g.
    I want to build a sql that helps me keep track of all the stocks I've bought and sold. Provided that I sell same qty that I buy. Here is the scenarion I am looking at as my initial table and following is my result to achieve.
    Here are all my actions Which I store in a table
    ACTION    SMBL    QTY    PRICE    AMOUNT    COMM    STATUS
    Sell    WFC    300    17.85         5355     7   Executed
    Buy     WFC    100    13.9299   -1392.99     7   Executed
    Buy     WFC    200    15.60        -3120     7   ExecutedHere is What I would like to achieve,
    SMBL    QTY     AVG_BUY_PRICE       TOTAL_BUY_PRICE     AVG_SELL_PRICE      TOTAL_SELL_PRICE    P&L     P&L %
    WFC     300       15.08996667           4526.99             17.82666667         5348            821.01 18.14%If someone can help me with something that would allow me buy and sell different qty and still keep track , that would be great....
    Thanks.........

    Hello,
    Output from the above query
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
    SQL> set lines 400;
    SQL> WITH t
      2         AS (  SELECT   smbl,
      3                        action,
      4                        SUM (qty) qty,
      5                        CASE WHEN action = 'Buy' THEN AVG (price) END
      6                           AS avg_buy_price,
      7                        CASE
      8                           WHEN action = 'Buy' THEN SUM (ABS (amount) + comm)
      9                        END
    10                           AS total_buy_price,
    11                        CASE WHEN action = 'Sell' THEN AVG (price) END
    12                           AS avg_sell_price,
    13                        CASE WHEN action = 'Sell' THEN SUM (amount - comm) END
    14                           AS total_sell_price
    15                 FROM   accounts
    16             GROUP BY   smbl, action)
    17    SELECT   smbl,
    18             t.qty,
    19             SUM (avg_buy_price) avg_buy_price,
    20             SUM (total_buy_price) total_buy_price,
    21             SUM (avg_sell_price) avg_sell_price,
    22             SUM (total_sell_price) total_sell_price,
    23             (SUM (total_sell_price) - SUM (total_buy_price)) AS "P_AND_L",
    24            round( ((SUM (total_sell_price) - SUM (total_buy_price)) /  SUM (total_buy_price) ) * 100, 2) as "P_AND_L%"
    25      FROM   t
    26  GROUP BY   smbl, qty;
    SMBL        QTY AVG_BUY_PRICE TOTAL_BUY_PRICE AVG_SELL_PRICE TOTAL_SELL_PRICE    P_AND_L   P_AND_L%
    WFC         300      14.76495         4526.99          17.85             5348     821.01      18.14
    SQL>

  • Average calculation using sql

    Hi all,
    My table structure is
    Id Name Remarks starting_date end_date
    workingdays = end_date-starting_date
    I passed a query
    select Name,max(case when remarks=remarks then remarks end),
    max(case when id=id then end_date-starting_date end),
    avg(end_date-starting_date) average from t_action_items
    group by rollup(name,end_date-starting_date);
    which passed output like this
    Name Remarks Workingdays Average
    x aaa 20 20
    x bbb     10 20
    aaa 10 15
    y ccc 19
    y ddd 8
    ccc 8 13.5     
    ccc 8 14.2
    But I need output like this,how can i do this someone please guide me
    Name Remarks Workingdays
    x aaa 20
    x bbb     10
    15 ---> Average for x
    y ccc 19
    y ddd 8
    13.5     ---> Average for y
    Pardon me i cant able to align it in proper format,i think with data u can seggregate
    Many Thanks in advance..
    Edited by: Paappu on 20 Mar, 2009 9:50 AM

    Hi
    I guess this is what you are looking for.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH T AS(
      2  (SELECT 'Mark' name, 'Design' remark    ,TO_DATE('15-FEB-09','DD-MON-YY') start_dt,TO_DATE('15-FEB-09','DD-MON-YY')end_dt FROM DUAL UNION ALL
      3  SELECT 'Hendry' name, 'Coding'  ,TO_DATE('08-JUN-08','DD-MON-YY'),TO_DATE('15-JUN-08','DD-MON-YY') FROM DUAL UNION ALL
      4  SELECT 'steve', 'Testing'  ,TO_DATE('29-OCT-08','DD-MON-YY'),TO_DATE('04-NOV-08','DD-MON-YY') FROM DUAL UNION ALL
      5  SELECT 'JAMES', 'POC',   TO_DATE('01-MAR-09','DD-MON-YY'),TO_DATE('01-MAR-09','DD-MON-YY') FROM DUAL UNION ALL
      6  SELECT 'JAMES', 'DOCUMENTATION', TO_DATE('01-MAR-09','DD-MON-YY'),TO_DATE('09-MAR-09','DD-MON-YY') FROM DUAL))
      7  SELECT Name,Remark, SUM(work_hrs), AVG(work_hrs) FROM (
      8  SELECT name,remark ,start_dt,end_dt,SUM(end_dt-start_dt) OVER (PARTITION BY name,remark ORDER by Name) work_hrs
      9  FROM T)
    10* GROUP BY ROLLUP(name,remark)
    SQL> /
    NAME   REMARK        SUM(WORK_HRS) AVG(WORK_HRS)
    Hendry Coding                    7             7
    Hendry                           7             7
    JAMES  DOCUMENTATION             8             8
    JAMES  POC                       0             0
    JAMES                            8             4
    Mark   Design                    0             0
    Mark                             0             0
    steve  Testing                   6             6
    steve                            6             6
                                    21           4.2
    10 rows selected.
    SQL>Cheers,

  • Needs Time Calculation in SQL Querry

    Dear ALL,
    I am having One Finished Good (X )  which is make item and machine is defined in one of the UDF in Item master (U_MACH) and Speed of the machine is also defined in Item Master. (U)Speed)
    now the scenario is :
    I got an Sales order for X , qty is 100000
    Now i want to calculate the time
    speed of the machine is 400 per min and name of the machine is M1
    so
    100000/400 = 250 /60  = 4,16 Hrs
    and my end time is 10AM 
    i want a querry to calculate 10:00:00 - 4:16.00 = 5:44:00
    Thanks In Advance
    Ashish Gupte

    Hi,
    I have a sample code right here.Just change Hour1 and Hour 2 into your corresponding Table.FieldName.
    Note: the only difference here is Time start - Time end - 15 mins. Kindly remove @lessmin.
    DECLARE @lessmin int;
    DECLARE @ms int;
    DECLARE @datetime1 datetime;
    DECLARE @datetime2 datetime;
    Declare @hour1 as datetime
    Declare @hour2 as datetime
    Declare @date1 as datetime
    Declare @date2 as datetime
    set @date1 ='2011-08-25'
    set @date2 ='2011-08-25'
    set @hour1=(Select $[OPDN.U_LoadTimeStart])
    set @hour2 =(Select $[OPDN.U_LOadTimeEnd])
    SET @lessmin = -15;
    SET @datetime1 = @date1 + @hour1 ;
    SET @datetime2 = @date2 + @hour2;
    SET @ms = DATEDIFF(ms,@datetime1,DATEADD(mi,@lessmin,@datetime2));
    select  convert(varchar(13),@ms/3600000)+':'+right('0'+convert(varchar(2),(@ms % 3600000)/60000),2)
    Regards,
    Darius Gragasin

  • Invalid column Index error - While consuming Calculation view via Native SQL

    Hi Experts,
    I am trying to consume a Calculation view (sql script one) , which has input parameters, via Native SQL in a ABAP program .
    Code snippet for the same would be as follows , Upon execution, it throws an error "Invalid Column Index (8) error " . Can anyone help what could be the issue here ?
    Thanks in Advance,
    Suma
    REPORT ZTEST_HANA2.
    *Report to consume Calculation view (script based) from ABAP
    PARAMETERS: ip_docnr type BELNR_D,
                ip_gjahr type GJAHR,
                ip_bukrs type BUKRS,
                ip_blgr type FAGL_RLDNR.
       DATA: LO_SQL_STMT TYPE REF TO CL_SQL_STATEMENT,
              LO_CONN     TYPE REF TO CL_SQL_CONNECTION,
              LO_RESULT   TYPE REF TO CL_SQL_RESULT_SET,
              LV_SQL      TYPE STRING,
              LR_DATA     TYPE REF TO DATA.
        DATA: LX_SQL_EXC           TYPE REF TO CX_SQL_EXCEPTION,
              LT_SEPMAPPS_CLSDINV  TYPE TABLE OF SEPMAPPS_CLSDINV,
              LV_TEXT              TYPE STRING.
        TRY.
    lv_sql = |SELECT * FROM "_SYS_BIC"."DEMO-ABAP/CA_GET_FI_DATA" | &&
                     |WITH PARAMETERS ('placeholder'= ('$$p_DOCNR$$','{ ip_docnr }'),| &&
                      |'placeholder'=('$$p_GJAHR$$','{ ip_gjahr }')| &&
                      |,'placeholder'= ('$$S_BUKRS$$','{ ip_bukrs }')| &&
                      |,'placeholder'= ('$$p_base_ledger$$','{ ip_blgr }') )| .
             LO_CONN = CL_SQL_CONNECTION=>GET_CONNECTION( ).
             "Create an SQL statement to be executed via the connection
              LO_SQL_STMT = LO_CONN->CREATE_STATEMENT( ).
             "Execute the native SQL query
             LO_RESULT = LO_SQL_STMT->EXECUTE_QUERY( LV_SQL ).
             "Read the result into the internal table lt_sepmapps_clsdinv
             GET REFERENCE OF LT_SEPMAPPS_CLSDINV INTO LR_DATA.
             LO_RESULT->SET_PARAM_TABLE( LR_DATA ).
             LO_RESULT->NEXT_PACKAGE( ).
             LO_RESULT->CLOSE( ).
             LO_CONN->CLOSE( ).
        CATCH CX_SQL_EXCEPTION INTO LX_SQL_EXC.
             LV_TEXT = LX_SQL_EXC->GET_TEXT( ).
             MESSAGE LV_TEXT TYPE 'E'.
        ENDTRY.

    Hi Suma,
    Post the SQL you success run directly on Studio together with error message (even if is the Invalid column index error).
    Check there if the parameters case is working properly... Is it really this confusing options:
    p_GJAHR
    S_BUKRS
    p_base_ledger
    Why not all lower or all upper? Anyhow you must test and find which option works according your modeling
    Regards, Fernando Da Rós

  • Errow with IF statement in Scripted Calculation view

    Hi Team,
    I am trying to use IF statement in Scripted Calculation view.
    My scenario is:-
    I need to create a restricted Key figure based on input date from user.
    While i am activating my view system gives "Internal deployment of object failed;Repository: Encountered an error in repository runtime extension;Internal Error:Deploy Calculation View: SQL: transaction rolled back by an internal error: Syntax Error for calculated Attribute: line 29 col 9 (at pos 1501)" error.
    Below is the code i have used in my CV.
    CE_CALC('IF((to_int("BUDAT") >= to_int(2013-01-01),"AMOUNT",'''')', DECIMAL(13,2)) AS "DTR"
    Here, "AMOUNT" is another calculated field created using CE_CALC.
    Without above IF statement my CV runs perfectly fine. The moment i include IF statement it does not activate.
    Kindly provide your inputs.
    Thanks & Regards,
    Anup

    Hi Lars,
    I am extremely sorry about the confusion.
    There was an extra parenthesis in the IF statement which was not allowing the CV to be activated. CV is now successfully activated.
    But my data is not getting restricted correctly.
    It is showing 0 against all the records.
    Below is the sql used for calling the CV.
    SELECT * FROM "_SYS_BIC"."A_123/CV_SCR_BSID_BSAD_ITEMS" ('PLACEHOLDER' = ('$$Currency$$', '''Local'''),'PLACEHOLDER' = ('$$Date_From$$','2014-01-01' ), 'PLACEHOLDER' = ('$$Date_To$$','2014-06-30' ));
    Below is my updated CE_CALC function :-
    CE_CALC('IF(date("BUDAT") >= date(:Date_From) and date("BUDAT") <= date(:Date_To),"AMOUNT",0)', DECIMAL(13,2)) AS "DTR"
    Is there any issue while passing values here?
    Regards,
    Anup

  • Named Calculation Column in DSV - SSAS Cube (2012)

    Hi,
    I have a question on creating named calculation (derived column) in data source view of SSAS 2012 Cube. Below scenario :
    If i am writing an expression in Fact table (say, creating named calculation column, "X" in this fact table) then is it possible to have a case statement based on the condition from one of the dimension data ?
    For ex., one my dimension "KC_Dim" contains column "KC_Code" on which i want to have a condition something like below:
    Case
    When KC_DIM.KC_Code = "-" 
    Then 0
    Else FactTable.Measure
    End 
    how to achieve this specially because i am writing it in fact table but the condition mentions dimension columns which it is giving error "could not find the dimension column"
    any idea ?
    Thanks

    Hi UltraDev,
    For the first questions "is it possible to have a case statement based on the condition from one of the dimension data ?"the answer is yes. The expresion for the named calculation should be a valid SQL expresion. So just the Case statement should be specified,
    like:
    Case [Month]
    When 1 Then 'January'
    When 2 Then 'February'
    End
    Then the SQL expression can refer to other tables in the data source view. You can refer to the link below to see the detail information.
    Define Named Calculations in a Data Source View (Analysis Services)
    Introduction to Named Calculations in SQL Server Analysis Services
    Regards,
    Charlie Liao
    TechNet Community Support

  • Getting Error while creating Calculation view.

    Hi Expert,
    I was trying to create one simple calculation view using SQL script but getting below error.
    /********* Begin Procedure Script ************/
    BEGIN
    create type var_out1 as table (ebeln varchar(10),menge decimal);
            var_out  = CE_COLUMN_TABLE ("SAPEH2"."EKKO",[EBELN,AEDAT] );
            var_out1 = CE_COLUMN_TABLE ("SAPEH2"."EKPO",[EBELN,MENGE] );
            var_out2 - CE_UNION_ALL (:var_out1,:var_out2);
    END
    /********* End Procedure Script ************/
    I thought , i might need to declare a table type for output table var_out1 and var_out2. I tried by declaring table like below couldn't get any success.
    create type var_out1 as table (ebeln varchar(10),menge decimal);
    create type var_out2 as table (ebeln varchar(10), aedat DATE ,menge decimal);
    error:
    Message :
         Internal deployment of object failed;Repository: Encountered an error in repository runtime extension;Internal Error:Deploy Calculation View: SQL: sql syntax error: CREATE TYPE is not allowed in SQLScript: line 5 col 2 (at pos 277)nSet Schema DDL statement: set schema "SAPEH2"nType DDL: create type "_SYS_BIC"."pkg-sapuser03.test_giri/CA_SALES1/proc/tabletype/VAR_OUT" as table ("EBELN" VARCHAR(10), "AEDAT" DATE, "MENGE" DECIMAL(13,3))nProcedure DDL: create procedure "_SYS_BIC"."pkg-sapuser03.test_giri/CA_SALES1/proc" ( OUT var_out "_SYS_BIC"."pkg-sapuser03.test_giri/CA_SALES1/proc/tabletype/VAR_OUT" ) language sqlscript sql security definer reads sql data as  n /********* Begin Procedure Script ***********/ n BEGIN n n create type var_out1 as table (ebeln varchar(10),menge decimal);n create type var_out2 as table (ebeln varchar(10), aedat DATE ,menge decimal);n n t   var_out  = CE_COLUMN_TABLE ("SAPEH2"."EKKO",[EBELN,AEDAT] );n t   var_out1 = CE_COLUMN_TABLE ("SAPEH2"."EKPO",[EBELN,MENGE] );n t   var_out2 - CE_UNION_ALL (:var_out1,:var_out2);nnEND /******** End Procedure Script ************/n
    Could you please help me to understand the cause of this?
    Thanks,
    Girdhari

    Hi Lars,
    Thanks for the reply.
    If i understood correctly , you are suggesting to create var_out1 and var_out2 in output ? If yes can you please guide me on how to do that? I tried but did not find anything suitable to declare table.
    Thanks,
    Girdhari

  • Syntax error while creating Calculation view script based

    Hi Folks,
    I'm creating Calc view based on script and drafted a simple code but I'm getting syntax error.
    Its just fetching few coloumns from two tables products and purchaseorderitem.
    /********* Begin Procedure Script ************/
    BEGIN
      var_out = select productid , category, nameid, currency, grossamount, quantity
      FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS B
      where P.productid = B.productid;
    END /********* End Procedure Script ************/
    Could you pls take a look and let me know what wrong I'm doing?
    Error logs are:-
    sap.hana..package.project.folder.mytest.CALCSCRIPTVIEWInternal deployment of object failed;Repository: Encountered an error in repository runtime extension;Internal Error:Deploy Calculation View: SQL: sql syntax error: incorrect syntax near "democontent": line 5 col 18 (at pos 439)nSet Schema DDL statement: set schema "SYSTEM"nType DDL: create type "_SYS_BIC"."sap.hana..package.project.folder.mytest/CALCSCRIPTVIEW/proc/tabletype/VAR_OUT" as table ("PRODUCTID" NVARCHAR(10), "CATEGORY" NVARCHAR(2), "NAMEID" NVARCHAR(10), "CURRENCY" NVARCHAR(5), "GROSSAMOUNT" DECIMAL(15,2), "QUANITYT" DECIMAL(13,3))nProcedure DDL: create procedure "_SYS_BIC"."sap.hana.package.project.folder.mytest/CALCSCRIPTVIEW/proc" ( OUT var_out "_SYS_BIC"."sap.hana.package.project.folder.mytest/CALCSCRIPTVIEW/proc/tabletype/VAR_OUT" ) language sqlscript sql security definer reads sql data as n /********* Begin Procedure Script ************/ n BEGIN n t var_out = select productid , category, nameid, currency, grossamount, quantityn t FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS Bn t where P.productid = B.productid;nnEND /********* End Procedure Script ************/n

    Hi Rubane,
    I don't have EPM installed here but based on this Table User Defined Functions( Table UDF ) in HANA  you are not properly defining the source table.
    In your case missing 1) schema of EPM, 2) not using double quotes, 3) separation of package and view, 4) missing camel case on purchaseOrderItem:
    FROM sap.hana.democontent.epm.data.products AS P , sap.hana.democontent.epm.data.purchaseorderitem AS B
    On blog:
    from "SAP_HANA_EPM_DEMO"."sap.hana.democontent.epm.data::businessPartner" as a
    SAP_HANA_EPM_DEMO is the schema
    sap.hana.democontent.epm.data is the package
    businessPartner is the view
    Start simple... before the seletion try it out on Studio SQL.
    Regards, Fernando Da Rós

  • High CPU Usage On client application when upgrade remote SQL database

    Hi,
    Is anyone here encountered very high CPU usage after upgraded the database from SQL 2005 to SQL 2012? Following describes my issue.
    I have my client application running on Windows 7 that access to central database (SQL 2005) on Windows server 2003 using ODBC connection, this client application basically query data and perform data insert and update. There are a number of this similar
    clients connected to the database.
    Due to slowness of the database server, company decided to upgrade the database server to SQL 2012 and also new hardware runing Windows Server 2012. There is no change on the client application and client hardware and the client application still using the
    same ODBC connection to query, insert or update the new database server.
    The problem I am now experiencing now is that my client PC where my client application running the CPU usage is very high almost hitting 100% when accessing to the central database. I am also noticed this program lsass.exe that utilized almost 40-50% of
    the CPU time when client application accessing the central database.
    Is anyone here know, why client PC CPU usage 100% when access to upgraded SQL 2012 database? What is lsass.exe program doing, it only appear when accessing to database server. How to reduce the CPU usage on client?
    Thanks.
    Chee Wee.

    Hello,
    After upgrading, please rebuild indexes and update statistics on the databases.
    http://www.mssqltips.com/sqlservertip/1367/sql-server-script-to-rebuild-all-indexes-for-all-tables-and-all-databases/
    http://www.mssqltips.com/sqlservertip/1606/execute-update-statistics-for-all-sql-server-databases/
    Configure maxdop on the instance.
    http://blogs.msdn.com/b/sqlsakthi/archive/2012/05/24/wow-we-have-maxdop-calculator-for-sql-server-it-makes-my-job-easier.aspx
    If the above does not solve the issue, let us know.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How to keep decimal in sql query

    Dear Expert,
    I try to do calculation in sql query, but it will automatically remove the decimal point.
    This is my query:
    SELECT 719 / 100
    And i want a result = 7.19, but its not work. Its return 7.
    i did try to use, SELECT ROUND(719/100,2), but its not working too...
    Does any one have any idea how to get 7.19
    Thanks in advance for any reply.
    Regards,
    Mat

    yes, i have answer already.
    select cast(719/(100*1.0)as decimal (16,2))

Maybe you are looking for

  • Problem in exporting report in CSV format

    Hi All, I am using Crystal Reports. Following are details about it: CR Developer Product 8.5.0.217 *_Problem that I am facing:__*_ I can create report in .rpt format, it is working fine here. But while trying to export this report in CSV format, it g

  • Notification center interferes with full-screen apps (incl. games)

    The new notification center interferes with games. When you are making control movements on the screen, a little grey tab keeps appearing at the top middle of the screen. Just from using it, it seems the notification center has a full-screen mode and

  • OIM Issue after upgraded to 9.1.0.2 BP07

    Hi everyone, I upgraded OIM with the bundle patch 07 but when try to connect with the OIM Admin Console (xelsysadm), I received a log error : <Apr 15, 2010 8:35:28 AM CEST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode> ERROR

  • My ipad camera is not working why? Help

    My ipad camera is not working, why? Please help!!

  • How can i send PGP encrypted file from PI to the receiver

    Hi experts,                     I am unable to send the  PGP encrypted file from PI to the receiver. where the Clients sends the file using PGP encryption, But i am trying to send the same with PI. But i am not able to send the same can you please he