Can call a function a few times in reports

Hi
Please help me to solve this problem:
I have a function taking parameters and return a number, I tried
2 ways to call this function but get same error saying the
function may not be used in SQL:
1. the function is in a package, and I use the pl/sql query
(build from data model) to call it a few times by passing
different parameters, I get error when compile the query
2. the function is outside the package, and is called from
another function in the package a few times, get error when
compile the package body.
3. by the way is weekly typed ref cursor allowed in reports?
Below is part of my code:
case 1:
create or replace package perDiem AS
PRAGMA SERIALLY_REUSABLE;
TYPE curType IS REF CURSOR;
function diemSum (
party_id IN NUMBER,
partytype IN NUMBER,
fid IN NUMBER,
freeday_type IN VARCHAR2,
startdays IN NUMBER,
enddays IN NUMBER)
RETURN NUMBER;
END;
CREATE OR REPLACE PACKAGE BODY perDiem AS
PRAGMA SERIALLY_REUSABLE;
function diemSum (
party_id IN NUMBER,
partytype IN NUMBER,
fid IN NUMBER,
freeday_type IN VARCHAR2,
startdays IN NUMBER,
enddays IN NUMBER)
RETURN NUMBER IS
pdSum NUMBER(10);
BEGIN
IF partytype = 1 THEN
IF freeday_type = 'gateout' THEN
SELECT COUNT(*) INTO pdsum
FROM equipment e,
equipmenttrip et,
facilitysegment s
WHERE s.facilityid =fid
AND et.lastfreeday between startdays AND enddays
AND et.carrierpartyid =party_id;
ELSIF freeday_type = 'strip' THEN
SELECT COUNT(*) INTO pdsum
FROM equipment e,
END IF;
ELSIF partytype = 3 THEN
IF freeday_type = 'gateout' THEN
SELECT COUNT(*) INTO pdsum
FROM ...
ELSIF freeday_type = 'strip' THEN
SELECT COUNT(*) INTO pdsum
FROM facility f,
END IF;
END IF;
RETURN pdsum;
END diemSum;
END;
/////////// pl/sql query//////////////
function diemDet return perDiem.curType is
sum_cv perDiem.curType;
     party_code VARCHAR2(20);     
          freeday_type VARCHAR2(20);
begin
party_code := :partycode;
          freeday_type := :freeday;
          OPEN sum_cv FOR SELECT      f.facilitycode,
               perDiem.diemSum(p.partyid,
p.partytypeid, f.facilityid, freeday_type, 1, 4 ) as days1,
          perDiem.diemSum(p.partyid, p.partytypeid,
f.facilityid, freeday_type, 5, 10 ) as days2,
          perDiem.diemSum(p.partyid, p.partytypeid,
f.facilityid, freeday_type, 11, 10000 ) as days3
          FROM equipmenttrip et,
               facility f,
               facilitysegment s,
               party p
     WHERE f.facilityid = s.facilityid
          AND p.partycode = party_code ;
     RETURN sum_cv ;
end;
case 2 *** diemSum is a seperate function from package
create or replace package perDiem AS
PRAGMA SERIALLY_REUSABLE;
TYPE curType IS REF CURSOR;
function diemDet (
party_code IN VARCHAR2,
freeday_type IN VARCHAR2)
RETURN curType;
END;
CREATE OR REPLACE PACKAGE BODY perDiem AS
PRAGMA SERIALLY_REUSABLE;
function diemDet (
party_code IN VARCHAR2,
freeday_type IN VARCHAR2)
RETURN curType IS
sum_cv curType;
BEGIN
OPEN sum_cv FOR SELECT f.facilitycode,
diemSum(p.partyid, p.partytypeid, f.facilityid, freeday_type, 1,
4 ) as days1,
diemSum(p.partyid, p.partytypeid, f.facilityid, freeday_type, 5,
10 ) as days2,
diemSum(p.partyid, p.partytypeid, f.facilityid, freeday_type,
11, 10000 ) as days3
FROM equipmenttrip et,
facility f,
facilitysegment s,
party p
WHERE ...
RETURN sum_cv ;
END diemDet;
END;

My bet would be that the function doesn't promise not to update
the database. Therefor it can't be called from a select statment.
To overcome this you need to define a pragma. I don't remember
its exact name but I think it is restricted_reference.

Similar Messages

  • How can call a function module(RFC)in one server to another sever in my rep

    How can call a function module(RFC)in one server to another sever in my report program.
    What i am know whenever rfc enabled immediately radio button checks then only it will come.
    please justify.

    Syntax
    CALL FUNCTION func DESTINATION dest [EXPORTING p1 = a1 p2 = a2 ...]
    [IMPORTING p1 = a1 p2 = a2 ...]
    [CHANGING p1 = a1 p2 = a2 ...]
    [TABLES t1 = itab1 t2 = itab2 ...]
    [EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
    [system_failure = ns [MESSAGE smess]]
    [communication_failure = nc [MESSAGE cmess]]
    [OTHERS = n_others]].
    http://help.sap.com/saphelp_47x200/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm

  • Does flex can call vbscript function ?

       i am not sure does flex or action script can call vbscript function .
    how can i get detail information . thank you!

    Adobe does not provide such a capability.  Folks have created ways to call
    Java I believe, and ExternalInterface will call JavaScript.  And you can use
    sockets.  And NativeProcess from AIR apps.

  • How can I debug the Call Library Function at run-time

    I've written a VI using the CLF to call a DLL which was compiled off-site by another engineer using MSVC. Even though the VI runs without flagging any errors, the VI is not doing what I expect. Is there any way of finding out if the DLL is been called correctly? The first function that is called doesn't return any value, but I think that it should. Does this mean that the DLL is not being called correctly? Note also that the DLL works fine with a JAVA GUI.

    Make sure that you are specifying the proper function prototype in the call library function. If you are slightly off the call will not work properly. Ask the offsite engineer to provide you with this data. Another tip is to build the dll with the option to show front panel when called. You can actually popup the dll like you would a subvi. If you design it with test indicators showing on the front panel that is a great way to determine if it is working. Hope this helps.
    BJD1613
    Lead Test Tools Development Engineer
    Philips Respironics
    Certified LV Architect / Instructor

  • Can call a function in the select statement?

    Is there any ways to call a function in the select statement?
    what I like to do is this:
    select deptno, totalEmployees(deptno), TotalSalary(deptno)
    from emp;
    I know it can be done by count(*) and join tables, but my case
    is much more complex and the where clauses are different from
    one function to another, and have many tables to join and many
    combinations
    Thanks

    Functions can be used in a select statement subject to certain
    restrictions, see
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/
    server.817/a85397/statem9b.htm#2062024
    It's under "CREATE FUNCTION> Keywords and Parameters> function>
    Restrictions on User-Defined Functions"
    Here is an except...
    When a function is called from within a query or DML statement,
    the function cannot:
    a) Have OUT or IN OUT parameters
    b) Commit or roll back the current transaction, create or roll
    back to a savepoint, or alter the session or the system. DDL
    statements implicitly commit the current transaction, so a user-
    defined function cannot execute any DDL statements.
    c) Write to the database, if the function is being called from a
    SELECT statement. However, a function called from a subquery in
    a DML statement can write to the database.
    d) Write to the same table that is being modified by the
    statement from which the function is called, if the function is
    called from a DML statement.
    Except for the restriction on OUT and IN OUT parameters, Oracle
    enforces these restrictions not only for the function called
    directly from the SQL statement, but also for any functions that
    function calls, and on any functions called from the SQL
    statements executed by that function or any function it calls.

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • Can call a function from SQL COMMAND but can't from the SHUTTLE help please

    I've read this article
    ARTICLE
    I've written the code in a function called SURVEY_USERS that takes one variable
    when I run the following in the SQL builder:
    SELECT SURVEY_USERS('canns') from DUAL;I get
    SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM where smteam.division_manager=canns and rownum = 1
    UNION
    SELECT SMTEAM.dept_manager DS, smteam.dept_manager RV from SMTEAM LEFT where smteam.division_manager=canns
    UNION
    SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM where smteam.division_manager=cannswhich is what I want but when I put in into the "list of values definition".
    RETURN SCREPORTS.SURVEY_USERS('canns');I get
    Error     ORA-06550: line 1, column 188: PL/SQL: ORA-00904: "CANNS": invalid identifier ORA-00904: "CANNS": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored ORA-00904: "CANNS": invalid identifierI'm just confused as to what I'm doing wrong. I'm passing the same thing to the function...and it appears to be working in the SQL workshop and not the actual LOV Shuttle.
    Edited by: bostonmacosx on Sep 12, 2012 3:45 PM

    Here is some of the function
    create or replace function "SURVEY_USERS"
    (app_user in VARCHAR2)
    return VARCHAR2
    is
      vp_exists INTEGER;
      ed_exists INTEGER;
      dr_exists INTEGER;
      mngr_exists INTEGER;
    begin
    SELECT COUNT(*) into vp_exists
      FROM smteam
      WHERE area_manager= app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO ed_exists
      FROM smteam
      WHERE division_manager = app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO dr_exists
      FROM smteam
      WHERE dept_manager = app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO mngr_exists
      FROM smteam
      WHERE wdmanagername = app_user
      AND ROWNUM = 1;
    --dbms_output.put_line (vp_exists);
    --dbms_output.put_line (ed_exists);
    --dbms_output.put_line (dr_exists);
    --dbms_output.put_line (mngr_exists);
    IF (vp_exists = 1) THEN
      RETURN 'SELECT smteam.area_manager DS,smteam.area_manager RV from SMTEAM where smteam.area_manager='''||app_user||''' and ROWNUM = 1
       UNION
       SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM where smteam.area_manager='''||app_user||'''
       UNION
         SELECT smteam.dept_manager DS, smteam.dept_manager RV from SMTEAM  where smteam.area_manager='''||app_user||'''
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.area_manager='''||app_user||'''';
    END IF;
    IF (ed_exists = 1 and vp_exists=0) THEN
        RETURN 'SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM  where smteam.division_manager='''||app_user||''' and rownum = 1
       UNION
         SELECT SMTEAM.dept_manager DS, smteam.dept_manager RV from SMTEAM LEFT where smteam.division_manager='''||app_user||'''
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM where smteam.division_manager='''||app_user||'''';
      END IF;
    IF (dr_exists = 1 and ed_exists=0 and vp_exists=0) THEN
         RETURN 'SELECT smteam.dept_manager DS, smteam.dept_manager RV from SMTEAM  where smteam.dept_manager=:'''||app_user||'''and rownum = 1
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.dept_manager='''||app_user||'''';
      END IF;
    IF (mngr_exists = 1 and ed_exists=0 and vp_exists=0 and dr_exists=0) THEN
        RETURN  'SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.wdmanagername=:'''||app_user||''' and rownum = 1';
      END IF;
    END;
    Edited by: bostonmacosx on Sep 12, 2012 3:56 PM

  • How jsp can call applet functions

    good morning to all java experts
    i have one problem that is
    in my application i have one applet in the server side which contains functions like encryption, decryption, hash functions.
    whenever any client wants to store some information on server side then he download the applet from the server and he gives his own key and encrypt all the contents and these encrypted message only transmitted through media and store on server side
    whenever clients wants to retrieve some information from server then he fetch the only encrypted message to client side then he down load the applet from server and decrypts the message as he pass the previous key.
    the problem is that whenever jsp calls the applet functions through javascript it displaying error message like: error in the jsp page
    but this concept working through html page properly
    plss reply as soon as possible
    thanking uuu

    the problem is that whenever jsp calls the applet functions through javascript Show the relevant code how you thought to accomplish this (this is namely impossible without firing a new request to the server).
    it displaying error message like: error in the jsp pageAnd further on, you -as developer- should know that it is not-done and unclear to talk about errors if they are irrelevant. Always post and the full, complete, original and unchanged error message and -if in Java- also the stacktrace. They are helpful in debugging.

  • How to call the function 5 times

    hi
    i have a function 'a'  with array 1x2, 1x3, 1x4...
    every step its 1x2 > answer
    1x3 > answer..
    ans so on
    if answer correct i call my function 'a' again.
    how i can call my function 'a' just 3 times?
    thank you.

    Hello!
    Well, it depends on some factors, like:
    1) Function 'a' itself checks if the answer is correct?
    2) Which event calls function 'a'?
    ... and so on.
    Please, if you could detail your problem and maybe post some code, it will be easier for us to understand it and help you :-).
    Message was edited by: rah02

  • Can I call a function using array index?

    I've defined an array which stores the function name, like this:
    var aresetButtonTop:Array = new Array(resetTop1,resetTop2,resetTop3,resetTop4,resetTop5);  
    Then I have a button named"btnresetTop" which when clicked will call one of the five functions stored in the above array(aresetButtonTop). The functions are called at run-time depending upon some conditions. I need to figure out how I can call those functions using the array index. I'm using the following code to call the function. The value of i has been already calculated.
    btnresetTop.addEventListener(MouseEvent.CLICK, aresetButtonTop[i]);
    After doing this I'm getting the following error when I click the button:
    TypeError: Error #2007: Parameter listener must be non-null.
        at flash.events::EventDispatcher/addEventListener()
        at gallerytest_fla::MainTimeline/thumbTopClick()
    Note: thumbTopClick() is a function inside which all these codes are written.
    I need to find out whether it is posible in AS3 to call a function name using the array index or not. If yes, could you pleas ehelp me out.

    Thanx Andrei1, you were right, i was out of range.The value of i will obviously expire outside the for loop. Now I have corrected my mistake by assigning the value of i to a variable index inside the for loop and then use the following code:
    btnresetTop.addEventListener(MouseEvent.CLICK, aresetButtonTop[index])
    It was a silly mistake but I was not able to figure it out for the last 2 hours. Thanks once again for your help

  • Can I call a function with an arguement of %ROWTYPE directly from SQL?

    I have the following function in a 10g DB:
    CREATE OR REPLACE FUNCTION f_is_eligible2 (in_dm_row IN amplify_dm%ROWTYPE)
    RETURN NUMBER
    IS
    I know I can call that function from another pl/sql function but I'm wondering if I can call that function directly from a SQL statement, something like this:
    SELECT f_is_eligible2(dm.*)
    FROM amplify_dm dm
    or
    SELECT f_is_eligible2(dm%rowtype)
    FROM amplify_dm dm
    neither of those worked so I'm thinking it's not possible but I thought I'd ask anyway.
    Thanks in advance!

    Not possible as said - but - based on what I'm seeing - you could simply pass the parameter(s) that are key on that table and - accomplish the same thing by modifying the function.
    not sure why you'd need the whole row if I'm interpretting the code excerpt.

  • Problems calling a function from another function

    Hello all.
    I am trying to create a function that will loop a few other function.
    Basically the main function is this
                        private function publish(event:MouseEvent):void
                            if (doPublish.label == 'Publish')
                                // create a new NetStream object for video publishing
                                nsPublish = new NetStream(nc);
                                nsPublish.addEventListener(NetStatusEvent.NET_STATUS, nsPublishOnStatus);
                                // set the buffer time to zero since it is chat
                                nsPublish.bufferTime = 0;
                                // publish the stream by name
                                nsPublish.publish(publishName.text);
                                // add custom metadata to the stream
                                var metaData:Object = new Object();
                                metaData["description"] = "Chat using VideoChat example."
                                nsPublish.send("@setDataFrame", "onMetaData", metaData);
                                // attach the camera and microphone to the server
                                nsPublish.attachCamera(camera);
                                nsPublish.attachAudio(microphone);
                                doPublish.label = 'Stop';
                            else
                                // here we are shutting down the connection to the server
                                nsPublish.attachCamera(null);
                                nsPublish.attachAudio(null);
                                nsPublish.publish("null");
                                nsPublish.close();
                                doPublish.label = 'Publish';
    I am then trying to call that function like this
                protected function startloop():void {
                    publish(event);
    But i get the error Access of undefined property event.
    Any ideas on how i can call this function ?  I need to call it as part of a loop against a timer..
    Thanks in advance

    Need more info. Are you using a ViewStack or other navigator container, and trying to access a view that has not been displayed yet, due to deferred instantiation?
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • How to call a function

    As part of my attempts to make FLEX 508 compliant, I've tried several things.  But this question is about basic FLEX in general.  What I'm trying to do is to call a routine (that will someday work and make FLEX compliant I hope).  Here is the basic layout in the mxml file:
      <mx:Script source="/scripts/FSUtil.as" />
      <mx:Script source="/scripts/FSCalc.as" />
      <mx:Script source="/scripts/FSLangSwitch.as" />
      <mx:Script>
          <![CDATA[
              accessibleSet();
          ]]>
      </mx:Script>
    "accessibleSet" is located in the FSUtil.as file.  The error from the invocation above is:
    1180: Call to a possibly undefined method accessibleSet.
    This is what it looks like (note the code creates an error):
    public function accessibleSet():void {
        headerDHSImage.accessibilityProperties.description = 'State of Illinois Department of Human Services logo';
    The error is:
    1120: Access of undefined property headerDHSImage.
    But I don't think the basic idea of calling a function from the script section of an mxml file is affected by this.
    Just for completeness, headerDHSImage is defined in a component called DHSHeader.mxml as:
        <mx:Image id="headerDHSImage"
            source="images/DHSLogo.gif"
            toolTip="State of Illinois Department of Human Services Logo"
            left="5" top="5"/>
    This component is displayed when the application runs so I know that connection is working.
    Recap:
    I want to call a function from the script area of an mxml file, but am not sure of the protocol.
    Thanks,
    Jerry

    > If I understand it at all, then in the mxml application tag you can only refer to functions
    > that are within a naked script tag (only locally).  That is, you can't refer to a function
    > that is in an associated script file via the script source method.
    No, this is incorrect. There is no difference between declaring a function like accessibleSet() within the <Script> tag and declaring it in an AS file included by a <Script> tag. The problem is where you can call that function from. You normally do not write "loose code" in a <Script> tag like
    <Script>
        accessibleSet();
    </Script>
    If you do, it actually becomes part of an autogenerated class initialization ("cinit") method emitted by the compiler, which isn't what you're expecting, because at class initialization time no instances even exist and you can only read and write static vars.
    Another way to understand it is this: When you write an MXML file, you are writing a class. For example, suppose you write MyApp.mxml as
    <mx:Application>
        <mx:Script>
            accessibleSet();
        <mx:Script>
        <mx:Button id="b"/>
    </mx:Application>
    This is more-or-less equivalent to writing the AS class
    public class MyApp extends Application
        accessibleSet();
        var b:Button = new Button();
    If you are familiar with writing classes, you should see the problem here: A class body doesn't normally contain loose function calls or other loose statements. Instead, a class body is supposed to contain 'const', 'var', and 'function' declarations. So you need to call a method like accessibleSet() inside another method -- such as an event handler -- that runs at a well-defined time.
    BTW, you are probably going to confuse yourself further if you continue splitting your code for a single application into multiple AS files which you then include with <Script> tags. All of this code goes into one class and therefore it really belongs either inside the <Script> tag itself or in a single AS file brought in by a single <Script> tag. You need to think in terms of classes, not files.
    Gordon Smith
    Adobe Flex SDK Team

  • Problem in calling AVM1Movie function

    Hello all,
    I have loaded an Action Script 2.0 swf file in Action Script 3.0 file. I want to call a function of  Action Script 2.0 function from  Action Script 3.0 file.
    following is the code i am using.
    Action Script 3.0:
    var loader:Loader=new Loader();
    loader.load(new URLRequest("2.swf"));
    addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.INIT,swfloaded);
    var banerObject;
    function swfloaded(e:Event) {
        banerObject=Object(loader.content);
    btn.addEventListener(MouseEvent.CLICK,clicked);
    function clicked(e:Event){
        banerObject.as2function();
    Action Script 2.0:
    function as2function(){
    trace("function is called");
    Please let me know, how i can call that function.

    I believe you need to make use of LocalConnection to communicate between different version files.  While I am fairly well confused with it, the following may be helpful for you.
    http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html

  • How do you call a function module in a web dynpro application ?

    Why do you delete my postings ?????????????????????????????
    pls see subject
    Edited by: Ilhan Ertas on Apr 1, 2009 4:51 PM
    Edited by: Ilhan Ertas on Apr 1, 2009 4:52 PM

    Its not me deleting them.  Perhaps a different moderator or a technical problem within SCN itself.
    Someone might be concerned about your question because it is very basic.
    You can call a function module from WD the same way you did in any ABAP program - with the CALL FUNCTION syntax.  There is a service call wizard that will generate a matching context and calling code for you - but it is just a helper, code generator.  Everything it does can be done by hand as well (and often better than the generator).

Maybe you are looking for

  • Home Sharing - Can See Computer on Apple TV but Cannot Browse

    I have a Macbook Air (2011) and Apple TV (2nd generation) and I have successfully set up home sharing. I have the ability to select the Apple TV from iTunes on my Macbook Air and use it to play music/movies. However, when trying to browse the compute

  • Blackberry Z 10 Charging Problems

    I Have problems With my B Z10. When i plug in my charging device that came with my B Z10. A tells me i have to use the charging device that came with? but i am using the same charging device* My phone just blacks out and doesnt show how many % are le

  • FF updated, Added Theme, hate it , want to get rid of Themes totally

    FF installed the new update. It asked me if I wanted a theme. I tried one, I do not like it and it makes my page too hard to read. I would like to put my browser back the way it was but cannot figure out how to get rid of themes app. Thank you. == Th

  • /etc/hosts and /etc/inet/hosts

    we're running Sol10x86 11-06 and notice that there's no link between /etc/hosts and /etc/inet/hosts as there has been on some previous versions. /etc/hosts is the only file that contains all of the info for our IPMP configuration, and that seems to b

  • What are the data collection requirements for CAND?

    Please explain the exact data collection requirements for CAND (Connected Analytics for Network Deployment). Thanks