Calling a User defined function from Data Model in BIP

I am new to Procedures and Functions and am not sure if I am doing it right, so please bear with me.
My User Function:
create function MyTempFunction(@master_key varchar(max))
returns VARCHAR(MAX)
begin
DECLARE @Names VARCHAR(8000)
SELECT @Names = COALESCE(@Names + ', ', '') + vndt.name
from
[CMPROJ].[dbo].[VNDT] as vndt,
[CMPROJ].[dbo].[CRQT_QUESTION_DISTRIBUTION] as CQD
where CQD.parent_key=@master_key
and CQD.project_name=vndt.project_name
and vndt.initials=CQD.distributed_to_ini
return @Names
endIf I call the function in my query window I get a result:
"Ron Swanson, Anne Perkins"
But if I put the same query into my Data Model in BI Publisher and try getting the XML Output, my data is blank.
This is how I call the function:
select top 1 dbo.MyTempFunction('98d4dfa893164d138d5f961fa4') as Names from dbo.[CRQT_QUESTION_DISTRIBUTION]And I know that BIP did access the function, because the first time I tried to save the new SQL Query, it threw an error saying it was denied access to the function and I had to add the user to be able to execute the function.
I am new to doing Procedures and Functions, so I am not sure if I am even doing it right.
And don't know if even calling procedures or functions works form BIP.
Any help appreciated.
Thanks

Thanks for the suggestion, but I still get nothing in the XML result set.
I enabled some extra logging in the bipublisher.log file and I get an error:
[2012-12-21T08:14:37.658-06:00] [AdminServer] [TRACE] [] [oracle.xdo] [tid: 11] [userId: <anonymous>] [ecid: e661403a668a80f1:56f304f5:13baf5ed125:-8000-0000000000003097,0] [SRC_CLASS: oracle.xdo.dataengine.XMLPGEN] [APP: bipublisher#11.1.1] [SRC_METHOD: processSQLDataSource] Sql Query :Distrubuted_To: select dbo.MyTempFunction('98d4dfa893164d138d5f961fa4') as Names [[
from dbo.[CRQT_QUESTION_DISTRIBUTION]
[2012-12-21T08:14:37.658-06:00] [AdminServer] [WARNING] [] [oracle.xdo] [tid: 11] [userId: <anonymous>] [ecid: e661403a668a80f1:56f304f5:13baf5ed125:-8000-0000000000003097,0] [APP: bipublisher#11.1.1] java.io.IOException: [Hyperion][SQLServer JDBC Driver]Object has been closed.[[
     at hyperion.jdbc.sqlserverbase.BaseCharacterStreamWrapper.validateClosedState(Unknown Source)
     at hyperion.jdbc.sqlserverbase.BaseCharacterStreamWrapper.read(Unknown Source)
     at oracle.xdo.dataengine.LOBList.readLobChunks(LOBList.java:263)
     at oracle.xdo.dataengine.XMLPGEN.writeLobToStream(XMLPGEN.java:976)
     at oracle.xdo.dataengine.XMLPGEN.writeRowSetListToStream(XMLPGEN.java:948)
     at oracle.xdo.dataengine.XMLPGEN.processSQLDataSource(XMLPGEN.java:479)
     at oracle.xdo.dataengine.XMLPGEN.writeData(XMLPGEN.java:345)
     at oracle.xdo.dataengine.XMLPGEN.writeGroupStructure(XMLPGEN.java:286)
     at oracle.xdo.dataengine.XMLPGEN.writeXMLDataStructure(XMLPGEN.java:216)
     at oracle.xdo.dataengine.XMLPGEN.processDataSet(XMLPGEN.java:1450)
     at oracle.xdo.dataengine.XMLPGEN.processMergedDataSet(XMLPGEN.java:1258)
     at oracle.xdo.dataengine.DataProcessor.processData(DataProcessor.java:366)
     at oracle.xdo.servlet.dataengine.DataProcessor.processData(DataProcessor.java:402)
     at oracle.xdo.servlet.dataengine.DataProcessor.processData(DataProcessor.java:389)
     at oracle.xdo.online.data.ClassicDataProcessor.process(ClassicDataProcessor.java:157)
     at oracle.xdo.servlet.ReportModelContextImpl.getReportXMLData(ReportModelContextImpl.java:232)
     at oracle.xdo.servlet.CoreProcessor.process(CoreProcessor.java:310)
     at oracle.xdo.servlet.CoreProcessor.generateDocument(CoreProcessor.java:93)
     at oracle.xdo.servlet.ReportImpl.renderBodyHTTP(ReportImpl.java:1059)
     at oracle.xdo.servlet.ReportImpl.renderReportBodyHTTP(ReportImpl.java:624)
     at oracle.xdo.servlet.XDOServlet.writeReport(XDOServlet.java:473)
     at oracle.xdo.servlet.XDOServlet.writeReport(XDOServlet.java:445)
     at oracle.xdo.servlet.XDOServlet.doGet(XDOServlet.java:265)
     at oracle.xdo.servlet.XDOServlet.doPost(XDOServlet.java:297)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
     at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
     at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.xdo.servlet.metadata.track.MostRecentFilter.doFilter(MostRecentFilter.java:65)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.xdo.servlet.security.SecurityFilter.doFilter(SecurityFilter.java:122)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.xdo.servlet.init.InitCheckingFilter.doFilter(InitCheckingFilter.java:64)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
     at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
     at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
     at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
     at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
     at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
     at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
     at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
     at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
     at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
     at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
     at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
     at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
     at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
]]This same error gets displayed 5 times in a row with the new changes to the query.
And If I look in the XML result set that I get when I do a test run I get:
<G_7>
     <NAMES></NAMES>
</G_7>
<G_7>
     <NAMES></NAMES>
</G_7>
<G_7>
     <NAMES></NAMES>
</G_7>
<G_7>
     <NAMES></NAMES>
</G_7>
<G_7>
     <NAMES></NAMES>
</G_7>So you can see that I am getting a blank value 5 times.
When I run it with the "top 1" I only get the error once and I only see 1 entry in the XML.
Thanks,

Similar Messages

  • Calling PL/SQL user defined functions from ODI Constraints

    Hi All,
    We are trying to call user defined PL/SQL functions from ODI. We are able to call them from ODI's User functions. But when we are trying to call them from ODI Constraints under Models, it is throwing an error 'ORA-00920 invalid relational operator'. Kindly let me know if anyone has faced the same issue and got the resolution for the same. Thanks in Advance.
    Regards,
    Abhishek Sharma

    Hi Ace,
    Thanks for the response, the same error was coming in operator also.
    I am able to call PL?SQL user defined functions from ODI Constraints. We have to first call ODI User functions from the ODI constraints as we cant call PL/SQL function (compiled in database) directly.
    From the ODI User functions, we can then call the PL/SQL functions.
    Please reach out to me if you need further details reg this.

  • Calling a user defined function as default value for a column

    Hi All
    Can we call a user defined function as default value for a column ??
    for example:
    create or replace  function test1  return number is
    begin
    return 10;
    end;
    create table testt
    (id  as test1,
      name varchar2(20));
    getting error:
    Error at line 1
    ORA-02000: missing ( keywordThanks
    Ashwani
    Edited by: Ashwani on Jan 16, 2012 1:19 AM

    Hi;
    For your issue i suggest close your thread here as changing thread status to answered and move it to Forum Home » Database » SQL and PL/SQL which you can get more quick response
    Regard
    Helios

  • Calling a user defined function in a select statement

    PLS-00231: function 'F_GET_PROJECT_ID' may not be used in SQL
    I am caling a user defined function 'F_GET_PROJECT_ID' in a select statement and getting the above error .
    Can any one help me to resolve it.
    I can not replace the function with a local variable nor can I assign the output of the function to a variable and use the variable in the sql stmt. cos, the in put parameters of the function comes from the same select statement.
    Please help
    Thanks in advance

    Can you provide your function code? Using a function like that is possible from the below example. I suspect something in your function code.
    SQL> create or replace function sample_func(p_sal number)
      2  return number
      3  is
      4  v_sal number;
      5  begin
      6     v_sal := p_sal+100;
      7     return v_sal;
      8  end;
      9  /
    Function created.
    SQL>
    SQL> select empno, ename, sal, sample_func(sal)
      2  from emp
      3  /
         EMPNO ENAME             SAL SAMPLE_FUNC(SAL)
          7839 KING             5000             5100
          7698 BLAKE            2850             2950
          7782 CLARK            2450             2550
          7566 JONES            2975             3075
          7654 MARTIN           1250             1350
          7499 ALLEN            1600             1700
          7844 TURNER           1500             1600
          7900 JAMES             950             1050
          7521 WARD             1250             1350
          7902 FORD             3000             3100
          7369 SMITH             800              900
          7788 SCOTT            3000             3100
          7876 ADAMS            1100             1200
          7934 MILLER           1300             1400
    14 rows selected.
    SQL>And yeah... your formatted code is this.
    cursor c1 is
       SELECT t.upi_nbr upi_nbr,
              f_get_project_id(l.pay_type_code,
                               l.charge_type_nme,
                               l.charge_code) project_id,
              LAST_DAY(TO_DATE(SUBSTR(t.Year_Month, 5, 2)||'/'||'01'||'/'||SUBSTR(t.Year_Month,1,4),
                               'MM/DD/YYYY'))reporting_period_end_date,
              SUM (c.hours_worked_qty) reported_hrs
       from trs.trs_timesheet@oraprod5 T,
            trs.trs_line@oraprod5 L,
            trs.trs_cell@oraprod5 C
    where T.upi_nbr=L.upi_nbr
    and T.year_month=L.year_month
    and L.row_nbr=C.row_nbr
    and L.upi_nbr=C.upi_nbr
    and L.year_month = C.year_month
    and L.invalid_activity_ind = 'V'
    and rtrim(L.charge_code) is not null
    AND L.Pay_Type_Code<>'REQ'
    and C.Hours_Worked_Qty > 0
    GROUP BY t.upi_nbr,
             t.year_month,
             t.oui_nbr,
             l.charge_code,
             l.activity_detail_code,
             l.charge_type_nme,
             l.pay_type_code;Cheers
    Sarma.

  • How to distinguish the User-Defined-Function from Oracle Build-In function

    Hi Friends,
    I could get the function list form all_objects table by the SQL:
    select * from all_objects where object_type = 'FUNCTION'
    but there is no column in all_objects specify the function is build-in or user-defined.
    But I found in SQL Server there is a column "is_ms_shipped" in the sys.all_objects table. This column will specify the object is build-in or user-defined. I want to get the equivalent column in Oracle but failed.
    Could anyone tell me how to solve this problem?
    Thanks,
    Ricky

    Thanks Pavan.
    But if an user connects to database using "conn /as sysdba" syntax and creates a function. This user-defined funtion goes into the "SYS" schema also. I know it is not the best practise to create objects using sys user so I think your solution is right.
    Regards,
    Ricky

  • Help: How to call a user defined function in a data block query?

    I created a string aggregation function in the program unit, see reference:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    I now like to call the function in my data block query. I got the error: ORA-00904: 'concatenate_list' invalid identifier.
    Please help.
    Thank you in advance.
    Jimmy

    Hi,
    You can write UDFs in java in Graphical mapping to enhance your XI Graphical mapping functionality
    The steps for doing it would be:
    1. Click on Create New function Button found on Bottom left corner on your XI Mapping window.
    2. Write your java code.
    3. Run the Mapping Test as usual.
    >>The module that is given here ...where and how it is used.
    The adapters in the Adapter Framework convert XI messages to the protocols of connected external systems and the other way around. When doing so, some
    functionality might need to be added specific to a situation which is possible with the use of custom modules.
    Typical example would be validation of file content when using a File Adapter or modification of the message payload to a common content structure which is not supported by any of the standard SAP modules.
    An Adapter module is developed as an Enterprise Java Bean and is called locally by the Adapter.
    An example on modules :
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805">How to develop a module for reading file name in a sender file adapter XI 3.0</a>
    Cheers,
    Chandra

  • Can COLMAP call a User Defined Function?

    Hi, I'm new to GoldenGate. We are replicating many source databases into a single target database. All source databases have the same schema but with different data. I need to generate a GUID to insert into a new column in every table in the source database. Can I do this with COLMAP? If so, how can I generate a GUID with COLMAP?
    If this is not possible, what would be a good solution? Should we use BEFORE INSERT triggers in the source DB to insert the GUID? The guid column is only on the target DB and not in the source DB.
    Thanks.

    Create a procedure to get the data you want:
    CREATE OR REPLACE PROCEDURE LOOKUP
    (CODE_PARAM IN VARCHAR2, DESC_PARAM OUT VARCHAR2)
    BEGIN
      SELECT DESC_COL INTO DESC_PARAM
      FROM LOOKUP_TABLE
      WHERE CODE_COL = CODE_PARAM;
    END;Then, in your replicat, use SQLEXEC:
    MAP HR.ACCOUNT, TARGET HR.NEWACCT,
    SQLEXEC (spname lookup,
    params (code_param = account_code)),
    COLMAP (USEDEFAULTS, newacct_id = account_id,
    newacct_val = @GETVAL(lookup.desc_param));The @GETVAL function maps values returned in desc_param to the newacct_val column.

  • Calling user defined functions through OBIEE

    Can anyone tell me how I can call the user defined functions on database through the new BI tool.
    The idea is to collect certain parameters through the prompt when launching the request, the function is supposed to pick up the parameters, make a certain calculation, and return a value.
    I wrote the function, I just need help over how to call the function through the BI tool - that was pretty easy in the old Discoverer.
    Thanks.
    Message was edited by:
    user611377

    Hi Kresimir ,
    You can use EVALUATE function to call a user defined function.
    EVALUATE('FUNCTIONNAME(%1,..)' As DATATYPE,parameter1,...)
    Here DATATYPE is the returntype of function.
    Hope this will help.
    Thanks
    Ashok

  • Calling user defined functions in Matlab Script Node

    Greetings!
    I am not successful in calling a user defined function inside a Matlab Script Node.
    The path has been added to Matlab, but the Matlab script node is not calling my function.
    I am calling it as follows:
    a= fcd(b,c);
    and the fcd.m file is calculating the 'first central difference' - works in Matlab, but not in LabVIEW:
    function MtxOut=fcd(MtxIn,dt)
    %MtxOut=fcd(MtxIn,dt)
    %first central difference method of finding instantaneous
    %first derivatives
    %MtxIn = MxN matrix of inputs
    %dt = time change between inputs
    %MtxOut = MxN matrix of first derivatives of inputs
    r=size(MtxIn,1);
    c=size(MtxIn,2);
    MtxOut(1,=(MtxIn(2,-MtxIn(1,)/dt;
    MtxOut(r,=(MtxIn(r,-MtxIn(r-1,)/dt;
    for i=2:r-1
        for j=1:c
            MtxOut(i,j)=(MtxIn(i+1,j)-MtxIn(i-1,j))/(2*dt);
        end
    end

    Matthew:
    What version of MatLab, LabVIEW are you using?. Also, what type of errors are you running into?.
    Thanks,
    Rudi N.

  • Using Xquery predefined functions in User defined functions

    Hi All,
    I have a requirement of calling a user defined function in osb xquery file.In that function i have to use osb predefined string functions but they are not working it shows error message in xquery file.Can you please suggest how to use them in user defined functions.
    Thanks,
    Srinivas.

    Hi Eric,
    I have a Proxy service it reads mfl data and transform to some other schema.In this Transformation one element data is taken and we have to manipulate that data
    based on the incoming value and return .For this process i took one function and i have to check weather it contains some symbols like ^,~ so i used contains function of
    String with and with out prefix with if else condition it gives error "Unexpected token if"
    declare function insp:buildReferenceRange($inRange as xs:string)
    as xs:string
    let $low:=""
    l
    if(contains($inRange,"^")) //"Unexpected token if"
    name space and prefix are defined in the top of file.
    Thanks,
    Srinivas.

  • Calling the function NUMBER_GET_NEXT from an XI User Defined Function

    Hi there,
    A number range object has been created on our XI server, called, ZBC_BKSTMT.
    I need to call the function NUMBER_GET_NEXT (standard SAP function for number range objects) with the parameters:
    NR_RANGE_NR = 01
    OBJECT = ZBC_BKSTMT
    Calling the NUMBER_GET_NEXT function will return a unique integer.  However, i need to call it from a User Defined Function because I need to make use of the returned integer in my message mapping.
    Thanks,

    Hello,
    If you have SP13, SAP provides a RFC API which can be called during the mapping. Refer to this document:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-code-samples/xi%20mapping%20lookups%20rfc%20api.pdf
    Also check this weblog :
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    For pre-SP13 systems, refer to this How-To
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi-how-to-guides/how%20to%20perform%20sap%20data%20lookups%20within%20xi%20mappings
    ***************Reward points,if found useful

  • Calling ORACLE Store Procedure with parameters in user define function

    Hi everybody,
    We have a scenario connecting Oracle DB thru JDBC adapter.
    We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
    Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
    I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
    I am looking for an example.
    Thanks in advance,
    Gigi

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • User defined function to find difference between dates

    format of dtActivityStartDate/dtActivityFinishDate: 2010-09-17 14:50:51.150
    usdFuncTimeCalc (vcActivityName,dtActivityStartDate, dtActivityFinishDate) -- user defined function
    i need to calculate time elapsed for that type of activity following are the rules:
    (If Process Request is the activity)
    Working Days: Monday through Saturday
    Hours of Operation: 9AM – 5PM
    only working hours of day need to the counted like for example if it is sep 15 11 Am is dtActivityStartDate & Sep 17 is dtActivityFinishDate is 10 Am. then time elapsed is 11am to 5pm on sep 15 , 9 to 5 on sep 16 & 9 to 10 on sep 17 so total should be
    6+ 8 + 1 = 15 hours + minutes.
    format of date time: 2010-09-17 14:50:51.150
    vcActivityName = Process Request
    Don't worry about process request...

    I hv modified the code to make it more generic inorder to suit any timings (customizable) from Monday - Saturday.
    declare
      -- ** b u s i n e s s _ h o u r s **
      -- business_hours returns the number of work houts (9 am through 5 pm,
      -- Monday through Saturday) between in_start_dt and in_end_dt.
      -- If in_start_dt > in_end_dt, the results will be <= 0.
      -- Holidays are not considered.
      in_start_dt DATE := to_date('15-SEP-2010 11:00:00','DD-MON-RRRR HH24:MI:SS');
      in_end_dt   DATE := to_date('17-SEP-2010 10:00:00','DD-MON-RRRR HH24:MI:SS');
      d          NUMBER; -- Hours of either start_dt or end_dt after midnight
      end_dt     DATE := GREATEST(in_start_dt, in_end_dt); -- In case dates were in wrong order
      return_val NUMBER; -- Total number of working hours
      start_dt   DATE := LEAST(in_start_dt, in_end_dt); -- In case dates were in wrong order
      start_time number := 9;
      end_time   number := 17;
    BEGIN
      WITH all_days AS(
        SELECT start_dt + LEVEL - 1 AS a_dt
          FROM dual
        CONNECT BY LEVEL <= 1 + TRUNC(end_dt) - TRUNC(start_dt))
          --SELECT SUM(12)
           SELECT SUM(end_time-start_time)
            INTO return_val
            FROM all_days
           WHERE TO_CHAR(a_dt,'Dy','NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun');
      dbms_output.put_line('Return_Val_1 : '||return_val);
      -- Adjust hours from start_dt, if necessary
      IF TO_CHAR(start_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
         -- Calculate nbr of hours passed from midnight
         d := 24 * (start_dt - TRUNC(start_dt));
         dbms_output.put_line('d:'||d);
         IF d >= end_time THEN -- d has passed 5 PM (end_time)
            -- Don't count start_dt if it has passed the closing hours
            return_val := return_val - (end_time-start_time);
            dbms_output.put_line('if-d:'||return_val);
         ELSIF d > start_time and d < end_time THEN -- d has passed 9 AM but less than 5 PM
            -- Don't count the part of start_dt which has passed the opening hours
            return_val := return_val - (d - start_time);
            dbms_output.put_line('else-d:'||return_val);
         END IF;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_2 : '||return_val);
      -- Adjust hours from end_dt, if necessary
      IF TO_CHAR(end_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
         d := 24 * (end_dt - TRUNC(end_dt));
         dbms_output.put_line('d:'||d);
        IF d <= 9 THEN -- d < 9 AM
           -- Don't count end_dt itself
           return_val := return_val - (end_time-start_time);
           dbms_output.put_line('if-d:'||return_val);
        ELSIF d > start_time and d < end_time THEN -- d > 5 PM
          -- Don't count part of end_dt
          return_val := return_val - (end_time - d);
          dbms_output.put_line('else-d:'||return_val);
        END IF;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_3 : '||return_val);
      IF in_start_dt > in_end_dt THEN
          return_val := -return_val;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_4 : '||return_val);
    END;Plz note the following points of the code :
    1) You'll need to convert it a function, I just made it a declare..begin..end; block.
    2) I hv used the same timings for start & end as you hv mentioned.
    3) The 2 variables "start_time" and "end_time" take the opening & closing business hours respectively in a 24 hour format.
    4) You might want to remove the DBMS_OUTPUT ... stmts which I had added for debugging.
    It was an interesting code block to analyze ... :-)

  • Calling user defined function in Oracle BI Answers?

    Hi
    I am new in Oracle BI . I want to use the user defined function in Oracle BI Answers as a column,function written in Oracle database to calculate the Sales Revenue.
    I am using Oracle BI Standard Edition One and Oracle 10g database.
    Please suggest me.
    Thanks
    Nusrat

    Search for EVALUATE function you can call function and pass parameters
    Example:
    EVALUATE Function
    This function is intended for scalar and analytic
    calculations.
    Syntax: EVALUATE('DB_Function(%1)', {
    Comma separated Expression})
    Example: SELECT
    e.lastname,sales.revenue,EVALUATE('dense_rank()
    over(order by %1
    )',sales.revenue) FROM sales s, employee e;

  • Can I call a User-Defined Mathscript Function using LabVIEW 7.1?

    I am trying to use a User-Defined function call in a mathscript node using LabVIEW 7.1 and I cannot seem to make it work.
    For example, consider that my mathscript node contains:
    clear all;
    close all;
    x = linspace(1,100,5);
    y = mltp(x);
    where the labview vi is saved in the same folder as the mathlab script mltp.m that is given by:
    function out1 = mltp(in1)
    out1 = 5*in1;
    Creating an array output of the mathscript node for y yields an empty array.
    How can I use User-Defined functions in a mathscript node using LabVIEW 7.1?

    Hello,
    LabVIEW 8.2 did not yet have the MathScript page in Tools >> Options.  In this version, you need to set the search path through the MathScript Window.  Launch the window from Tools >> MathScript Window.  Then go to File >> MathScript Preferences.  It sounds like you have done this.
    A first guess is that your .m file calls some unsupported functions or uses unsupported syntax.  If that were the case, you could put the script in the Script Editor of the MathScript Window and select the "Save and Compile Script" menu item.  This will return any errors from compiling the script.  However, you said you simplified the problem to a single multiplication.  Since this still does not work, I need more information.  What are all the directories listed for the path in the MathScript Preferences dialog from the MathScript window?  What is the working directory?  Where is your .m file located on disk?  Can you attach your .m file or paste the contents in your message?
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

Maybe you are looking for

  • Help needed in OIM 11g with respect to Target Recon

    Hi Experts, I have OIM 11.1.1.5.0 installed with AD Connector configured. We have 3 AD instances, so we have cloned the full AD Connector to "A_AD_RO User", "B_AD_RO User" and "C_AD_RO User" resourced with separate-separate Process defn, scheduled ta

  • ISW - Can Not Sync Password

    I use the ldap browser and it can connect to the ISW server. But when I verify the password, it shows nothing. Even on the ISW server, I use the "idsync resync -a "uid=myaccount", the result is the same. The new created user in the Window AD can sync

  • Install program for version 6 is hung up

    On 8/15/11, I attempted to download the upgrade from Firefox v 5 to version 6. Something went wrong, because after the install wizard went through its process, it asked me to reboot, which I did, but the Firefox program does not appear on my desktop.

  • Div vs. ap div

    Is there a way to put a div on top of another div.

  • I ordered a new iphone under my email address, not signed in.  I'm not able to view my receipt

    Hi I ordered a new iphone under my email address but as a guest, I can see tracking of my order, but when I choose to get a receipt, I need to sign in and there's no information about my order / receipt. what to do???