on 2022 Mar 16 6:30 AM
create or replace procedure mytest1 () begin call logproc (@@procid); end; create or replace procedure mytest2 () begin declare var1 unsigned int; set var1 = (select @@procid); call logproc (var1); end; create or replace procedure logproc (@procid unsigned int) begin message ('call from ' || (select proc_name from sysprocedure where proc_id =@procid)); end; -------------- -------------- call mytest1 ()--call from logproc call mytest2 ()--call from mytest2
Could someone explain this phenomen, or I see it false!! (sql anywhere 17.0.09, build 4803)
Request clarification before answering.
@@procid has behaved this way since (at least) SQL Anywhere Version 6.
The Help says "@@procid is the stored procedure ID of the currently executing procedure which apparently means the called procedure for @@procid passed as an argument.
The following code demonstrates this because @@procid - 10 is evaluated using logproc's @@procid.
create procedure mytest1() begin MESSAGE STRING ( @@VERSION, ' mytest1 @@procid = ', @@procid ) TO CONSOLE; call logproc (@@procid - 10 ); end; create procedure logproc ( passed_value unsigned int ) begin MESSAGE STRING ( @@VERSION, ' logproc passed_value = ', passed_value ) TO CONSOLE; MESSAGE STRING ( @@VERSION, ' logproc @@procid = ', @@procid ) TO CONSOLE; MESSAGE STRING ( @@VERSION, ' logproc @@procid -10 = ', @@procid - 10 ) TO CONSOLE; end; CALL mytest1 (); 17.0.9.4882 mytest1 @@procid = 491 17.0.9.4882 logproc passed_value = 482 17.0.9.4882 logproc @@procid = 492 17.0.9.4882 logproc @@procid -10 = 482 6.0.4.3594 mytest1 @@procid = 217 6.0.4.3594 logproc passed_value = 208 6.0.4.3594 logproc @@procid = 218 6.0.4.3594 logproc @@procid -10 = 208
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.