I was investigating a mysterious problem which I now suspect may be a bug, as illustrated by the two simple stored functions below:-

create function getlv1() returns long varchar begin declare @lv long varchar; set @lv = @lv || 'a'; return @lv; end;

create function getlv2() returns long varchar begin declare @lv long varchar; declare @i integer; set @lv = @lv || 'a'; return @lv; end;

When I 'select getlv1()' in dbisql I receive an error message "Column '@lv' not found", but 'select getlv2()' works just fine. The only difference between the two definitions is the unused/unwanted declaration of the variable @i.

asked 11 Jul '13, 10:06

davef's gravatar image

davef
76123
accept rate: 0%


Thank you for reporting this problem.

You could work around the problem by using

declare @lv long varchar = NULL;

instead of the current declaration in the first function.

Why are you using @lv in the calculation? Using the variable provides no benefit for your calculation. Is there a different problem you are trying to solve?

permanent link

answered 11 Jul '13, 10:49

Elmi%20Eflov's gravatar image

Elmi Eflov
8061114
accept rate: 36%

1

Thank you for your suggestion.

The samples I provided were solely to illustrate what I thought might be a problem - one which arose when I split a very old stored procedure into umpteen separate bits. The original SP declared more than one variable (as in the second sample), and the return value was originally the result of concatenating many strings together, and this is where the unnecessary initial concatenation came from when I removed some unwanted prior code.

(11 Jul '13, 10:59) davef

Thank you for reporting this problem. I do believe that you have found a bug. We will investigate and provide a fix as needed.

permanent link

answered 11 Jul '13, 10:20

Karim%20Khamis's gravatar image

Karim Khamis
5.7k53870
accept rate: 40%

Your answer
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:

×125
×35
×28

question asked: 11 Jul '13, 10:06

question was seen: 2,815 times

last updated: 11 Jul '13, 11:22