Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not detected invalid FETCH variable references #205

Open
torobito opened this issue Feb 4, 2022 · 0 comments
Open

Not detected invalid FETCH variable references #205

torobito opened this issue Feb 4, 2022 · 0 comments

Comments

@torobito
Copy link

torobito commented Feb 4, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant