cancel
Showing results for 
Search instead for 
Did you mean: 

call procedures wait for each other

Former Member
0 Kudos
2,617

When I call the following procedure from 2 different connections in ISQL, one waits for another for completion before returning to isql. This was tried on ASA 10, 11, 12.

Create the following procedure.

create procedure CSEnter() 
begin
  declare i int;

  message 'enter scroll for ' to client;
  set i = 0;

  while i < 3 loop
    message 'begin while ' to client;
    waitfor delay '0:0:10';
    message 'end while ' to client;

    set i = i + 1;
  end loop;

  message 'leave scroll for ' to client;
end;
  1. Start ISQL and connect to database;
  2. Start another ISQL and connect to datbase;
  3. In first ISQL execute call csenter();
  4. Wait for about 10s
  5. In second ISQL execute call csenter();
  6. In first ISQL in message window you'll see the message 'leave scroll for ' and ISQL will wait till second finishes, can someone explain why???

Accepted Solutions (0)

Answers (1)

Answers (1)

jan24
Explorer
0 Kudos

I tested (ASA11 and ISQLc) your interesting submission, but the result is almost exactly the same.
I modified the procedure slightly.

if exists (select 1 from sysprocedure where proc_name='CSEnter') then drop procedure CSEnter end if;
create procedure CSEnter()
begin
declare i int;
declare @t varchar(32);
set @t = current timestamp;
message current timestamp || ' Enter scroll for ' to client;
set i = 0;
while i < 3 loop
  message current timestamp || ' Begin waiting ' to client;
  waitfor delay '0:0:10';
  message current timestamp || ' End waiting ' to client;
  set i = i + 1;
end loop;
message current timestamp || ' Leave scroll for ' to client;
message DATEDIFF(millisecond, current timestamp, @t) || ' Execution time' to client;
end;

VolkerBarth
Contributor
0 Kudos

Would be interesting if you change "to client" to "to log" (possibly only inside the loop) - it may be that the client side just has to be "ready" to accept messages from the server, and that this may interfere here whereas writing to the servers's console log would be done immediately. Just guessing:)