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------------------------------
Original Message:
Sent: Wed May 11, 2022 06:58 AM
From: Antonio Ferrara
Subject: SPL was called by another SPL
Thanks for the reply.
Excuse my ignorance, but how do you declare a global variable to the two routines?
------------------------------
Antonio Ferrara
Original Message:
Sent: Wed May 11, 2022 06:38 AM
From: Art Kagel
Subject: SPL was called by another SPL
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
Original Message:
Sent: Wed May 11, 2022 05:51 AM
From: Antonio Ferrara
Subject: SPL was called by another SPL
is there a way to know if an SPL was called by another SPL?
Thanks.
------------------------------
Antonio Ferrara
------------------------------
#Informix