Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Antonio Ferrara asked how an SPL could tell whether another SPL called it. Art Kagel knew no direct way and suggested a DEFINE GLOBAL variable set by the caller before the call and cleared after. He showed example declarations and pointed to the DEFINE statement manual page. Antonio said it was clear.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Antonio Ferrara — source: IBM Community (ConnectedCommunity.org) Informix forum
is there a way to know if an SPL was called by another SPL?
Thanks.
------------------------------
Antonio Ferrara
------------------------------
#Informix
↪ replying to Antonio Ferrara
Art Kagel — source: IBM Community (ConnectedCommunity.org) Informix forum
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
------------------------------
↪ replying to Art Kagel
Antonio Ferrara — source: IBM Community (ConnectedCommunity.org) Informix forum
Thanks for the reply.
Excuse my ignorance, but how do you declare a global variable to the two routines?
------------------------------
Antonio Ferrara
------------------------------
↪ replying to Antonio Ferrara
Art Kagel — source: IBM Community (ConnectedCommunity.org) Informix forum
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
------------------------------
↪ replying to Art Kagel
Antonio Ferrara — source: IBM Community (ConnectedCommunity.org) Informix forum
Now it is clear to me. Thanks
------------------------------
Antonio Ferrara
------------------------------
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.