BUG: ISNULL Function Causes Update Through View to Fail

Last reviewed: April 28, 1997
Article ID: Q88201

The information in this article applies to:
  • Microsoft SQL Server version 4.2 for OS/2
BUG# OS/2: 1428 (4.2)

SYMPTOMS

Following message appears

   Attempt to insert the value NULL into 'col2 ', table
   'master.dbo.mytable';
   column does not allow nulls. Update fails
   ( Msg 515, Level 16, State 3 )

when you execute this procedure

   create proc sp_isnull (@arg1 char(5) = NULL)

as:

   UPDATE mytableV
      set col2 = isnull(@arg1, col2)
   where col1 = 'a'

   select * from mytable order by col1

WORKAROUND

To ensure that you never encounter this intermittent problem, execute the procedure against the base table, "mytable", instead of the view, "mytableV". Another way to avoid this problem is to execute the procedure using the WITH RECOMPILE option after the problem has occurred.

STATUS

Microsoft has confirmed this to be a problem in SQL Server version 4.2 for OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Mytable and mytableV (the view) are defined as follows:

   create table mytable (col1 char(1), col2 char(5))
   go
   create view  mytableV as select * from mytable
   go
   insert mytable values ('a', 'aaaaa')
   insert mytable values ('b', 'bbbbb')

NOTE: The problem occurs only if you execute sp_isnull without any parameters right after you create the stored procedure; that is:

   exec sp_isnull

If you include parameters, such as exec sp_isnull 'aaa', you will not encounter the problem even if you subsequently execute the procedure without any parameters, as shown above.


Additional query words: Transact-SQL
Keywords : kbbug4.20 kbprg SSrvServer
Version : 4.2
Platform : OS/2


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.