Is this a bug in SQL Anywhere 17.0.9

create or replace database variable testvar bit default 0;
create or replace function testvar()
returns bit
begin
    if testvar = 1 then
        return(1);
    else
        return(0);
    end if;
end;
set testvar = 1;
select testvar;
select testvar();--why this delivers 0?

asked 06 Feb '22, 17:24

Baron's gravatar image

Baron
2.1k134146175
accept rate: 46%

edited 07 Feb '22, 02:12

1

Odd, seems to be a bug with 17.0.11.6800, too.

The behaviour is as expected when the database variable is qualified within the function:

create or replace database variable dba.testvar bit default 0;
create or replace function dba.testvar()
returns bit
begin
    if dba.testvar = 1 then
        return(1);
    else
        return(0);
    end if;
end;
set testvar = 1;
select testvar;
select testvar(); return 1 as expected
(07 Feb '22, 03:05) Volker Barth
1

It seems to affect a connection-level variable in version 16 as well.

create or replace variable testvar bit default 0;
create or replace function testvar()
returns bit 
begin
    if testvar = 1 then
        return(1);
    else
        return(0);
    end if;
end;
set testvar = 1;
select @@version, testvar, testvar();

@@version,testvar,testvar() '16.0.0.2512',true,false

@@version,testvar,testvar() '17.0.9.4882',true,false

(07 Feb '22, 08:35) Breck Carter
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×14

question asked: 06 Feb '22, 17:24

question was seen: 578 times

last updated: 07 Feb '22, 08:41