Can a function module call another function module

Can a function module call another function module:-
  within the same function group
(ii)  within different function  groups

Hi,
We can call function from another function. If there is a function which is like a calculator and all the operations are from different functions then we have to call the functions from the calculator function for different functions.
If all the function are from same function group, Then the data is globally available to all the functions with in the group.
Otherwise we have to declare the data definitions for each of the functions if they are in different function groups.  
Yes it is possible to call a function module from another function module:-
within the same function group
(ii) within different function groups
Reward.

Similar Messages

  • Calling another function if upate statement fails

    Hi there,
    I have written an update procedure and insert procedure. Is there a way of calling another function if the update statement fails? Thanks a lot for your help.
    Chris
    procedure update_costing(in_period in DATE,
                   in_project_id IN VARCHAR2,
                   in_user_id IN VARCHAR2,
                   in_thu IN VARCHAR2,
                   in_fri IN VARCHAR2,
                   in_sat IN VARCHAR2,
                   in_sun IN VARCHAR2,
                   in_mon IN VARCHAR2,
                   in_tue IN VARCHAR2,
                   in_wed IN VARCHAR2)
         UPDATE TBL_COSTING
              SET
                   HOURS_THU = to_date (in_thu, 'HH24:MI'),
                   HOURS_FRI = to_date (in_fri, 'HH24:MI'),
                   HOURS_SAT = to_date (in_sat, 'HH24:MI'),
                   HOURS_SUN = to_date (in_sun, 'HH24:MI'),
                   HOURS_MON = to_date (in_mon, 'HH24:MI'),
                   HOURS_TUE = to_date (in_tue, 'HH24:MI'),
                   HOURS_WED = to_date (in_wed, 'HH24:MI'),
                   WHERE PERIOD = in_period
         AND PROJECT_ID = in_project_id
         AND USER_ID = in_user_id;
    EXCEPTION
    --CALLL HERE THE INSERT FUNCTION WITH SAME DATAMEMBERS
    SOMETHING LIKE THIS---
    WHEN others then
         insert_costing(in_period, in_project_id, in_user_id ,in_thu,in_fri,in_sat,in_sun,in_mon,in_tue,in_wed ,in_submit);
    COMMIT;
    END update_costing;

    begin
    UPDATE statement
    IF SQL%ROWCOUNT =0
    then
    INSERT statement|procedure
    end if;
    end;
    /Hi,
    i have a simple doubt over here, i read somewhere that cursor attributes can be used only as long as the cursor is open, then in the above case whiel doing the update operation, oracle implicitly will open an cursor and will do the operation and then will close the cursor, then how does SQL%ROWcount works???please revert...
    cheere

  • Function call another function variable

    Is it possible to call another function variable?
    Below is my Script:
    f2();
    function f1() { 
      var v2 = 1; 
    function f2(v2) { 
      var v3= 2; 
      alert(v2);

    Hi creativejoan0425,
    Some additional notes:
    > Is it possible to call access another function variable?
    No, it isn't. A local variable only lives in the scope of the function (body) where it is declared. In that sense any local variable should be considered private—in OOP terms.
    pixxxel schubser's solution is based on setting a global scope for the variable myA, so it is visible from every place of your code.
    Another solution could be implemented using JS closure mechanism. You can create a local scope (in an anonymous function which is executed once) then return your main function and additional helpers from that scope. All inner functions have then access to the local variables that have been declared in the scope. For example, you can create your function f1 and attach a getter function to it, as follows:
    var f1 = (function(/*anonymous*/__)
        // Local variable to be nested in the closure
        var v1;
        (__ = function(/*optional init value*/x)
            // Here is your *actual* function
            // do what you want with v1
            v1 = 'undefined'!=typeof x ? x : Math.random();
        ).getVar = function()
            // Here is your getter
            return v1;
        return __;
    var f2 = function()
        alert( f1.getVar() );
    // Process
    f1('init');
    f2();           // => 'init'
    f1();
    f2();           // => some random number
    f1();
    f2();           // => another random number
    // etc
    This way v1 remains almost private but the outer code can read it through f1.getVar().
    Anyway this seems to me a complicate approach for a basic script that probably does not require high security level. Another option, really easy to set up, is to use the fact that a function is an object. Instead of declaring a local variable, just handle v1 as a (public) member of f1, as follows:
    var f1 = function F(/*optional init*/x)
        // Do something with F.var
        F.v1 = 'undefined'!=typeof x ? x : Math.random();
    var f2 = function()
        alert( f1.v1 );
    f1('init');
    f2();          // => 'init'
    f1();
    f2();          // => some random number
    f1();
    f2();          // => another random number
    That's it!
    > why every function need to return?
    No, return is not required. By default, any function that has no return statement will simply return undefined.
    @+
    Marc

  • Need help to call a simple function from within another function?

    I created a movieclip which has a function in its one and only frame.
    function testx() {
    x = x+2};
    This movieclip is in the main timeline (in its own layer).
    In another layer on the timeline I have created a single keyframe with a button instance called myBtn
    myBtn.onRelease = function() {
    var x
    x =2
    testx(2);
    trace (x);
    What I want to do is call the function in the movieclip frame from the button press function. However, I can't seem to reference it properly.
    Can anyone help me to basically call a simple function from within another function?

    Yes am using CS4.  Have saved it as CS3 now.  Ok the file is somewhat complicated and what I am testing is not what I ultimately want to do but if I can pass that variable I can figure it out.  In terms of describing the file I think the only parts of importance are what I put in my previous post (please let me know if there is something I should be telling you that I have missed).  I am 99.9% sure that I am using the correct instance name.
    Scene1 Layer3 Frame1 has the function call for the button.
    myBtn.onRelease = function() {
    var x
    x = 2
    testx(2);
    trace (x);
    Slideshow layer //Actions Frame1 has the function
    function testx(x) {
    x = x+2};
    thank you so much for helping me.

  • Call function and call customer function

    Hi
    Can anybody let me know what is the difference between CALL FUNCTION AND CALL CUSTOMER- FUNCTION .
    i know call customer- function is used while we r working on user exits .
    but is their any specific reason of difference ...
    Thanks

    CALL CUSTOMER-FUNCTION function_exit parameter_list.
    Effect
    This statement can be used in programs delivered by SAP. It includes the function module exit specified in function_exit . The function module exit is a customer exit. In an SAP program, it enables you to call a function module provided by SAP and implemented by the customer.
    The indicator function_exit must be a three-digit text field literal. A function module exit is specified by SAP using the transaction SMOD and can be activated using the transaction CMOD in customer systems.
    Specifications by SAP
    An empty or partly implemented function module must be assigned to the function module exit using the transaction SMOD. The name of the function module consists of EXIT_, the program name, which contains the statement CALL CUSTOMER-FUNCTION, and the three-digit indicator in function_exit. The interface of the function module is completely defined by SAP.
    Activation in the customer system
    The transaction CMOD enables the customer to implement the source code of the function module within an enhancement project and to activate the function module exit. If the function module exit is not activated, the statement CALL CUSTOMER-FUNCTION is ignored. If the function module is activated, the corresponding function module is called in the same way as the general function module call.
    Syntax and meaning of the parameter_list for the assignment of the actual parameters to formal parameters and for the exception handling are the same as in a general function module call. It is not possible to dynamically fill the interface.
    CALL FUNCTION func
    Syntax
    CALL FUNCTION func { parameter_list
                       | parameter_tables }.
    Effect
    This statement calls the function module specified in func. The identifier func must be a character-type data object, which contains the name of a function module in uppercase letters during the statement execution. Each function module of an SAP system has a unique name, which is why you need not specify the function group.
    Use additions parameter_list or parameter_tables (as of release 6.10) to statically or dynamically assign actual parameters to the formal parameters of the function module and return values to the non-class-based exceptions.
    Note
    If the name of a function module is specified by a constant or as a literal, the extended syntax check can check the statement.
    Exceptions
    Catchable Exceptions
    CX_SY_DYN_CALL_ILLEGAL_FUNC
    Cause: The called function is known but not active.
    Runtime Error: CALL_FUNCTION_NOT_ACTIVE
    Cause: The called function is unknown.
    Runtime Error: CALL_FUNCTION_NOT_FOUND
    CX_SY_DYN_CALL_ILLEGAL_TYPE
    Cause: The type of the actual parameter does not fulfill the requirements of the function interface.
    Runtime Error: CALL_FUNCTION_CONFLICT_GEN_TYP
    Cause: The actual parameter does not have the length expected by the function.
    Runtime Error: CALL_FUNCTION_CONFLICT_LENG
    Cause: The actual parameter does not have the type expected by the function.
    Runtime Error: CALL_FUNCTION_CONFLICT_TYPE
    Cause: Only those functions can be called in the update task that are intended for it.
    Runtime Error: CALL_FUNCTION_NO_VB
    Cause: An actual parameter does not fulfill the alignment requirements of the respective formal parameter.
    Runtime Error: CALL_FUNCTION_WRONG_ALIGNMENT
    CX_SY_DYN_CALL_PARAM_MISSING
    Cause: The function expects a parameter, which has not been passed by the caller.
    Runtime Error: CALL_FUNCTION_PARM_MISSING
    CX_SY_DYN_CALL_PARAM_NOT_FOUND
    Cause: The caller has passed a parameter, which is not known to the function.
    Runtime Error: CALL_FUNCTION_PARM_UNKNOWN
    plz reward points if it helps

  • 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 a loaded SWF call a function that lives in the parent?

    I'm building a pretty simple Flash site in AS3. There is a
    main movie (main.swf) that simply loads different swfs via buttons
    on a main nav bar. The user clicks on a MC in "main.swf" and a
    function is called, loadMyContent("section1.swf"), is called and it
    animates in nicely. Other buttons use the same function, loading
    section2.swf, section3.swf, etc.
    I've defined how "loadMyContent()" works in the the main
    movie's document class file. It's all working fine when I just need
    to load content from a user action from the buttons that live in
    "main.swf". I want to call that same "loadContent" function from
    within "section1.swf" and have "main.swf" run it's "loadContent"
    fuction, but I can't seem to figure out how to make a child call a
    function that lives in the parent.
    Is there any way of having my child do this?
    I have a suspicion I may have to define that "loadContent"
    somewhere else, but I'm a little stumped now. I'm not really
    familiar with design patterns yet, although I want to get an
    understanding of them sometime soon. Can anyone offer some help
    with my immediate need or suggest a route to a solution?
    Thanks.

    kglad,
    Thank you very much! That worked perfectly. My section1 FLA
    is now compiling it's SWF without complaint.
    In case someone else is following this, the exact code I
    ended up using to cast "this.parent.parent" as a MovieClip is:
    MovieClip(this.parent.parent).loadMyContent("section2.swf");
    The discussion I think kglad is referencing is
    this
    discussion. If that's not it, just let me know. Again, kglad,
    thank you!

  • How can a custom class call a function in "parent" class?

    Say I have an application (ultrasimplified):
    public class myApp {
    myClass mc;
    boolean foo=false;
    public static void main(String[] args) {
    mc = new myClass();
    public static void myFunc(boolean blah) {
    foo=blah;
    in a separate .java file where my questions lie:
    public class myClass {
    boolean bar=true;
    public void myClass() {
    // this is wrong, but how would I do this:
    foo = bar; // foo in myApp set to true
    // or how would I call "myFunc()" in myApp from this class:
    myFunc(bar);
    my problem is that I've created a new class that I share between two applications so I could share the code. However, I want this class I created to call a function in the application class that instanciated it. Or alternatively, I would like to set a variable in the class that instanciated myClass.
    How would go about this? I've used the "this" parameter in applets to pass the parent class to an inner class, but main() in applications doesn't allow the non-static "this":
    myClass my = new myClass(this);
    Is there something similar I can do?

    You can let MyApp implement an interface and refer to that object in MyClass:
    class MyApp implements Something {
    main() {
    MyApp app = new MyApp();
    MyClass mc = new MyClass(app);
    public void foo() { }
    class MyClass {
    Something app;
    MyClass(Something app) {
    this.app = app;
    app.foo();
    interface Something {
    public void foo();
    Better yet, you can let MyApp extend an abstract class that defines foo(). Then MyApp can override the foo() method. If later on, the abstract class needs to add a bar() method then default implementation can be done in the abstract class. If you make it an interface then all implementing classes will have to be updated to implement the new method.

  • How to call an App Module from another App Module?

    Here are the settings for my project.
    MyApplication (Application)
    Model1 (Project) : Has connection settings to connect to schema1
    Model2 (Project) : Has connection settings to connect to schema2
    ViewController (Project) : View project
    How do I call Model2 from Model1 ? I tried calling findApplicationModule but that did not work.
    Can I get access to the AppModule from JNDI tree? How else can I get access to Model2 from Model1?
    Thanks

    This is the code that is getting called from App Module 1. The first method, test1, throws an error where as test2 is successful. Do you see any obvious errors in the code?
    public String test1() {
    System.out.println("This is test1");
    String amDef = "org.model.service.HrService";
    String config = "HrServiceLocal";
    ApplicationModule am2 = (ApplicationModule ) Configuration.createRootApplicationModule(amDef,config);
    HrServiceImpl am3 = (HrServiceImpl)am2;
    am3.test123();
    Configuration.releaseRootApplicationModule(am2, true);
    //return am2;
    return "test1";
    Error:
    Internal Server Error (Caught exception while handling request: oracle.jbo.ConfigException: JBO-33005: Configuration HrServiceLocal not found)
    public String test2() {
    String AMDefName = "org.model.service.HrService";
    Hashtable env = new Hashtable(2);
    env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
    env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
    HrService am = null;
    try { 
    InitialContext ic = new InitialContext(env);
    ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(AMDefName);
    am = (HrService)home.create();
    String retString = am.test123();
    System.out.println("Value from the first application module=" + retString);
    catch (NamingException nex) {  /* Handle the error here if you don't find it */
    System.out.println("Naming exception " + nex);
    Configuration.releaseRootApplicationModule(am, true);
    return "test2";
    successful
    Thanks
    Mike

  • Calling another function from run function

    Dear All,
    Below is my skeleton of multithread programme. I am now going to implelment a new function to do the processing rather then over crowding my run fuctnion. Where exactly must I define the myNewFunction in the same class as ConnectionHandler or create a new class? What would be right? I saw some place you need to put the word static what is it?
    class ConnectionHandler implements Runnable {
         public void run() {
          callMyNewFunction()
    }

    Dear Jverd,
    Basically below is code skeleton. So below the big T is new Thread(new ConnectionHandler(socketConn1)).start(); correct and the small t is the run function correct? So my question is that if via the run function I call some other function will that have impact on the memory allocation or shall I leave all my codes in the run function itself? I hope I am clearer now.
    public class commServer {
       public static void main(String[] args) {
          try {
               final ServerSocket serverSocketConn = new ServerSocket(9000);
              while (true)
         try
         Socket socketConn1 = serverSocketConn.accept();
                    new Thread(new ConnectionHandler(socketConn1)).start();                          
         catch(Exception e)
         System.out.println("MyError:Socket Accepting has been caught in main loop."+e.toString());
         e.printStackTrace(System.out);
          catch (Exception e)
             System.out.println("MyError:Socket Conn has been caught in main loop."+e.toString());
             e.printStackTrace(System.out);
             //System.exit(0);
    class ConnectionHandler implements Runnable {
        private Socket receivedSocketConn1;
        ConnectionHandler(Socket receivedSocketConn1) {
          this.receivedSocketConn1=receivedSocketConn1;
       //@Override
       public void run() {
          Connection dbconn = null;
          BufferedWriter w = null;
          BufferedReader r = null;
          try {
             PrintStream out = System.out;
                BufferedWriter fout = null;
             w =  new BufferedWriter(new OutputStreamWriter(receivedSocketConn1.getOutputStream()));
             r = new BufferedReader(new InputStreamReader(receivedSocketConn1.getInputStream()));
             int m = 0, count=0;
             String line="";
             String n="";
             //w.write("$PA\n");
             //w.flush();
             while ((m=r.read()) != -1)
                      ///**DB processing here.
                      n="";
          catch (IOException ex) 
               System.out.println("MyError:IOException has been caught in in the main first try");
               ex.printStackTrace(System.out);
          finally
            try
                 if ( w != null )
                        w.close();
                 else
                      System.out.println("MyError:w is null in finally close");
            catch(IOException ex){
               System.out.println("MyError:IOException has been caught in w in finally close");
               ex.printStackTrace(System.out);
    }

  • Passing function name into another function?

    Hi
    I have a movieclip prototype thats scales and moves any
    movieclips depending
    on the parameters passed in. I want to be able to pass in a
    function name
    that is executed when the main function has finished. The
    problem is the
    line of code that calls the main function executes the
    function name that I
    m trying to pass in as a parameter. Is there something I m
    missing?
    see my code below:
    "mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
    -100,
    mcMainAnimation._xscale, -30, 50,moveToX());"
    MovieClip.prototype.moveFadeTransform = function(t, oldY,
    diffY, oldScale,
    newScale, tTime, funcToCall) {
    this.onEnterFrame = function() {
    t++;
    if (t<=tTime) {
    this._y = easeIn(t, oldY, diffY, tTime);
    this._xscale = easeIn(t, oldScale, newScale, tTime);
    this._yscale = easeIn(t, oldScale, newScale, tTime);
    } else {
    t = 0;
    funcToCall;
    this.onEnterFrame = null;
    moveToX = function () {
    trace("called");
    Thank in advance
    Shaun

    Hi!
    Try to modify code to:
    mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
    -100,
    mcMainAnimation._xscale, -30, 50,moveToX);"
    ... so don't use () at end of function. That should do the
    trick.
    Also, you need to add the () to funcToCall, so that instead
    of:
    t = 0;
    funcToCall;
    this.onEnterFrame = null;
    you should have
    t = 0;
    funcToCall();
    this.onEnterFrame = null;
    /Jensen/
    "forums.macromedia.com" <[email protected]>
    wrote in message
    news:e6m428$qa0$[email protected]..
    > Hi
    >
    > I have a movieclip prototype thats scales and moves any
    movieclips
    > depending on the parameters passed in. I want to be able
    to pass in a
    > function name that is executed when the main function
    has finished. The
    > problem is the line of code that calls the main function
    executes the
    > function name that I m trying to pass in as a parameter.
    Is there
    > something I m missing?
    >
    > see my code below:
    >
    > "mcMainAnimation.moveFadeTransform(0,
    mcMainAnimation._y, -100,
    > mcMainAnimation._xscale, -30, 50,moveToX());"
    >
    > MovieClip.prototype.moveFadeTransform = function(t,
    oldY, diffY, oldScale,
    > newScale, tTime, funcToCall) {
    > this.onEnterFrame = function() {
    > t++;
    > if (t<=tTime) {
    > this._y = easeIn(t, oldY, diffY, tTime);
    > this._xscale = easeIn(t, oldScale, newScale, tTime);
    > this._yscale = easeIn(t, oldScale, newScale, tTime);
    > } else {
    > t = 0;
    > funcToCall;
    > this.onEnterFrame = null;
    > }
    > };
    > };
    >
    > moveToX = function () {
    > trace("called");
    > }
    >
    >
    > Thank in advance
    >
    > Shaun
    >

  • How to load kernel module before another kernel module?

    I have an Iomega ZIP 100 parallel port drive and need module imm to be loaded before lp module. But I don't know how to do this. Simple adding these modules in rc.conf in MODULES section in the correct order doesn't work. I also realized that udev loads lp module, but I don't know how to make udev load this module before or after other modules.
    Last edited by kotyz (2007-06-24 13:58:15)

    or in /etc/mkinitcpio.conf :
    # MODULES
    # The following modules are loaded before any boot hooks are
    # run.  Advanced users may wish to specify all system modules
    # in this array.  For instance:
    #     MODULES="piix ide_disk reiserfs"
    MODULES=""
    and make a new initrd image with mkinitcpio -g /boot/newkernel26.img ,edit menu.lst and reboot

  • SOLVED: How can I use or call a function that returns %ROWTYPE?

    Hi
    edit: you can probably skip all this guff and go straight to the bottom...In the end this is probably just a question of how to use a function that returns a %rowtype.  Thanks.
    Currently reading Feuerstein's tome, 5th ed. I've downloaded and run the file genaa.sp, which is a code generator. Specifically, you feed it a table name and it generates code (package header and package body) that will create a cache of the specified table's contents.
    So, I ran:
    HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\OPP5.WEB.CODE\OPP5.WEB.CODE\genaa.sp"
    749  /
    Procedure created.
    HR@XE> exec genaa('EMPLOYEES');which generated a nice bunch of code, viz:
    create or replace package EMPLOYEES_cache is
        function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE) return HR.EMPLOYEES%ROWTYPE;
        function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE) return HR.EMPLOYEES%ROWTYPE;
        procedure test;
    end EMPLOYEES_cache;
    create or replace package body EMPLOYEES_cache is
        TYPE EMPLOYEES_aat IS TABLE OF HR.EMPLOYEES%ROWTYPE INDEX BY PLS_INTEGER;
        EMP_EMP_ID_PK_aa EMPLOYEES_aat;
        TYPE EMP_EMAIL_UK_aat IS TABLE OF HR.EMPLOYEES.EMPLOYEE_ID%TYPE INDEX BY HR.EMPLOYEES.EMAIL%TYPE;
        EMP_EMAIL_UK_aa EMP_EMAIL_UK_aat;
        function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE)
            return HR.EMPLOYEES%ROWTYPE is
            begin
                return EMP_EMP_ID_PK_aa (EMPLOYEE_ID_in);
            end;
        function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE)
            return HR.EMPLOYEES%ROWTYPE is
            begin
                return EMP_EMP_ID_PK_aa (EMP_EMAIL_UK_aa (EMAIL_in));
            end;
        procedure load_arrays is
            begin
                FOR rec IN (SELECT * FROM HR.EMPLOYEES)
                LOOP
                    EMP_EMP_ID_PK_aa(rec.EMPLOYEE_ID) := rec;
                    EMP_EMAIL_UK_aa(rec.EMAIL) := rec.EMPLOYEE_ID;
                end loop;
            END load_arrays;
        procedure test is
            pky_rec HR.EMPLOYEES%ROWTYPE;
            EMP_EMAIL_UK_aa_rec HR.EMPLOYEES%ROWTYPE;
            begin
                for rec in (select * from HR.EMPLOYEES) loop
                    pky_rec := onerow (rec.EMPLOYEE_ID);
                    EMP_EMAIL_UK_aa_rec := onerow_by_EMP_EMAIL_UK (rec.EMAIL);
                    if rec.EMPLOYEE_ID = EMP_EMAIL_UK_aa_rec.EMPLOYEE_ID then
                        dbms_output.put_line ('EMP_EMAIL_UK  lookup OK');
                    else
                        dbms_output.put_line ('EMP_EMAIL_UK  lookup NOT OK');
                    end if;
                end loop;
            end test;
        BEGIN
            load_arrays;
        end EMPLOYEES_cache;
    /which I have run successfully:
    HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\EMPLOYEES_CACHE.sql"
    Package created.
    Package body created.I am now trying to use the functionality within the package.
    I have figured out that the section
        BEGIN
            load_arrays;
        end EMPLOYEES_cache;
    /is the initialization section, and my understanding is that this is supposed to run when any of the package variables or functions are referenced. Is that correct?
    With that in mind, I'm trying to call the onerow() function, but it's not working:
    HR@XE> select onerow(100) from dual;
    select onerow(100) from dual
    ERROR at line 1:
    ORA-00904: "ONEROW": invalid identifier
    HR@XE> select employees_cache.onerow(100) from dual;
    select employees_cache.onerow(100) from dual
    ERROR at line 1:
    ORA-06553: PLS-801: internal error [55018]
    HR@XE> select table(employees_cache.onerow(100)) from dual;
    select table(employees_cache.onerow(100)) from dual
    ERROR at line 1:
    ORA-00936: missing expressionHe provides the code genaa.sp, and a very brief description of what it does, but doesn't tell us how to run the generated code!
    Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
    So I try wrapping the call in an exec:
    HR@XE> exec select employees_cache.onerow(100) from dual;
    BEGIN select employees_cache.onerow(100) from dual; END;
    ERROR at line 1:
    ORA-06550: line 1, column 30:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PLS-00428: an INTO clause is expected in this SELECT statement
    HR@XE> exec select table(employees_cache.onerow(100)) from dual;
    BEGIN select table(employees_cache.onerow(100)) from dual; END;
    ERROR at line 1:
    ORA-06550: line 1, column 14:
    PL/SQL: ORA-00936: missing expression
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored
    HR@XE> exec employees_cache.onerow(100)
    BEGIN employees_cache.onerow(100); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00221: 'ONEROW' is not a procedure or is undefined
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignoredNo joy.
    Of course, now that I'm looking at it again, it seems that the way to go is indicated by the first error:
    PLS-00428: an INTO clause is expected in this SELECT statement
    So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
    I've had a stab at this, but still, no joy:
    create or replace procedure testcache is
        emp employees%rowtype;
        begin
            select employees_cache.onerow(100) from dual into emp;
            dbms_output.put_line('Emp id: ' || emp.employee_id);
        end testcache;
    show errors
    HR@XE> @testcache.sql
    Warning: Procedure created with compilation errors.
    Errors for PROCEDURE TESTCACHE:
    LINE/COL ERROR
    4/9      PL/SQL: SQL Statement ignored
    4/54     PL/SQL: ORA-00933: SQL command not properly ended
    HR@XE>Have a feeling this should be really easy. Can anybody help?
    Many thanks in advance.
    Jason
    Edited by: 942375 on 08-Feb-2013 11:45

    >
    Ha, figured it out
    >
    Hopefully you also figured out that the example is just that: a technical example of how to use certain Oracle functionality. Unfortunately it is also an example of what you should NOT do in an actual application.
    That code isn't scaleable, uses expensive PGA memory, has no limit on the amount of memory that might be used and, contrary to your belief will result in EVERY SESSION HAVING ITS OWN CACHE of exactly the same data if the session even touches that package.
    Mr. Feuerstein is an expert in SQL and PL/SQL and his books cover virtually all of the functionality available. He also does an excellent job of providing examples to illustrate how that functionality can be combined and used. But the bulk of those examples are intended solely to illustrate the 'technical' aspects of the technology. They do not necessarily reflect best practices and they often do not address performance or other issues that need to be considered when actually using those techniques in a particular application. The examples show WHAT can be done but not necessarily WHEN or even IF a given technique should be used.
    It is up to the reader to learn the advantages and disadvantages of each technicalogical piece and determine when and how to use them.
    >
    Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
    >
    That is correct. To be used by SQL you would need to create SQL types using the CREATE TYPE syntax. Currently that syntax does not support anything similar to %ROWTYPE.
    >
    So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
    >
    NO! That is a common misconception. Each session has its own set of package variables. Any session that touches that package will cause the entire EMPLOYEES table to be queried and stored in a new associative array specifically for that session.
    That duplicates the cache for each session using the package. So while there might be some marginal benefit for a single session to cache data like that the benefit usually disappears if multiple sessions are involved.
    The main use case that I am aware of where such caching has benefit is during ETL processing of staged data when the processing of each record is too complex to be done in SQL and the records need to be BULK loaded and the data manipulated in a loop. Then using an associative array as a lookup table to quickly get a small amount of data can be effective. And if the ETL procedure is being processed in parallel (meaning different sessions) then for a small lookup array the additional memory use is tolerable.
    Mitigating against that is the fact that:
    1. Such frequently used data that you might store in the array is likely to be cached by Oracle in the buffer cache anyway
    2. Newer versions of Oracle now have more than one cache
    3. The SQL query needed to get the data from the table will use a bind variable that eliminates repeated hard parsing.
    4. The cursor and the buffer caches ARE SHARED by multiple sessions globally.
    So the short story is that there would rarely be a use case where ARRAYs like that would be preferred over accessing the data from the table.

  • How to get the main funciton name when calling another function inside?

    for eg, one RFC named A,inside A,a funtion B is called.when the processing is at B now,how can i get the main RFC name(A)?
    any help will be much appricated.

    > just see SM50,there is a column called 'Report',it shows the program id the proess is now processing.but i don't know its main program or say it 'the process's first excuting program',how can i get it programmatically?
    I'm still not sure to understand. The program in SM50 is the current main program (not the first). It is stored in SY-REPID system variable. Or use this code:
    DATA lt_callstack_long TYPE abap_callstack.
    DATA ls_callstack_long TYPE LINE OF abap_callstack.
    CALL FUNCTION 'SYSTEM_CALLSTACK'
          IMPORTING
            callstack    = lt_callstack_long.
    READ TABLE lt_callstack_long INDEX 1 INTO ls_callstack_long.
    WRITE : / 'current main program is:', ls_callstack_long-mainprogram.
    If you want to know the frame program (the first called), use SY-CPROG, or use this code:
    DATA lt_callstack_long TYPE abap_callstack.
    DATA ls_callstack_long TYPE LINE OF abap_callstack.
    CALL FUNCTION 'SYSTEM_CALLSTACK'
          IMPORTING
            callstack    = lt_callstack_long.
    " read last line = first called program
    DESCRIBE TABLE lt_callstack_long. "to make sy-tfill = number of lines
    READ TABLE lt_callstack_long INDEX sy-tfill INTO ls_callstack_long.
    WRITE : / 'First main program is:', ls_callstack_long-mainprogram.

  • Temp table gets deleted when calling another function

    Hello Everyone
    I am using temporary tables which gets deleted on commit to workaround a multiset union (which doesnt work on Oracle 9). Now, this table somehow gets deleted (the content) during execution of my stored procedure but there is no delete or commit statement.
    Here is what I am doing
    start
    delete temp table (just to be sure)
    prepare array
    loop array {
    output count of temp table
    a = some other function(...)
    output count of temp table
    insert stuff I need to temp table
    output count of temp table
    end
    The output is giving me (example). The correct result would be 140 at the end
    0
    0
    100
    0
    40
    I checked all further function calls, there is no delete or commit, just some objects are created (and collections) which are then processed and returned.
    Could it be that there is a automatic commit or something like that?
    Thanks
    Edited by: maschlegel on Jan 26, 2009 6:36 AM
    Edited by: maschlegel on Jan 26, 2009 6:37 AM
    Edited by: maschlegel on Jan 26, 2009 6:38 AM

    just some objects are created (and collections) which are then processed and returneAll DDL statements issue COMMITs implicitly - once before the statement is processed and once after. (so any data changes are committed even if the DDL statement fails).
    This is just one reason why it is such a bad idea to stick DDL statements in the middle of transactions.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

Maybe you are looking for