Defining Variables in the Package Spec [message #685433] |
Thu, 06 January 2022 12:03  |
Duane
Messages: 519 Registered: December 2002
|
Senior Member |
|
|
I think I know this question but I thought I had better ask.
CREATE OR REPLACE package Common as
LineNumber number default 6;
end Common;
CREATE OR REPLACE package body Test as
procedure Test1 is
begin
common.LineNumber := common.LineNumber + 1;
end;
end Test1;
procedure Test2 is
begin
common.LineNumber := common.LineNumber * 3;
.
.
.
common.LineNumber := common.LineNumber + 1;
end;
end Test2;
end Test;
If Test1 and Test2 are run close to one another then the common.LineNumber variable would be shared between the two procedures and colliding and not producing the numbers that each procedure would produce if the variable was defined within the procedure.
Basically, the common.LineNumber variable would be unpredictable if two or more procedures were running and modifying the variable at the same time.
Just want to confirm my thoughts.
|
|
|
|
Re: Defining Variables in the Package Spec [message #685435 is a reply to message #685434] |
Thu, 06 January 2022 14:29   |
Duane
Messages: 519 Registered: December 2002
|
Senior Member |
|
|
Ah, thank you.
I actually thought that was the case but I started to have my doubts so I thought the variable would be colliding when multiple procedures were accessing the same variable. That's not what I wanted.
I want each procedure to have it's own reference to that variable when it's called. If I have ten procedures running at around the same time then I want ten separate variables being used by those ten procedures.
|
|
|
|