Informix

 View Only
  • 1.  SPL was called by another SPL

    Posted 14 days ago
    is there a way to know if an SPL was called by another SPL?

    Thanks.

    ------------------------------
    Antonio Ferrara
    ------------------------------


  • 2.  RE: SPL was called by another SPL

    Posted 14 days ago

    Antonio:

    I cannot think of any way for an SPL routine to know if it was called by another SPL, no.

    You could create a Global variable and set it before calling another routine then clear it after the routine returns. When the other routine checks the value of the global, if it was called directly by a client the global will not have been set. Other than that, dunno.

    Art



    ------------------------------
    Art S. Kagel, President and Principal Consultant
    ASK Database Management Corp.
    www.askdbmgt.com
    ------------------------------



  • 3.  RE: SPL was called by another SPL

    Posted 14 days ago
    Thanks for the reply.
    Excuse my ignorance, but how do you declare a global variable to the two routines?

    ------------------------------
    Antonio Ferrara
    ------------------------------



  • 4.  RE: SPL was called by another SPL
    Best Answer

    Posted 14 days ago
    Check the Guide to SQL Syntax manual or equivalent online manual page for the SPL DEFINE statement. The description is: 

    Use the DEFINE statement to declare local variables that an SPL routine uses, or to
    declare global variables that can be shared by several SPL routines.

    So:
    DEFINE GLOBAL is_subcall INT DEFAULT 0;
    DEFILE GLOBAL in_transaction INT DEFAULT 0;  -- This may be what you really want, considering your other question.

    You would define that same variable in each routine that needs to know whether it was called from another routine. The caller or the routine that issues the BEGIN WORK would then set the appropriate variable to '1'. On returning from the called routine the caller would clear is_subcall back to 0. Or whichever routine in the process tree issues a COMMIT WORK or ROLLBACK WORK would clear the in_transaction variable.

    Here's the link to the online manual page:
    Declare global variables



    ------------------------------
    Art S. Kagel, President and Principal Consultant
    ASK Database Management Corp.
    www.askdbmgt.com
    ------------------------------



  • 5.  RE: SPL was called by another SPL

    Posted 14 days ago
    Now it is clear to me. Thanks

    ------------------------------
    Antonio Ferrara
    ------------------------------