cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

"CREATE VARIABLE" statement within a stored procedure: error

2,346

SQL Anywhere Network Server Version 12.0.1.3967

I use the example from the documentation on CREATE VARIABLE statement:
"This example creates a variable named v1 and sets its value to 10, regardless of whether or not the v1 variable already exists.
CREATE OR REPLACE VARIABLE v1 INT = 10;"

1)
create procedure "dba"."CREATE_VARIABLE_statement"()
begin
CREATE OR REPLACE VARIABLE v1 INT = 10;
end
;
call CREATE_VARIABLE_statement();
select v1;

Result = NULL

But:
2a)
create procedure "dba"."CREATE_VARIABLE_statement"()
begin
execute immediate 'CREATE OR REPLACE VARIABLE v1 INT = 10';
end
;
call CREATE_VARIABLE_statement();
select v1;

Result = 10

2b)
create procedure "dba"."CREATE_VARIABLE_statement"()
begin
CREATE OR REPLACE VARIABLE v1 INT;
set v1 = 10;
end
;
call CREATE_VARIABLE_statement();
select v1;

Result = 10

Accepted Solutions (1)

Accepted Solutions (1)

MarkCulp
Participant

This appears to be a bug. I have reproduced it on both the latest v12 and v16. I had a quick look a the code and it seems correct... so there is obviously something strange going on that will require more investigation.

Until this issue is fixed you can use 2b as a work-around.

(I'll post back here when the issue is fixed)

MarkCulp
Participant
0 Kudos

FYI: This issue is begin tracked as Engineering Issue (QTS) #693422

MarkCulp
Participant
0 Kudos

This has been fixed in 12.0.1 build 4031 and 16.0.0 build 1758.

Answers (0)