joereynolds / joereynolds/sql-lint

Not detected invalid FETCH variable references

Open
#205 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
459
Forks
44
PR merge metrics
No merged PRs in 30d

Description

It's not detected that the second FETCH is not referencing @i_field3:

```
ALTER PROCEDURE [proc_with_cursor]
AS
BEGIN
CREATE TABLE #mytemp (i_field1 INT, i_field2 INT, i_field4 INT, i_field3 INT )
DECLARE mycursor CURSOR local fast_forward read_only FOR SELECT i_field1,i_field2,i_field3,i_field4 FROM #mytemp
OPEN mycursor
FETCH next FROM mycursor INTO @idGiro, @i_field2, @i_field3, @i_field4
WHILE @@fetch_status = 0
BEGIN
IF ( @i_field4 = 1 )
BEGIN
EXEC [Proc_when_1]
END
ELSE
BEGIN
EXEC [Proc_when_0]
END
FETCH next FROM mycursor INTO @idGiro, @i_field2, @i_field4
END
CLOSE mycursor
DEALLOCATE mycursor
END

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.